Forum Discussion

snw's avatar
snw
New Contributor
9 years ago
Solved

Getting Error while trying to run soap xml using java

Hi, I am using maven-soapui-plugin 4.5.1 and I want to run a particular test step. I am using below code:

        WsdlProject abc = new WsdlProject(projectXMLPath);
        WsdlTestSuite wsdlTestSuite = abc.getTestSuiteByName(testSuiteName);
        WsdlTestCase wsdlTestCase = wsdlTestSuite.getTestCaseByName(testCaseName);
        WsdlTestCaseRunner wsdlTestCaseRunner = new WsdlTestCaseRunner(wsdlTestCase,new StringToObjectMap());
        WsdlTestStep wsdlTestStep = wsdlTestCase.getTestStepByName(testStepName);
        wsdlTestCaseRunner.run(wsdlTestStep);

Few things -
1. The project xml has 2 test suites, first test suite has the steps and second test suite has the library functions. In SoapUI they are coded as below:

First Test Step Script (Given a request with a valid address is made) from first Test Suite is as below:

    def proj= null
    def workspace = testRunner.testCase.testSuite.project.getWorkspace();

    proj= workspace.getProjectByName("Calling")

    def testCase = proj.testSuites["Library"].testCases["Successful Calling Steps" ]
    testRunner.testCase.setPropertyValue( "addressLine1", "xxxx" )
    testRunner.testCase.setPropertyValue( "city", "xxxx" )
    testRunner.testCase.setPropertyValue( "state", "xx" )

    def testStep = testCase.getTestStepByName("Given a request with a valid address is made")

    def runner = null
    runner = testStep.run(testRunner, context)

2. Second Test Script from Library Test suite has the actual REST request, end point for the webservice and webservice authentication.

3. If we execute the first test step in first test suite in SOAPUI, it internally calls the test step in Library replaces the variable values and makes a REST call to get a response. This works fine in SOAPUI, but when we are calling the first test step by run method in JAVA, it is failing with below error.


Exception in thread "main" java.lang.NoClassDefFoundError: com/jniwrapper/PlatformContext
 at com.eviware.soapui.SoapUI.isJXBrowserDisabled(SoapUI.java:1060)
 at com.eviware.soapui.SoapUI.isJXBrowserDisabled(SoapUI.java:1038)
 at com.eviware.soapui.impl.wsdl.submit.filters.HttpAuthenticationRequestFilter.filterAbstractHttpRequest(HttpAuthenticationRequestFilter.java:77)
 at com.eviware.soapui.impl.wsdl.submit.filters.AbstractRequestFilter.filterRequest(AbstractRequestFilter.java:31)
 at com.eviware.soapui.impl.wsdl.submit.transports.http.HttpClientRequestTransport.sendRequest(HttpClientRequestTransport.java:184)
 at com.eviware.soapui.impl.wsdl.WsdlSubmit.run(WsdlSubmit.java:123)
 at com.eviware.soapui.impl.wsdl.WsdlSubmit.submitRequest(WsdlSubmit.java:76)
 at com.eviware.soapui.impl.rest.RestRequest.submit(RestRequest.java:209)
 at com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep.run(RestTestRequestStep.java:898)
 at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:238)
 at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:224)
 at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner$runTestStep.call(Unknown Source)
 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
 at MyClass.simpletest1(MyClass.groovy:109)
 at test.main(test.java:11)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.ClassNotFoundException: com.jniwrapper.PlatformContext
 at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
 ... 22 more

 

What may be missed here that I need to add to resolve the issue? Please help.

 

 After further debug, I found that SoapUI.class -> line 734 is coded as below:

 

return disable.equals("true")?true:(getSoapUICore() != null && getSettings().getBoolean(UISettings.DISABLE_BROWSER)?true:(!disable.equals("false") && allowNative && (BrowserType.Mozilla.isSupported() || BrowserType.IE.isSupported() || BrowserType.Safari.isSupported())?false:!disable.equals("false") && !PlatformContext.isMacOS() && "64".equals(System.getProperty("sun.arch.data.model"))));

 and the PlatformContext class import is failing.

 

import com.jniwrapper.PlatformContext;

Please check and reply. 

  • I used below dependency instead of maven-soapui-plugin 4.5.1 and it fixed the issue.

     

    <dependency>
    <groupId>com.smartbear.soapui</groupId>
    <artifactId>soapui-maven-plugin</artifactId>
    <version>5.1.3</version>
    </dependency>

     

3 Replies

  • snw's avatar
    snw
    New Contributor

    I used below dependency instead of maven-soapui-plugin 4.5.1 and it fixed the issue.

     

    <dependency>
    <groupId>com.smartbear.soapui</groupId>
    <artifactId>soapui-maven-plugin</artifactId>
    <version>5.1.3</version>
    </dependency>

     

    • snw's avatar
      snw
      New Contributor

      Yes I used the latest Maven dependency and it resolved the issue.