Andrew Dinn [
http://community.jboss.org/people/adinn] created the discussion
"Re: Problem with faults and classloaders in AS7"
To view the discussion, visit:
http://community.jboss.org/message/608493#608493
--------------------------------------------------------------
Alessio Soldano wrote:
> Andrew Dinn wrote:
>
> I found another glitch in the XTS interop demo which is als a package problem but it
was masked by not seeing an exception on the client side. The interop tests creates a
JaxWS proxy for the test Participant service which drives XTS and then asks it to run a
test. In some cases it passes transaction details using a handler to serialise them into
the message. My handler was failing with an NPE but the client proxy did not receive any
exception. Is this normal behaviour?
>
I don't think so, but I'd probably need to see more details / the code to better
understand.
Nothing much to see. It's a classic "I'll fix this later
cock-up". Here's the code.
public boolean handleMessage(SOAPMessageContext context) throws ProtocolException
{
final boolean outbound =
(Boolean)context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outbound) {
return handleMessageOutbound(context);
} else {
return handlemessageInbound(context);
}
}
protected boolean handleMessageOutbound(SOAPMessageContext context) throws
ProtocolException
{
try {
CoordinationContextType coordinationContext =
CoordinationContextManager.getThreadContext();
if (coordinationContext != null) {
final JAXBContext jaxbCtx = getJaxbContext();
// insert a header into the current message containing the coordination
context
final SOAPMessage soapMessage = context.getMessage();
final SOAPEnvelope soapEnvelope =
soapMessage.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = soapEnvelope.getHeader() ;
if (soapHeader == null)
{
soapHeader = soapEnvelope.addHeader() ;
}
. . .
SOAPHeaderElement headerElement =
soapHeader.addHeaderElement(getDummyQName());
Marshaller marshaller = jaxbCtx.createMarshaller();
marshaller.marshal(coordinationContext, headerElement);
. . .
}
} catch (Exception se) {
throw new ProtocolException(se);
}
return true;
}
and here's the code which returns the null pointer
private static JAXBContext jaxbContext;
private synchronized JAXBContext getJaxbContext()
{
if (jaxbContext == null) {
try {
jaxbContext =
JAXBContext.newInstance("org.oasis_open.docs.ws_tx.wscoor._2006._06");
} catch (JAXBException e) {
// TODO log error here
}
}
return jaxbContext;
}
I would have expected the ProtocolException to have resulted in an exception thrown from
the client proxy method invocation but the proxy call just returned normally.
Once again the classloader used to resollve the load under JAXBContext.newInstance was the
war classloader. I worked round this by adding 'com.sun.xml.bind services export'
to the dependencies in the war manifest.mf. However, I think it would be better if the
modules which import it (both jaxws-client and jbossws-cxf-client) also exported it. It
might be good if all the dependencies weer scrutinised to see whether they need
re-exporting.
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/608493#608493]
Start a new discussion in JBoss Web Services Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]