views:

361

answers:

2

I have a very annoying problem.

So I want to include 2 jar files in my java web application (.war file) - to be loaded on glassfish version 2.1.

The files are:

axis2-adb-1.4.1.jar and wstx-asl-3.2.4.jar.

In my console application, I simply add these to my classpath and they run fine. However, when I deploy this to glassfish (jars are placed in WEB-INF/lib/) I get this:

java.lang.reflect.InvocationTargetException

org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Can not invoke the getTypeObject method in the extension mapper class

I noticed that in my console application, when I removed wstx-asl-3.2.4.jar from my classpath, I would get this exact same error. So my feeling is that this jar is not loaded some how.

I then moved on to repackaging the jars together. I made this big axis2+wstx.jar and loaded it into my glassfish project. Same error... It is definately loading since without the axis2 jar it would throw a axis2 class not def exception way earlier.

So my theory is that glassfish is loading the jars lazily and since neither the axis2 jar nor my main program requires this wstx jar, it is not loaded correctly. But I am probably totally wrong.

I really hope someone could help me out with this.

A: 

I think that there is the same class in both of jars. And somehow class without getTypeObject method is loaded as first. If there is chance to change the order of loaded jars in classpath it would help.

kogut
+1  A: 

Starting with GF v2 b49, Woodstox is integrated as part of Glassfish along with sjsxp which remains the default parser. To enable Woodstox set the following system properties on the server side:

-Djavax.xml.stream.XMLEventFactory=com.ctc.wstx.stax.WstxEventFactory
-Djavax.xml.stream.XMLInputFactory=com.ctc.wstx.stax.WstxInputFactory
-Djavax.xml.stream.XMLOutputFactory=com.ctc.wstx.stax.WstxOutputFactory

More details in Woodstox in Glassfish v2.

If using the integrated Woodstox doesn't meet your requirements, then maybe try to activate the "class loading delegation feature" in the sun-web.xml file by setting by setting delegate="false" in the class-loader element. Something like that:

<sun-web-app>
  <class-loader delegate="false"/>
</sun-web-app>
Pascal Thivent
holy crap this works. You're amazing. I'll look more into setting these system properties :)
Andy