I am receiving the above message when making a request to a java webservice.
We originally created a Java Console application and manually submitted an xml file. When running this as a Java Application the response is successfully created and displayed by using System.out.println. We are creating the web service by selecting the java file that contains the methods and choosing "create webservice" specifying the dynamic project that the webservice is to be created in and the methods to be exposed.
What the application is doing is taking an xml file and unmarshalling this to an object using:
public static Object unmarshalToObject(Class classToBeBound,
String xmlRequest) {
Object obj = new Object();
try {
JAXBContext jc = JAXBContext.newInstance(classToBeBound);
Unmarshaller um = jc.createUnmarshaller();
obj = um.unmarshal(new StringReader(xmlRequest));
} catch (Exception e) {
e.printStackTrace()
}
return obj;
}
Some processing is carried out on the file and then an object is marshalled to xml as follows:
public static String marshalToXML(Object data) {
StringWriter sw = new StringWriter();
try {
logger.info("Create new Marshall");
JAXBContext jc = JAXBContext.newInstance("ContextPathName");
logger.info("Marshalled to xmlObjects");
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.marshal(data, sw);
} catch (Exception e) {
logException(logger, e);
}
return sw.toString();
}
The following is the line of code that seems to be causing an issue as the logger displays the message prior to this:
JAXBContext jc = JAXBContext.newInstance("ContextPathName");
The webservice never gets to the next line - the following is the body of the SOAP message:
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.lang.reflect.InvocationTargetException</faultstring>
<detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">servername</ns1:hostname>
</detail>
</soapenv:Fault>
I have added Try/Catch around this section of code even as far as looking for JAXBExceptions but this does not seem to catch anything - nor does the general exception.
This issue does not occur when running the console application. The build path for this includes the following contents of sun\jwsdp-2.0\jaxb\lib:
jaxb-api.jar
jsr173_1.0_api.jar
jaxb-impl.jar
I have added these to the lib folder in the WEB-INF file of the dynamic project.
I am running the webservice in JBuilder 2008 R2 and using SOAPUI to submit the request - this points to the wsdl generated when creating the webservice.
If anyone has any help or ideas on how to solve this could they please reply - thanks for taking the time to read this post!
I am doing quite similar to you, taking in some XML via SOAP and marshalling it into objects. This isn't necessarily related to the problem.
The InvocationException is thrown when there is a problem with running some Java code inside of Axis in processing the request. You need to specify some extra options to get access to log output from Axis itself. Once you have this output, you will more than likely see an exception that will make sense to you (in my case I was using a class which I hadn't included on my server classpath).
Basically you need to add a LogHandler to your WSDD file. The following page has a good howto on what you need in the WSDD. However this page talks about the client-config.wsdd for an Axis client, whereas I am bundling Axis in my EAR and made the changes to server-config.wsdd.
http://www.theserverside.com/discussions/thread.tss?thread_id=35765
This page has info more specific to Tomcat
Note that the save location of axis.log can vary depending on your server and OS. Some people report it appearing in the System32 directory of Windows, the 2nd link says it will appear in the bin/ directory in Tomcat. In my case (Mac OS X, Glassfish 2.1.1) it turned up in the config/ directory of my domain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With