Forum Discussion

apratik's avatar
apratik
New Contributor
9 years ago

Error using custom JAR in SOAP UI Groovy Test Step

I am trying to include custom code for SAML generation (in form of JAR) into Groovy test step. Below are the steps I followed :

 

1. Created JAR

2.Copied JAR and their dependencies in .../bin/ext

3. Restarted SOAP UI

 

Added below code in Groovy test step:

 

import com.example.test.SAML2OpenSamlHelper;

 

SAML2OpenSamlHelper s = new SAML2OpenSamlHelper();

String saml = s.generateResponseString("Raj","mypage.com", null, false, "", false, false);

log.info (saml);

 

But getting below error when executing :

 

Thu Jun 30 14:10:25 MST 2016:ERROR:java.lang.NoClassDefFoundError: org/apache/velocity/app/Velocity java.lang.NoClassDefFoundError: org/apache/velocity/app/Velocity at org.opensaml.DefaultBootstrap.initializeVelocity(DefaultBootstrap.java:172) at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:89) at com.example.test.SAML2OpenSamlHelper.setUp(SAML2OpenSamlHelper.java:212) at com.example.test.SAML2OpenSamlHelper.init(SAML2OpenSamlHelper.java:190) at com.example.test.SAML2OpenSamlHelper.(SAML2OpenSamlHelper.java:124) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186) at Script6.run(Script6.groovy:2) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:92) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141) at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:250) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)

 

Am I doing something wrong or missing some step ? Help will be appreciated...

 

Thanks,

Abhi

  • Hi Abhi,

     

    The steps you described for adding a jar file library appear correct - I actually did a basic blog of how to build and add jar file libraries to SoapUI, let me know if it helps:

     

    http://rupertanderson.com/blog/1-how-to-develop-add-and-use-a-custom-groovy-library-in-soapui/

     

    Something that isn't in the blog (which I might well add now) is how to handle when a SoapUI jar library requires external dependencies - in this case, I can see that NoClassDefFoundError for:

     

    org/apache/velocity/app/Velocity

     

    can be obtained from https://mvnrepository.com/artifact/org.apache.velocity/velocity/1.7

     

    The jar file containing this must also be present on the SoapUI class path. So if it isn't in the SoapUI /lib folder, then you need to add this velocity jar to the /ext folder too - are you sure that this velocity jar is present in either /lib or the /ext folder?

     

    Regards,

    Rupert

  • apratik's avatar
    apratik
    New Contributor
    Thanks rupert.... Well written blog and great answer.Exactly I was looking for the same. I am able to use Jar now.
    • rupert_anderson's avatar
      rupert_anderson
      Valued Contributor

      Thanks Abhi, nice of you to say. Feedback is important to me and makes me want to blog more! :-)

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi Abhi,

     

    The steps you described for adding a jar file library appear correct - I actually did a basic blog of how to build and add jar file libraries to SoapUI, let me know if it helps:

     

    http://rupertanderson.com/blog/1-how-to-develop-add-and-use-a-custom-groovy-library-in-soapui/

     

    Something that isn't in the blog (which I might well add now) is how to handle when a SoapUI jar library requires external dependencies - in this case, I can see that NoClassDefFoundError for:

     

    org/apache/velocity/app/Velocity

     

    can be obtained from https://mvnrepository.com/artifact/org.apache.velocity/velocity/1.7

     

    The jar file containing this must also be present on the SoapUI class path. So if it isn't in the SoapUI /lib folder, then you need to add this velocity jar to the /ext folder too - are you sure that this velocity jar is present in either /lib or the /ext folder?

     

    Regards,

    Rupert