Forum Discussion

SmartSoapUI's avatar
Occasional Contributor
5 years ago

Unexpected token in Groovy Scripting.

My agenda is to create a greeting() method inside the HelloWorld class using Eclipse and want to use the same method in Soap UI open source by importing that jar file.


Steps I've followed:

1. Created simple program in Java (This is the only class present in the Java Project)



2. Exported the complete Java Project as runnable jar and placed */bin/ext folder and restarted Soap UI

3.  Below is the code from Soap UI Groovy editor.


4. When I try to the program from Soap UI, getting the following error.


Is there any step that I missed? Would be grateful if anyone could help :)

5 Replies

  • JHunt's avatar
    Community Hero

    Your statement is inside the Raaki class, but not inside a method.


    Did you mean to put it after the end of the class ( } ) or inside the constructor?


    (By the way, images of code are less convenient for people to respond to... please use a code block and paste the code.)

    • SmartSoapUI's avatar
      Occasional Contributor

      Thank you JHunt for the quick response :) 

      I corrected that mistake but now getting "Unable to resolve error".

      Below is my code in Soap UI



      import com.raaki.*;
      class Raaki{
      	def context;
      	def log;
      	def testRunner;
      	def Raaki(log,context,testRunner){
      	def obj=new HelloWorld();
      	def str=obj.greeting("Rk");
      	def method(){ (str);
      context.setProperty("Raaki",new Raaki(log,context,testRunner))




      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script33.groovy: 14: unable to resolve class HelloWorld @ line 14, 
      column 10. def obj=new HelloWorld(); ^ org.codehaus.groovy.syntax.SyntaxException: unable to resolve class HelloWorld @ line 14, column 10. at
       org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError( at 
       org.codehaus.groovy.control.ResolveVisitor.resolveOrFail( at 
      org.codehaus.groovy.control.ResolveVisitor.resolveOrFail( at
      org.codehaus.groovy.control.ResolveVisitor.transformConstructorCallExpression( at
      org.codehaus.groovy.control.ResolveVisitor.transform( at
      org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitField( at
      org.codehaus.groovy.control.ResolveVisitor.visitField( at
      org.codehaus.groovy.ast.ClassNode.visitContents( at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass( at org.codehaus.groovy.control.ResolveVisitor.visitClass( at org.codehaus.groovy.control.ResolveVisitor.startResolving( at org.codehaus.groovy.control.CompilationUnit$ at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits( at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation( at org.codehaus.groovy.control.CompilationUnit.compile( at groovy.lang.GroovyClassLoader.doParseClass( at groovy.lang.GroovyClassLoader.parseClass( at groovy.lang.GroovyShell.parseClass( at groovy.lang.GroovyShell.parse( at groovy.lang.GroovyShell.parse( at groovy.lang.GroovyShell.parse( at at at at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$ at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$ Source) at Source) 1 error


      • JHunt's avatar
        Community Hero

        Try importing HelloWorld from com.raaki.demo package. At the moment you are only importing from com.raaki package.