Forum Discussion

bfourie's avatar
bfourie
Occasional Contributor
10 years ago
Solved

Adding JAR extensions

I'm trying to build in JSON validation in my tests in SoapUI NG.

I found json-schema-validator-2.2.6.jar as was described in the SoapUI cookbook.

In this book it tells me to copy all of those files to <Install Folder>\Java\ext 

However, in ReadyAPI that folder does not exist. How do I then add plugins and extensions to ReadyAPI?

 

I really need to get Restful JSON validation working. I've got little less than a week remaining on trial, and company will only get the licence once I have this validation bits working.

 

Any help will be appreciated. Even if it is an alternate way to validate response against json schema or raml.

 

Kind Regards

Ben

  • Ok Problem solved.

    Stupid problem really.

    I was running ReadyAPI 1.1.0

    I then updated to 1.2.2. However the shortcut on my desktop was still pointing to 1.1.0. Hence the java libs was copied into 1.2.2 since it is the one I thought I was using. As a simple test I copied into 1.2.2 folder. Everything worked perfect :-)

    Wil update shortcut now to point to the correct place.

     

    Thanks for everyones input.

     

11 Replies

  • bfourie's avatar
    bfourie
    Occasional Contributor

    Ok, 

    So I copied the files to C:\Program Files\SmartBear\ReadyAPI-1.2.2\bin\ext

    I then restarted Ready API.

     

    Yet, I'm not having any luck.

    It seems like thise libraries are not picked up.

     

    The Groovy Script that refrences those libs.

    import com.fasterxml.jackson.databind.JsonNode
    import com.fasterxml.jackson.databind.ObjectMapper
    import com.github.fge.jsonschema.core.report.ProcessingReport
    import com.github.fge.jsonschema.main.JsonSchema
    import com.github.fge.jsonschema.main.JsonSchemaFactory
    
    def response = context.expand( '${GetUser#Response}' )
    ObjectMapper mapper = new ObjectMapper()
    JsonNode GetUserJSON = mapper.readTree(response)
    JsonNode GetUserSchemaJSON = mapper.readTree(new File("/schema/GetUser200.raml"))
    JsonSchemaFactory factory = JsonSchemaFactory.byDefault()
    JsonSchema GetUserSchema = factory.getJsonSchema(GetUserSchemaJSON)
    if (GetUserSchema.validInstance(GetUserJSON)) 
    	{
    		log.info("Response Validated!")
    	}
    else 
    	{
    		testRunner.fail(GetUserSchema.validate(GetUserJSON).toString())
    	}

     

    And the result:

     

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script3.groovy: 
    5: unable to resolve class com.github.fge.jsonschema.main.JsonSchemaFactory @ line 5, column 1. 
    import com.github.fge.jsonschema.main.JsonSchemaFactory ^ org.codehaus.groovy.syntax.SyntaxException: 
    unable to resolve class com.github.fge.jsonschema.main.JsonSchemaFactory @ line 5, column 1. 
    at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:146) 
    at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1145) 
    at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:141) 
    at org.codehaus.groovy.control.CompilationUnit$10.call(CompilationUnit.java:632) 
    at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912) 
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574) 
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:523) 
    at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279) 
    at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258) 
    at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613) 
    at groovy.lang.GroovyShell.parse(GroovyShell.java:625) 
    at groovy.lang.GroovyShell.parse(GroovyShell.java:652) 
    at groovy.lang.GroovyShell.parse(GroovyShell.java:643) 
    at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:138) 
    at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:89) 
    at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SoapUIProGroovyScriptEngineFactory.java:76) 
    at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:139) 
    at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:263) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source)

     

    Any Ideas?

     

    • bfourie's avatar
      bfourie
      Occasional Contributor

      Ok got a bit further in understanding the problem...

      By looking at the current classpath def, it is not adding from the ext folder:

       

      set CLASSPATH=%READY_API_HOME%ready-api-ui-1.2.2.jar;%READY_API_HOME%..\lib\*;%READY_API_HOME%..\.install4j\*
      "%JAVA%" -cp "%CLASSPATH%" com.eviware.soapui.tools.JfxrtLocator > %TEMP%\jfxrtpath
      set /P JFXRTPATH= < %TEMP%\jfxrtpath
      del %TEMP%\jfxrtpath
      set CLASSPATH=%CLASSPATH%;%JFXRTPATH%

       

      • nmrao's avatar
        nmrao
        Champion Level 3

        Just a quick check! Have you restarted readyAPI tool after copying the jar files? If not, can you try that?