Ramnath
11 years agoNew Contributor
[Resolved] Require help - getting weird Class cast exception
Hi
I am running the Java code from eclipse to execute the request in soapui. The required tag elements are encapsulated in CDATA in the response. so What I am doing is, first take the response out as string and from that taking CDATA xml as string. Please look at the code below. But when I do this I am getting the following Class Cast execption at the below line:
line in the code - CDataXml = respxmlholder.getNodeValue("//data_flux[5]/item[2]")
Exception message -org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath cannot be cast to org.apache.xmlbeans.impl.store.PathDelegate.SelectPathInterface
When I run the same code in soapui it is running fine and fetching data's but when I trigger it from eclipse, I am getting classcastexception in Eclipse. Please advice.
Code used in Script assertion (I also used it in a groovy step, neither works). Groovy code is pasted below the error message
---------------------------------Error message below---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Attempt 1 to execute request
10:08:00,124 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Sending request: POST /OUGWar/workflow_soap HTTP/1.1
10:08:02,340 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Receiving response: HTTP/1.1 200 OK
10:08:02,340 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection can be kept alive indefinitely
java.lang.RuntimeException: java.lang.ClassCastException: org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath cannot be cast to org.apache.xmlbeans.impl.store.SaxonXBeansDelegate$SelectPathInterface
at org.apache.xmlbeans.impl.store.SaxonXBeansDelegate.createInstance(SaxonXBeansDelegate.java:102)
at org.apache.xmlbeans.impl.store.Path$SaxonPathImpl.create(Path.java:448)
at org.apache.xmlbeans.impl.store.Path.getCompiledPathSaxon(Path.java:185)
at org.apache.xmlbeans.impl.store.Path.getCompiledPath(Path.java:115)
at org.apache.xmlbeans.impl.store.Path.getCompiledPath(Path.java:91)
at org.apache.xmlbeans.impl.store.Cursor._selectPath(Cursor.java:902)
at org.apache.xmlbeans.impl.store.Cursor._selectPath(Cursor.java:894)
at org.apache.xmlbeans.impl.store.Cursor.selectPath(Cursor.java:2616)
at com.eviware.soapui.support.xml.XmlUtils.selectFirstDomNode(XmlUtils.java:1389)
at com.eviware.soapui.support.xml.XmlUtils.selectFirstNodeValue(XmlUtils.java:1367)
at com.eviware.soapui.support.XmlHolder.getNodeValue(XmlHolder.java:81)
at com.eviware.soapui.support.XmlHolder$getNodeValue.call(Unknown Source)
at Script1.run(Script1.groovy:25)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:100)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:154)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:239)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:52)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:152)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:47)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:139)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.start(AbstractTestRunner.java:81)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.run(WsdlTestCase.java:645)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.run(WsdlTestCase.java:77)
at com.soapuitutorial.script.ProjectTestRunner.main(ProjectTestRunner.java:59)
Caused by: java.lang.ClassCastException: org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath cannot be cast to org.apache.xmlbeans.impl.store.SaxonXBeansDelegate$SelectPathInterface
at org.apache.xmlbeans.impl.store.SaxonXBeansDelegate.createInstance(SaxonXBeansDelegate.java:97)
... 23 more
10:08:02,418 ERROR [SoapUI] An error occurred [No such property: CDataXml for class: Script1], see error log for details
groovy.lang.MissingPropertyException: No such property: CDataXml for class: Script1
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
at Script1.run(Script1.groovy:30)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:100)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:154)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:239)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:52)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:152)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:47)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:139)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.start(AbstractTestRunner.java:81)ougWS TestCase --- FAILED ---
-------------------------Groovy Script------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import com.eviware.soapui.support.XmlHolder
import java.util.*
context.setProperty("result","")
def response = context.expand('${ougWS - Top Up QS3 - BAN#response}')
log.info "STarting"
log.info response
log.info "Ending"
def respxmlholder = new XmlHolder(response)
def timestamp = System.currentTimeMillis()
def directory = "D:\\Documents and Settings\\raghunra\\Desktop\\Soapui_Pack\\Recording scripts\\freeversion_frameworks\\Response"
def responsefile = new File(directory,"response_${timestamp}.txt")
responsefile.append(response)
def request = context.expand('${ougWS - Top Up QS3 - BAN#request}')
def reqfile = new File(directory,"request_${timestamp}.txt")
reqfile.append(request)
log.info request
log.info "test"
try{
CDataXml = respxmlholder.getNodeValue("//data_flux[5]/item[2]") - Problem area
}catch (Exception e){
e.printStackTrace()
}
log.info "test2"
log.info (CDataXml)
log.info "test23"
def CDataXmlHolder = new XmlHolder(CDataXml)
log.info "test3"
TRC = CDataXmlHolder.getNodeValue("//AP-TR-REFERENCE")
RC1 = CDataXmlHolder.getNodeValue("//cd_rsn_pol[1]")
RC2 = CDataXmlHolder.getNodeValue("//cd_rsn_pol[2]")
FinDec = CDataXmlHolder.getNodeValue("//nm_dcsn")
FinSc = CDataXmlHolder.getNodeValue("//R-FINAL-SCORE")
I am running the Java code from eclipse to execute the request in soapui. The required tag elements are encapsulated in CDATA in the response. so What I am doing is, first take the response out as string and from that taking CDATA xml as string. Please look at the code below. But when I do this I am getting the following Class Cast execption at the below line:
line in the code - CDataXml = respxmlholder.getNodeValue("//data_flux[5]/item[2]")
Exception message -org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath cannot be cast to org.apache.xmlbeans.impl.store.PathDelegate.SelectPathInterface
When I run the same code in soapui it is running fine and fetching data's but when I trigger it from eclipse, I am getting classcastexception in Eclipse. Please advice.
Code used in Script assertion (I also used it in a groovy step, neither works). Groovy code is pasted below the error message
---------------------------------Error message below---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Attempt 1 to execute request
10:08:00,124 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Sending request: POST /OUGWar/workflow_soap HTTP/1.1
10:08:02,340 DEBUG [SoapUIMultiThreadedHttpConnectionManager$SoapUIDefaultClientConnection] Receiving response: HTTP/1.1 200 OK
10:08:02,340 DEBUG [HttpClientSupport$SoapUIHttpClient] Connection can be kept alive indefinitely
java.lang.RuntimeException: java.lang.ClassCastException: org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath cannot be cast to org.apache.xmlbeans.impl.store.SaxonXBeansDelegate$SelectPathInterface
at org.apache.xmlbeans.impl.store.SaxonXBeansDelegate.createInstance(SaxonXBeansDelegate.java:102)
at org.apache.xmlbeans.impl.store.Path$SaxonPathImpl.create(Path.java:448)
at org.apache.xmlbeans.impl.store.Path.getCompiledPathSaxon(Path.java:185)
at org.apache.xmlbeans.impl.store.Path.getCompiledPath(Path.java:115)
at org.apache.xmlbeans.impl.store.Path.getCompiledPath(Path.java:91)
at org.apache.xmlbeans.impl.store.Cursor._selectPath(Cursor.java:902)
at org.apache.xmlbeans.impl.store.Cursor._selectPath(Cursor.java:894)
at org.apache.xmlbeans.impl.store.Cursor.selectPath(Cursor.java:2616)
at com.eviware.soapui.support.xml.XmlUtils.selectFirstDomNode(XmlUtils.java:1389)
at com.eviware.soapui.support.xml.XmlUtils.selectFirstNodeValue(XmlUtils.java:1367)
at com.eviware.soapui.support.XmlHolder.getNodeValue(XmlHolder.java:81)
at com.eviware.soapui.support.XmlHolder$getNodeValue.call(Unknown Source)
at Script1.run(Script1.groovy:25)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:100)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:154)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:239)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:52)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:152)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:47)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:139)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.start(AbstractTestRunner.java:81)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.run(WsdlTestCase.java:645)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.run(WsdlTestCase.java:77)
at com.soapuitutorial.script.ProjectTestRunner.main(ProjectTestRunner.java:59)
Caused by: java.lang.ClassCastException: org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath cannot be cast to org.apache.xmlbeans.impl.store.SaxonXBeansDelegate$SelectPathInterface
at org.apache.xmlbeans.impl.store.SaxonXBeansDelegate.createInstance(SaxonXBeansDelegate.java:97)
... 23 more
10:08:02,418 ERROR [SoapUI] An error occurred [No such property: CDataXml for class: Script1], see error log for details
groovy.lang.MissingPropertyException: No such property: CDataXml for class: Script1
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
at Script1.run(Script1.groovy:30)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:100)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:154)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:239)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:52)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:152)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:47)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:139)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.start(AbstractTestRunner.java:81)ougWS TestCase --- FAILED ---
-------------------------Groovy Script------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
import com.eviware.soapui.support.XmlHolder
import java.util.*
context.setProperty("result","")
def response = context.expand('${ougWS - Top Up QS3 - BAN#response}')
log.info "STarting"
log.info response
log.info "Ending"
def respxmlholder = new XmlHolder(response)
def timestamp = System.currentTimeMillis()
def directory = "D:\\Documents and Settings\\raghunra\\Desktop\\Soapui_Pack\\Recording scripts\\freeversion_frameworks\\Response"
def responsefile = new File(directory,"response_${timestamp}.txt")
responsefile.append(response)
def request = context.expand('${ougWS - Top Up QS3 - BAN#request}')
def reqfile = new File(directory,"request_${timestamp}.txt")
reqfile.append(request)
log.info request
log.info "test"
try{
CDataXml = respxmlholder.getNodeValue("//data_flux[5]/item[2]") - Problem area
}catch (Exception e){
e.printStackTrace()
}
log.info "test2"
log.info (CDataXml)
log.info "test23"
def CDataXmlHolder = new XmlHolder(CDataXml)
log.info "test3"
TRC = CDataXmlHolder.getNodeValue("//AP-TR-REFERENCE")
RC1 = CDataXmlHolder.getNodeValue("//cd_rsn_pol[1]")
RC2 = CDataXmlHolder.getNodeValue("//cd_rsn_pol[2]")
FinDec = CDataXmlHolder.getNodeValue("//nm_dcsn")
FinSc = CDataXmlHolder.getNodeValue("//R-FINAL-SCORE")