Hi,

We are using Axis 1.2.1 and noticed the following behaviour (same behaviour in Axis 1.3):

We call org.apache.axis.tools.ant.wsdl.Java2WsdlAntTask to generate WSDL from Java.  The first thing Java2WsdlAntTask does is:

       AntClassLoader cl = new AntClassLoader(getClass().getClassLoader(),
                        getProject(),
                classpath == null ? createClasspath() : classpath,
                false);
       
        ClassUtils.setDefaultClassLoader(cl);

If the classpath for Java2WsdlAntTask includes activation.jar, when JavaUtils.isAttachmentSupported() is called, since

     ClassUtils.forName("javax.activation.DataHandler");

can be successfully executed, attachmentSupportEnabled is set to true.

However, later on, when Java2WsdlAntTask is constructing org.apache.axis.wsdl.fromJava.Emitter, I got the exception:

java.lang.NoClassDefFoundError: javax/activation/DataSource
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:141)
        at org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory.class$(JAFDataHandlerSerializerFactory.java:37)
        at org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory.getSerializerClass(JAFDataHandlerSerializerFactory.java:46)
        at org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory.<init>(JAFDataHandlerSerializerFactory.java:34)
        at org.apache.axis.encoding.DefaultTypeMappingImpl.initMappings(DefaultTypeMappingImpl.java:120)
        at org.apache.axis.encoding.DefaultTypeMappingImpl.<init>(DefaultTypeMappingImpl.java:91)
        at org.apache.axis.encoding.DefaultTypeMappingImpl.getSingletonDelegate(DefaultTypeMappingImpl.java:85)
        at org.apache.axis.encoding.TypeMappingRegistryImpl.<init>(TypeMappingRegistryImpl.java:155)
        at org.apache.axis.encoding.TypeMappingRegistryImpl.<init>(TypeMappingRegistryImpl.java:149)
        at org.apache.axis.wsdl.fromJava.Emitter.<clinit>(Emitter.java:747)
        at org.apache.axis.tools.ant.wsdl.Java2WsdlAntTask.execute(Java2WsdlAntTask.java:172)

Apparently, when initializing the type mapping registry, JAFDataHandlerSerializerFactory is called (since attachmentSupportEnabled is set to true).  It uses the Emitter's classloader, which does not have activation.jar in it's classpath (activation.jar and mail.jar is not in the Axis/lib directory).

My question is, shouldn't JavaUtils.isAttachmentSupported() be using the Emitter's classloader (like the rest of the other code called by the Emitter) rather than ClassUtils.forName (which uses the classloader based on the classpath passed to Java2WsdlAntTask)?  The fact that one classloader is used to determine if attachment is supported and another one is used to handling attachment type mapping is giving us trouble.

I've opened
http://issues.apache.org/jira/browse/AXIS-2146

for this problem and is wondering if others are running into similar problem.

Regards,

Kathy Chan

Reply via email to