You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Dennis Sosnoski <dm...@sosnoski.com> on 2007/03/18 08:56:41 UTC

[Axis2] Classloading broken for static code in message receiver

I've started experimenting with the current pre-1.2 code, and ran into a 
problem with the classloading. JiBX generates static initializers as 
part of the message receiver code, in order to configure some of the 
binding information used by JiBX when the service methods are called. In 
the case I'm working on, one of the classes being loaded by the static 
code is in a jar file, located in the /lib directory of the aar. This 
worked fine in 1.1 and 1.1.1, but now I get:

java.lang.NoClassDefFoundError: 
com/sosnoski/ws/library/jibx/AddDuplicateFault
    at 
org.apache.axis2.jibx.library.JibxLibraryMessageReceiverInOut.<clinit>(JibxLibraryMessageReceiverInOut.java:99)
    ...

So it looks like the /lib/*.jar files are no longer being added to the 
classpath used when loading the message receiver. Is this a deliberate 
change, and if so can someone explain the logic? Or is there some 
special classloader I should be using?

Thanks,

  - Dennis

-- 
Dennis M. Sosnoski
SOA and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] Classloading broken for static code in message receiver

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
Dennis Sosnoski wrote:
> Incidentally, when I try to deploy this the failure is not a one-time 
> thing - Axis2 keeps retrying the failed aar deployment, so the server 
> log keeps growing with more of the failure stack traces. I understand 
> that the code works this way in order to support hot deployment by 
> dropping the aar file in the /services directory, but this could lead to 
> problems in production systems.
> 
> I'd suggest that if the aar cannot be deployed it should either be added 
> to an ignore list (with time stamp, so that if its overwritten by a 
> later version another deployment attempt will be made) or just deleted 
> from the /service directory.

+1. Please open a separate issue for this one.

Sanjiva.
-- 
Sanjiva Weerawarana, Ph.D.
Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
Director; Open Source Initiative; http://www.opensource.org/
Member; Apache Software Foundation; http://www.apache.org/
Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] Classloading broken for static code in message receiver

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Incidentally, when I try to deploy this the failure is not a one-time 
thing - Axis2 keeps retrying the failed aar deployment, so the server 
log keeps growing with more of the failure stack traces. I understand 
that the code works this way in order to support hot deployment by 
dropping the aar file in the /services directory, but this could lead to 
problems in production systems.

I'd suggest that if the aar cannot be deployed it should either be added 
to an ignore list (with time stamp, so that if its overwritten by a 
later version another deployment attempt will be made) or just deleted 
from the /service directory.

  - Dennis

Dennis Sosnoski wrote:
> I'll create a Jira and attach the aar and message receiver source code.
>
> Thanks!
>
>  - Dennis
>
> Davanum Srinivas wrote:
>> Quite possible. How can i recreate this problem?
>>
>> thanks,
>> dims
>>
>> On 3/18/07, Dennis Sosnoski <dm...@sosnoski.com> wrote:
>>> Yes, the jar is in the /lib directory of the aar. And the problem is
>>> occurring in a static block in the generated message receiver.
>>>
>>>  From a look through the code,
>>> org.apache.axis2.deployment.DescriptionBuilder.processMessageReceivers
>>> is using the thread's context class loader to load the message 
>>> receiver.
>>> I see where the aar class loader is set on the service under
>>> construction in
>>> org.apache.axis2.deployment.repository.util.ArchiveReader, but do not
>>> see it being set as the context class loader. Is that the problem?
>>>
>>>   - Dennis
>>>
>>> Davanum Srinivas wrote:
>>> > Are these jars inside aar's? We were extracting those jars from the
>>> > aar, dumping them in temp and adding them to classpath. This was
>>> > filling up disk space and turned out to be a bad idea. So i added
>>> > support for jar:// syntax (code from Geronimo) in URLClassLoader 
>>> using
>>> > a custom URLStreamHandler. I think you could try to generate some
>>> > static blocks in the generated message receiver to do what you need.
>>> >
>>> > thanks,
>>> > -- dims
>>> >
>>> > On 3/18/07, Dennis Sosnoski <dm...@sosnoski.com> wrote:
>>> >> I've started experimenting with the current pre-1.2 code, and ran 
>>> into a
>>> >> problem with the classloading. JiBX generates static initializers as
>>> >> part of the message receiver code, in order to configure some of the
>>> >> binding information used by JiBX when the service methods are 
>>> called. In
>>> >> the case I'm working on, one of the classes being loaded by the 
>>> static
>>> >> code is in a jar file, located in the /lib directory of the aar. 
>>> This
>>> >> worked fine in 1.1 and 1.1.1, but now I get:
>>> >>
>>> >> java.lang.NoClassDefFoundError:
>>> >> com/sosnoski/ws/library/jibx/AddDuplicateFault
>>> >>     at
>>> >> 
>>> org.apache.axis2.jibx.library.JibxLibraryMessageReceiverInOut.<clinit>(JibxLibraryMessageReceiverInOut.java:99) 
>>>
>>> >>
>>> >>     ...
>>> >>
>>> >> So it looks like the /lib/*.jar files are no longer being added 
>>> to the
>>> >> classpath used when loading the message receiver. Is this a 
>>> deliberate
>>> >> change, and if so can someone explain the logic? Or is there some
>>> >> special classloader I should be using?
>>> >>
>>> >> Thanks,
>>> >>
>>> >>   - Dennis
>>> >>
>>> >> --
>>> >> Dennis M. Sosnoski
>>> >> SOA and Web Services in Java
>>> >> Training and Consulting
>>> >> http://www.sosnoski.com - http://www.sosnoski.co.nz
>>> >> Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
>>> >>
>>> >>
>>> >> 
>>> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>>> >> For additional commands, e-mail: axis-dev-help@ws.apache.org
>>> >>
>>> >>
>>> >
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-dev-help@ws.apache.org
>>>
>>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] Classloading broken for static code in message receiver

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
I'll create a Jira and attach the aar and message receiver source code.

Thanks!

  - Dennis

Davanum Srinivas wrote:
> Quite possible. How can i recreate this problem?
>
> thanks,
> dims
>
> On 3/18/07, Dennis Sosnoski <dm...@sosnoski.com> wrote:
>> Yes, the jar is in the /lib directory of the aar. And the problem is
>> occurring in a static block in the generated message receiver.
>>
>>  From a look through the code,
>> org.apache.axis2.deployment.DescriptionBuilder.processMessageReceivers
>> is using the thread's context class loader to load the message receiver.
>> I see where the aar class loader is set on the service under
>> construction in
>> org.apache.axis2.deployment.repository.util.ArchiveReader, but do not
>> see it being set as the context class loader. Is that the problem?
>>
>>   - Dennis
>>
>> Davanum Srinivas wrote:
>> > Are these jars inside aar's? We were extracting those jars from the
>> > aar, dumping them in temp and adding them to classpath. This was
>> > filling up disk space and turned out to be a bad idea. So i added
>> > support for jar:// syntax (code from Geronimo) in URLClassLoader using
>> > a custom URLStreamHandler. I think you could try to generate some
>> > static blocks in the generated message receiver to do what you need.
>> >
>> > thanks,
>> > -- dims
>> >
>> > On 3/18/07, Dennis Sosnoski <dm...@sosnoski.com> wrote:
>> >> I've started experimenting with the current pre-1.2 code, and ran 
>> into a
>> >> problem with the classloading. JiBX generates static initializers as
>> >> part of the message receiver code, in order to configure some of the
>> >> binding information used by JiBX when the service methods are 
>> called. In
>> >> the case I'm working on, one of the classes being loaded by the 
>> static
>> >> code is in a jar file, located in the /lib directory of the aar. This
>> >> worked fine in 1.1 and 1.1.1, but now I get:
>> >>
>> >> java.lang.NoClassDefFoundError:
>> >> com/sosnoski/ws/library/jibx/AddDuplicateFault
>> >>     at
>> >> 
>> org.apache.axis2.jibx.library.JibxLibraryMessageReceiverInOut.<clinit>(JibxLibraryMessageReceiverInOut.java:99) 
>>
>> >>
>> >>     ...
>> >>
>> >> So it looks like the /lib/*.jar files are no longer being added to 
>> the
>> >> classpath used when loading the message receiver. Is this a 
>> deliberate
>> >> change, and if so can someone explain the logic? Or is there some
>> >> special classloader I should be using?
>> >>
>> >> Thanks,
>> >>
>> >>   - Dennis
>> >>
>> >> --
>> >> Dennis M. Sosnoski
>> >> SOA and Web Services in Java
>> >> Training and Consulting
>> >> http://www.sosnoski.com - http://www.sosnoski.co.nz
>> >> Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>> >> For additional commands, e-mail: axis-dev-help@ws.apache.org
>> >>
>> >>
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-dev-help@ws.apache.org
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] Classloading broken for static code in message receiver

Posted by Davanum Srinivas <da...@gmail.com>.
Quite possible. How can i recreate this problem?

thanks,
dims

On 3/18/07, Dennis Sosnoski <dm...@sosnoski.com> wrote:
> Yes, the jar is in the /lib directory of the aar. And the problem is
> occurring in a static block in the generated message receiver.
>
>  From a look through the code,
> org.apache.axis2.deployment.DescriptionBuilder.processMessageReceivers
> is using the thread's context class loader to load the message receiver.
> I see where the aar class loader is set on the service under
> construction in
> org.apache.axis2.deployment.repository.util.ArchiveReader, but do not
> see it being set as the context class loader. Is that the problem?
>
>   - Dennis
>
> Davanum Srinivas wrote:
> > Are these jars inside aar's? We were extracting those jars from the
> > aar, dumping them in temp and adding them to classpath. This was
> > filling up disk space and turned out to be a bad idea. So i added
> > support for jar:// syntax (code from Geronimo) in URLClassLoader using
> > a custom URLStreamHandler. I think you could try to generate some
> > static blocks in the generated message receiver to do what you need.
> >
> > thanks,
> > -- dims
> >
> > On 3/18/07, Dennis Sosnoski <dm...@sosnoski.com> wrote:
> >> I've started experimenting with the current pre-1.2 code, and ran into a
> >> problem with the classloading. JiBX generates static initializers as
> >> part of the message receiver code, in order to configure some of the
> >> binding information used by JiBX when the service methods are called. In
> >> the case I'm working on, one of the classes being loaded by the static
> >> code is in a jar file, located in the /lib directory of the aar. This
> >> worked fine in 1.1 and 1.1.1, but now I get:
> >>
> >> java.lang.NoClassDefFoundError:
> >> com/sosnoski/ws/library/jibx/AddDuplicateFault
> >>     at
> >> org.apache.axis2.jibx.library.JibxLibraryMessageReceiverInOut.<clinit>(JibxLibraryMessageReceiverInOut.java:99)
> >>
> >>     ...
> >>
> >> So it looks like the /lib/*.jar files are no longer being added to the
> >> classpath used when loading the message receiver. Is this a deliberate
> >> change, and if so can someone explain the logic? Or is there some
> >> special classloader I should be using?
> >>
> >> Thanks,
> >>
> >>   - Dennis
> >>
> >> --
> >> Dennis M. Sosnoski
> >> SOA and Web Services in Java
> >> Training and Consulting
> >> http://www.sosnoski.com - http://www.sosnoski.co.nz
> >> Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> >> For additional commands, e-mail: axis-dev-help@ws.apache.org
> >>
> >>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>


-- 
Davanum Srinivas :: http://wso2.org/ :: Oxygen for Web Services Developers

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] Classloading broken for static code in message receiver

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Yes, the jar is in the /lib directory of the aar. And the problem is 
occurring in a static block in the generated message receiver.

 From a look through the code, 
org.apache.axis2.deployment.DescriptionBuilder.processMessageReceivers 
is using the thread's context class loader to load the message receiver. 
I see where the aar class loader is set on the service under 
construction in 
org.apache.axis2.deployment.repository.util.ArchiveReader, but do not 
see it being set as the context class loader. Is that the problem?

  - Dennis

Davanum Srinivas wrote:
> Are these jars inside aar's? We were extracting those jars from the
> aar, dumping them in temp and adding them to classpath. This was
> filling up disk space and turned out to be a bad idea. So i added
> support for jar:// syntax (code from Geronimo) in URLClassLoader using
> a custom URLStreamHandler. I think you could try to generate some
> static blocks in the generated message receiver to do what you need.
>
> thanks,
> -- dims
>
> On 3/18/07, Dennis Sosnoski <dm...@sosnoski.com> wrote:
>> I've started experimenting with the current pre-1.2 code, and ran into a
>> problem with the classloading. JiBX generates static initializers as
>> part of the message receiver code, in order to configure some of the
>> binding information used by JiBX when the service methods are called. In
>> the case I'm working on, one of the classes being loaded by the static
>> code is in a jar file, located in the /lib directory of the aar. This
>> worked fine in 1.1 and 1.1.1, but now I get:
>>
>> java.lang.NoClassDefFoundError:
>> com/sosnoski/ws/library/jibx/AddDuplicateFault
>>     at
>> org.apache.axis2.jibx.library.JibxLibraryMessageReceiverInOut.<clinit>(JibxLibraryMessageReceiverInOut.java:99) 
>>
>>     ...
>>
>> So it looks like the /lib/*.jar files are no longer being added to the
>> classpath used when loading the message receiver. Is this a deliberate
>> change, and if so can someone explain the logic? Or is there some
>> special classloader I should be using?
>>
>> Thanks,
>>
>>   - Dennis
>>
>> -- 
>> Dennis M. Sosnoski
>> SOA and Web Services in Java
>> Training and Consulting
>> http://www.sosnoski.com - http://www.sosnoski.co.nz
>> Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-dev-help@ws.apache.org
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [Axis2] Classloading broken for static code in message receiver

Posted by Davanum Srinivas <da...@gmail.com>.
Are these jars inside aar's? We were extracting those jars from the
aar, dumping them in temp and adding them to classpath. This was
filling up disk space and turned out to be a bad idea. So i added
support for jar:// syntax (code from Geronimo) in URLClassLoader using
a custom URLStreamHandler. I think you could try to generate some
static blocks in the generated message receiver to do what you need.

thanks,
-- dims

On 3/18/07, Dennis Sosnoski <dm...@sosnoski.com> wrote:
> I've started experimenting with the current pre-1.2 code, and ran into a
> problem with the classloading. JiBX generates static initializers as
> part of the message receiver code, in order to configure some of the
> binding information used by JiBX when the service methods are called. In
> the case I'm working on, one of the classes being loaded by the static
> code is in a jar file, located in the /lib directory of the aar. This
> worked fine in 1.1 and 1.1.1, but now I get:
>
> java.lang.NoClassDefFoundError:
> com/sosnoski/ws/library/jibx/AddDuplicateFault
>     at
> org.apache.axis2.jibx.library.JibxLibraryMessageReceiverInOut.<clinit>(JibxLibraryMessageReceiverInOut.java:99)
>     ...
>
> So it looks like the /lib/*.jar files are no longer being added to the
> classpath used when loading the message receiver. Is this a deliberate
> change, and if so can someone explain the logic? Or is there some
> special classloader I should be using?
>
> Thanks,
>
>   - Dennis
>
> --
> Dennis M. Sosnoski
> SOA and Web Services in Java
> Training and Consulting
> http://www.sosnoski.com - http://www.sosnoski.co.nz
> Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
>
>


-- 
Davanum Srinivas :: http://wso2.org/ :: Oxygen for Web Services Developers

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org