|
Title: Using user-defined java (or groovy) class in script Post by: PeterT on March 06, 2008, 04:32:49 am Hi there
So, I'm finally getting a bit of a handle on SoapUI and Groovy. One thing (at the moment) that I'm having trouble with is using a user-defined java class in my Groovy Script. I've made a very basic class, Test.java, which just returns a string. I've compiled it and put both the .java and .class file in the \soapUI-2.0.2\bin\ext folder and imported the package in my script. When I try to run the script however it cannot resolve the new object that I created (e.g. def t = new Test()). I know that this should be doable and I'm sure I just haven't put the .class file in the right location or something like that. Can anyone shed any light on this? Cheers Peter Title: Re: Using user-defined java (or groovy) class in script Post by: omatzura on March 06, 2008, 07:04:10 am Hi Peter,
you need to package your class file in a jar archive and then put that .jar file in the bin\ext folder. Hope this helps! regards, /Ole eviware.com Title: Re: Using user-defined java (or groovy) class in script Post by: PeterT on March 06, 2008, 08:12:47 pm Hi Ole
Actually I did that and while I could see in the command window that it was picking up the .jar file it still didn't recognise the object I was trying to create. Perhaps I screwed up creating my .jar, will give it another go. Thanks for your help again. Cheers Peter Title: Re: Using user-defined java (or groovy) class in script Post by: omatzura on March 07, 2008, 12:08:16 am Ok, hope it works better this time, let me know if we can help some more!
regards! /Ole eviware.com Title: Re: Using user-defined java (or groovy) class in script Post by: Pesotska on March 14, 2008, 02:17:18 pm Hi,
I have also the problem with user-defined java class in Groovy script I've made a very basic class Test.java, which returns a string. I have packaged Test.class in a jar archive and then put test.jar file in the soapUI-2.0.2\bin\ext folder. Groovy script: import soapuitest.* def test = new soapuitest.Test() By script Running: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script14.groovy: 3: unable to resolve class mysoapuitest.GenerateExternalBookingId @ line 3, column 14. org.codehaus.groovy.syntax.SyntaxException: unable to resolve class mysoapuitest.GenerateExternalBookingId @ line 3, column 14. at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:113) at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:132) .... Could someone help me? Best regards, Liliya Title: Re: Using user-defined java (or groovy) class in script Post by: Pesotska on March 14, 2008, 04:00:39 pm Sorry!
:) It functions nevertheless, error lay in the JAR! Best regards, Liliya |