Forum Discussion

MNeidt's avatar
MNeidt
New Contributor
13 years ago

NullPointerException when logging HTTP Request results

Hello,

I encountered a NullPointerException and suppose this is a bug (if it's something I've done wrong I am sure you will tell me :-) ).

The situation is as follows:

- TestCase A sends an HTTP request (not SOAP) to a remote server
- TestCase B calls A and provides some parameters (A is a generic test case)
- in the project settings I created an afterStep event that logs the outcome of each test step, just as proposed here: http://www.soapui.org/Scripting-Propert ... ng-results

filePath = 'c:/testresults'
fos = new FileOutputStream( filePath + testStepResult.testStep.label + '.txt', true )
pw = new PrintWriter( fos )
testStepResult.writeTo( pw )
pw.close()
fos.close()


When I call TestCase B, a NullPointerException is being thrown during the logging event as follows:

Mon Mar 19 11:14:42 CET 2012:ERROR:java.lang.NullPointerException
java.lang.NullPointerException
at java.lang.String.<init>(Unknown Source)
at com.eviware.soapui.impl.wsdl.teststeps.RestRequestStepResult.writeTo(RestRequestStepResult.java:210)
at com.eviware.soapui.model.testsuite.TestStepResult$writeTo.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at com.eviware.soapui.model.testsuite.TestStepResult$writeTo.call(Unknown Source)
at Script62.run(Script62.groovy:8)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:96)
at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:88)
at com.eviware.soapui.eventhandlers.support.DefaultSoapUIScript.invoke(SourceFile:47)
at com.eviware.soapui.eventhandlers.support.DefaultSoapUIEventHandler.invoke(SourceFile:29)
at com.eviware.soapui.eventhandlers.support.AbstractEventHandlerMetaData.invokeHandlers(SourceFile:73)
at com.eviware.soapui.eventhandlers.support.AbstractEventHandlerMetaData.invokeHandlers(SourceFile:49)
at com.eviware.soapui.eventhandlers.impl.EventHandlersTestRunListener.afterStep(SourceFile:41)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:244)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:48)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:141)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:42)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:135)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


Some more information:
- The Exception does not occur when I run TestCase A directly, nor on any other test step type.
- This seems to be independent of the utilized HTTP method (tested GET and POST).
- I also have a similar situation in the same project where I use a SOAP request instead of HTTP. There it does work, so the problem is limited to the HTTP Test Request step.
- The HTTP request for now simply targets an Apache Tomcat index page, so there is a valid HTML response.
- soapUI version is 4.0.1 pro (Build dist-142-2011-09-14, Build Date 2011/09/14 13:38)

Thank you in advance for your help. Please let me know if you need further information.

7 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    thanks for this - it is a bug that should be fixed in the 4.5 beta version, can you give that a try to confirm?

    regards,

    /Ole
    SmartBear Software
  • MNeidt's avatar
    MNeidt
    New Contributor
    Hello Ole,

    thanks for your answer. I installed 4.5.0 beta2 in the meantime, but the problem still persists. If you were referring to viewtopic.php?f=13&t=12507 it might be worthwhile to glimpse at the differences between these problems, which are "vanilla" HTTP vs. REST and HTTP status 200 vs. 204 in the other post.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    hmm.. can you show the stacktrace you are getting with the 4.5 beta?

    thanks!

    /Ole
    SmartBear Software
  • MNeidt's avatar
    MNeidt
    New Contributor
    Hello Ole,

    of course, here it is:

    Wed Mar 21 12:01:10 CET 2012:ERROR:java.lang.NullPointerException
    java.lang.NullPointerException
    at java.lang.String.<init>(Unknown Source)
    at com.eviware.soapui.impl.wsdl.teststeps.RestRequestStepResult.writeTo(RestRequestStepResult.java:223)
    at com.eviware.soapui.model.testsuite.TestStepResult$writeTo.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at com.eviware.soapui.model.testsuite.TestStepResult$writeTo.call(Unknown Source)
    at Script1.run(Script1.groovy:8)
    at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:96)
    at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:89)
    at com.eviware.soapui.eventhandlers.support.DefaultSoapUIScript.invoke(SourceFile:47)
    at com.eviware.soapui.eventhandlers.support.DefaultSoapUIEventHandler.invoke(SourceFile:29)
    at com.eviware.soapui.eventhandlers.support.AbstractEventHandlerMetaData.invokeHandlers(SourceFile:73)
    at com.eviware.soapui.eventhandlers.support.AbstractEventHandlerMetaData.invokeHandlers(SourceFile:49)
    at com.eviware.soapui.eventhandlers.impl.EventHandlersTestRunListener.afterStep(SourceFile:41)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:250)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:48)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:147)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:42)
    at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:135)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)


    (the line number in RestRequestStepResult.java has changed, but else the exception seems to be the same)
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Thanks! I've fixed this one now - unfortunately you will have to wait until the final 4.5 to try it out.

    regards!

    /Ole
    SmartBear Software