3

I am getting the following error messages returned:

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script3.groovy: 1: unable to resolve class groovy.json.JsonSlurpe @ line 1, column 1. import groovy.json.JsonSlurpe ^ 
    org.codehaus.groovy.syntax.SyntaxException: unable to resolve class groovy.json.JsonSlurpe @ line 1, column 1. at 
    org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:149) at 
    org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1225) at 
    org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:178) at 
    org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:651) at 
    org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:931) at 
    org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593) at 
    org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:542) at 
Johnny Rockex
  • 4,136
  • 3
  • 35
  • 55
Deepika Raj
  • 41
  • 1
  • 1
  • 3
  • 1
    Can you show your script please? And error in line 1? see if there are any invisible characters. – Rao Aug 24 '17 at 08:45
  • 2
    Why hello there, welcome to SO. It's a great resource for coding problems and so forth, but it's important to format your questions correctly. I edited your question for clarity and readability. As a rule of thumb it's good to post what code you have already tried to solve your problem. You have access to some of the best coders in the world on here (for free!) but we have to keep the community spick and span :D – Johnny Rockex Aug 24 '17 at 08:46
  • Deepika, have you got chance to try the solution? – Rao Aug 31 '17 at 03:58

3 Answers3

21

Try changing the first line. Trivial typo.

From:

import groovy.json.JsonSlurpe

To:

import groovy.json.JsonSlurper
Rao
  • 20,781
  • 11
  • 57
  • 77
1

Your first line should be like this...

import net.sf.json.groovy.JsonSlurper

This worked for me.

1

Ensure you have groovy.json on class path, e.g. depend on

<dependency>
    <groupId>org.apache.groovy</groupId>
    <artifactId>groovy-json</artifactId>
</dependency>

or

<dependency>
    <groupId>org.apache.groovy</groupId>
    <artifactId>groovy-all</artifactId>
</dependency>