Search code examples
javaglassfishosgijava.util.loggingsaaj

java.util.logging, ResourceBundles, SAAJ: exception on loading Glassfish OSGi webapp bundle


I'm being driven out of my mind by the following exception:

java.lang.IllegalArgumentException: 
com.sun.xml.messaging.saaj.soap.LocalStrings != com.sun.xml.internal.messaging.saaj.soap.LocalStrings
    at java.util.logging.Logger.getLogger(Logger.java:357)
    at com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl.<clinit>(SAAJMetaFactoryImpl.java:41)

It's occurring when I try to deploy a WAB (web application OSGi bundle) to Glassfish (3.1.1).

I'm trying to use an up-to-date version of SAAJ (com.sun.xml.messaging.saaj...) rather than the old JDK one (which is the com.sun.xml.internal.saaj... one), by putting the string com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl in the file META-INF/services/javax.xml.soap.MessageFactory.

It appears there is some logging going on before the OSGi classloading kicks in, and therefore the 'wrong' ResourceBundle is being returned during initialization of the static log field of com.sun.xml.messaging.saaj.soap.MessageFactoryImpl (SAAJ's implementation of javax.xml.soap.MessageFactory).

Anyone seen this / any workarounds on offer?


Solution

  • Never got to the bottom of this, but manifest voodoo eventually made it go away (with all of the javax.xml.ws / javax.ws.rs packages in Import-Package rather than on the bundle classpath WEB-INF/lib).

    It was also possible to work around it by using

    -Djavax.xml.soap.MessageFactory=com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl 
    

    on Glassfish startup, though obviously this forces that implementation on all users of MessageFactory.