Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error importing jar in groovy script (soapui)

I have a problem with running java code from groovy script (groovy script is a part of SoapUI test suite) i create simple script:

import myjar.jar
new TopClass().sayHello()

the code of TopClass:

public class TopClass {
    public void sayHello (){
        System.out.println("Hello");
    }   
}

I put myjar.jar into both soapui-pro-2.5\lib and soapui-pro-2.5\bin\ext folders. But running script I get:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script1.groovy: 2: unable to resolve class myjar.jar @ line 2, column 1.org.codehaus.groovy.syntax.SyntaxException: unable to resolve class myjar.jar @ line 2, column 1. at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:113) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:970) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:141) at org.codehaus.groovy.control.CompilationUnit$5.call(CompilationUnit.java:527) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:772) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:438) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:281) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:572) at groovy.lang.GroovyShell.parse(GroovyShell.java:584) at groovy.lang.GroovyShell.parse(GroovyShell.java:564) at groovy.lang.GroovyShell.parse(GroovyShell.java:603) at

Please help me to find what I'm doing wrong

like image 746
Oleksandr Martynov Avatar asked Apr 28 '12 11:04

Oleksandr Martynov


2 Answers

Putting the jar under soapui-pro-2.5\bin\ext is all you need for the classes to be found (although restarting SoapUI won't hurt).

However - you should check that the error you get is related to your jar. Is com.my.research available within myjar.jar? If no - just add it.

If yes, add more detailed information to your post.

like image 129
RonK Avatar answered Oct 28 '22 17:10

RonK


import myjar.jar

I believe this is not correct, you should be importing the name of the java package not the name of the jar. Hope this helps

like image 39
Philippe Avatar answered Oct 28 '22 15:10

Philippe