Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sample java code to retrieve AxisFault from InvocationTargetException

 
lucky Behl
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My InvocationTargetException prints following when did printStackTrace on it:



AxisFault
faultCode: device.could.not.be.created
faultSubcode:
faultString: The Device could not be created
faultActor:
faultNode:
faultDetail:
{http://schemas.xmlsoap.org/soap/envelope/}Fault:<faultcode>device.already.exists</faultcode><faultstring>Device already exists</faultstring>

The Device could not be created
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at com.motive.www.remotehdm.NBIService._1_0.NBIServicePortStub.createDevice(NBIServicePortStub.java:4846)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at motive.hdm.nbiclientutils.NBIServiceWSClientProxy.invoke(NBIServiceWSClientProxy.java:95)
at $Proxy18.createDevice(Unknown Source)
at motive.datasource.hdm.HDMNBIServiceWrapper.createDevice(HDMNBIServiceWrapper.java:1180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at motive.datasource.hdm.FailSafeAndLoadBalancer.handleHDMConnectionAndInvokeNBIAPIs(FailSafeAndLoadBalancer.java:131)
at motive.datasource.hdm.HDMDriver.execute(HDMDriver.java:84)
at motive.instrumentation.datasourcemgr.DatasourceMgr.execute(DatasourceMgr.java:206)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:247)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
at org.mozilla.javascript.gen._cmd__147._c_createDevice_3(<cmd>:69)
at org.mozilla.javascript.gen._cmd__147.call(<cmd>)
at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:97)
at org.mozilla.javascript.gen._cmd__147._c_generatedFunction_1(<cmd>:37)
at org.mozilla.javascript.gen._cmd__147.call(<cmd>)
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
at org.mozilla.javascript.gen._cmd__147._c_script_0(<cmd>:46)
at org.mozilla.javascript.gen._cmd__147.call(<cmd>)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3178)
at org.mozilla.javascript.gen._cmd__147.call(<cmd>)
at org.mozilla.javascript.gen._cmd__147.exec(<cmd>)
at org.mozilla.javascript.Context.evaluateString(Context.java:1111)
at motive.utilities.javascript.JavaScriptImpl.executeString(JavaScriptImpl.java:196)
at motive.instrumentation.datasourcemgr.DatasourceJavaScriptImpl.executeScriptNoCache(DatasourceJavaScriptImpl.java:233)
at motive.instrumentation.datasourcemgr.DatasourceJavaScriptImpl.executeScript(DatasourceJavaScriptImpl.java:161)
at motive.instrumentation.datasourcemgr.DatasourceMgr.executeScript(DatasourceMgr.java:426)
at motive.instrumentation.datasourcemgr.DatasourceMgr.executeScript(DatasourceMgr.java:378)
at motive.instrumentation.PropertyDiscoverable.discover(PropertyDiscoverable.java:340)
at motive.instrumentation.EcosystemDiscoverable.discoverProperty(EcosystemDiscoverable.java:1381)
at motive.instrumentation.EcosystemDiscoverable.discoverProperties(EcosystemDiscoverable.java:396)
at motive.instrumentation.ComponentDiscoverable.doDiscover(ComponentDiscoverable.java:265)
at motive.utilities.Discoverable.discover(Discoverable.java:741)
at motive.instrumentation.EcosystemDiscoverable.discover(EcosystemDiscoverable.java:111)
at motive.instrumentation.EcosystemDiscoverable.discover(EcosystemDiscoverable.java:96)
at motive.utilities.Discoverable.run(Discoverable.java:490)
at motive.java.util.ThreadPool$WorkerThread.run(ThreadPool.java:232)



I would like to retrieve faultcode & faultString from InvocationTargetException: <faultcode>device.already.exists</faultcode> <faultstring>Device already exists</faultstring>
how can i do this??

I tried following:



try {
// here code which throws InvocationFailureException
} catch (InvocationFailureException e) {
Throwable rootCause = e.getRootCause();
if (rootCause instanceof AxisFault) {
AxisFault axFault = (AxisFault)rootCause;
// now extract information, e.g.
axFault.getFaultDetails();
}
}



But only thing i am getting is: "The Device could not be created" Not able to get faultstring i.e. "Device already exists"

How could i retrieve faultString from InvocationTargetException??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic