You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Laurent Even <la...@sab2i.com> on 2009/05/14 18:36:39 UTC
[AXIS2] Accessing classes inside aar from a jar located in the lib
directory
Hi all,
I have some classes in a jar which is located in the WEB-INF/lib
directory of my application.
I deployed several services in this application.
So far so good but.... (always a but ;) )
I'm doing a classforname from my jar fil (WEB-INF/lib) that try to
instantiate a class inside a service (aar)
I'm getting a classnotfound exception.
I found several post on the internet talking of classnotfound exception
but only for service deployment
I also used the parameter ServiceTCCL for my service ( <parameter
name="ServiceTCCL" locked="false">composite</parameter>) without success.
If you have any clue on how to solve this problem, please, let me know
Bye
Laurent
-----------------------------------------------------------
Un geste responsable aujourd hui pour preserver demain.
N imprimez ce message que si necessaire.
Please, consider the environment before printing this email.
------------------------------------------------------------
Re: [AXIS2] Accessing classes inside aar from a jar located in the
lib directory
Posted by Laurent Even <la...@sab2i.com>.
Great!
it works!
Thanks Andreas!!
Andreas Veithen a écrit :
> In that case you should change the code in WEB-INF/lib to use
> Thread.getContextClassLoader(). If the ServiceTCCL parameter is set
> correctly, then that method should return the appropriate class
> loader.
>
> Andreas
>
> 2009/5/15 Laurent Even <la...@sab2i.com>:
>
>> Andreas,
>>
>> thanks for your response.
>> Basically, my class in the WEB-INF/lib contains core functions which are
>> used by all services.
>> Each service contains specific code.
>> for each service call, I have
>> service -> core (web-inf/lib) -> service
>> Is there a simple way to get the classloader dynamically for a class in
>> WEB-INF/lib directory?
>>
>> Laurent
>>
>> Andreas Veithen a écrit :
>>
>> Laurent,
>>
>> By design, there is a distinct class loader for each AAR. This is
>> important to isolate services from each other. The classes in the JARs
>> in WEB-INF/lib are loaded by the Web app class loader, which is the
>> parent of the AAR class loaders. It is therefore normal that a class
>> in WEB-INF/lib (or WEB-INF/classes) can't load a class from an AAR
>> file. There are ways around this, but first you should make sure that
>> you are not running into this issue because of a flaw in your design.
>> What is actually the use case for this?
>>
>> Andreas
>>
>> 2009/5/14 Laurent Even <la...@sab2i.com>:
>>
>>
>> Hi all,
>>
>> I have some classes in a jar which is located in the WEB-INF/lib directory
>> of my application.
>> I deployed several services in this application.
>> So far so good but.... (always a but ;) )
>> I'm doing a classforname from my jar fil (WEB-INF/lib) that try to
>> instantiate a class inside a service (aar)
>> I'm getting a classnotfound exception.
>> I found several post on the internet talking of classnotfound exception but
>> only for service deployment
>> I also used the parameter ServiceTCCL for my service ( <parameter
>> name="ServiceTCCL" locked="false">composite</parameter>) without success.
>>
>> If you have any clue on how to solve this problem, please, let me know
>>
>> Bye
>> Laurent
>>
>> -----------------------------------------------------------
>>
>> Un geste responsable aujourd hui pour preserver demain.
>> N imprimez ce message que si necessaire.
>>
>>
>>
>> Please, consider the environment before printing this email.
>>
>> ------------------------------------------------------------
>>
>>
>>
>>
>>
>> -----------------------------------------------------------
>> Un geste responsable aujourd hui pour preserver demain.
>> N'imprimez ce message que si necessaire.
>>
>> Please, consider the environment before printing this email.
>> ------------------------------------------------------------
>>
>>
>
>
>
>
-----------------------------------------------------------
Un geste responsable aujourd hui pour preserver demain.
N imprimez ce message que si necessaire.
Please, consider the environment before printing this email.
------------------------------------------------------------
Re: [AXIS2] Accessing classes inside aar from a jar located in the
lib directory
Posted by Andreas Veithen <an...@gmail.com>.
In that case you should change the code in WEB-INF/lib to use
Thread.getContextClassLoader(). If the ServiceTCCL parameter is set
correctly, then that method should return the appropriate class
loader.
Andreas
2009/5/15 Laurent Even <la...@sab2i.com>:
> Andreas,
>
> thanks for your response.
> Basically, my class in the WEB-INF/lib contains core functions which are
> used by all services.
> Each service contains specific code.
> for each service call, I have
> service -> core (web-inf/lib) -> service
> Is there a simple way to get the classloader dynamically for a class in
> WEB-INF/lib directory?
>
> Laurent
>
> Andreas Veithen a écrit :
>
> Laurent,
>
> By design, there is a distinct class loader for each AAR. This is
> important to isolate services from each other. The classes in the JARs
> in WEB-INF/lib are loaded by the Web app class loader, which is the
> parent of the AAR class loaders. It is therefore normal that a class
> in WEB-INF/lib (or WEB-INF/classes) can't load a class from an AAR
> file. There are ways around this, but first you should make sure that
> you are not running into this issue because of a flaw in your design.
> What is actually the use case for this?
>
> Andreas
>
> 2009/5/14 Laurent Even <la...@sab2i.com>:
>
>
> Hi all,
>
> I have some classes in a jar which is located in the WEB-INF/lib directory
> of my application.
> I deployed several services in this application.
> So far so good but.... (always a but ;) )
> I'm doing a classforname from my jar fil (WEB-INF/lib) that try to
> instantiate a class inside a service (aar)
> I'm getting a classnotfound exception.
> I found several post on the internet talking of classnotfound exception but
> only for service deployment
> I also used the parameter ServiceTCCL for my service ( <parameter
> name="ServiceTCCL" locked="false">composite</parameter>) without success.
>
> If you have any clue on how to solve this problem, please, let me know
>
> Bye
> Laurent
>
> -----------------------------------------------------------
>
> Un geste responsable aujourd hui pour preserver demain.
> N imprimez ce message que si necessaire.
>
>
>
> Please, consider the environment before printing this email.
>
> ------------------------------------------------------------
>
>
>
>
>
> -----------------------------------------------------------
> Un geste responsable aujourd hui pour preserver demain.
> N'imprimez ce message que si necessaire.
>
> Please, consider the environment before printing this email.
> ------------------------------------------------------------
>
Re: [AXIS2] Accessing classes inside aar from a jar located in the
lib directory
Posted by Laurent Even <la...@sab2i.com>.
Andreas,
thanks for your response.
Basically, my class in the WEB-INF/lib contains core functions which are
used by all services.
Each service contains specific code.
for each service call, I have
service -> core (web-inf/lib) -> service
Is there a simple way to get the classloader dynamically for a class in
WEB-INF/lib directory?
Laurent
Andreas Veithen a écrit :
> Laurent,
>
> By design, there is a distinct class loader for each AAR. This is
> important to isolate services from each other. The classes in the JARs
> in WEB-INF/lib are loaded by the Web app class loader, which is the
> parent of the AAR class loaders. It is therefore normal that a class
> in WEB-INF/lib (or WEB-INF/classes) can't load a class from an AAR
> file. There are ways around this, but first you should make sure that
> you are not running into this issue because of a flaw in your design.
> What is actually the use case for this?
>
> Andreas
>
> 2009/5/14 Laurent Even <la...@sab2i.com>:
>
>> Hi all,
>>
>> I have some classes in a jar which is located in the WEB-INF/lib directory
>> of my application.
>> I deployed several services in this application.
>> So far so good but.... (always a but ;) )
>> I'm doing a classforname from my jar fil (WEB-INF/lib) that try to
>> instantiate a class inside a service (aar)
>> I'm getting a classnotfound exception.
>> I found several post on the internet talking of classnotfound exception but
>> only for service deployment
>> I also used the parameter ServiceTCCL for my service ( <parameter
>> name="ServiceTCCL" locked="false">composite</parameter>) without success.
>>
>> If you have any clue on how to solve this problem, please, let me know
>>
>> Bye
>> Laurent
>>
>> -----------------------------------------------------------
>>
>> Un geste responsable aujourd hui pour preserver demain.
>> N imprimez ce message que si necessaire.
>>
>>
>>
>> Please, consider the environment before printing this email.
>>
>> ------------------------------------------------------------
>>
>>
>
>
>
>
-----------------------------------------------------------
Un geste responsable aujourd hui pour preserver demain.
N imprimez ce message que si necessaire.
Please, consider the environment before printing this email.
------------------------------------------------------------
Re: [AXIS2] Accessing classes inside aar from a jar located in the
lib directory
Posted by Andreas Veithen <an...@gmail.com>.
Laurent,
By design, there is a distinct class loader for each AAR. This is
important to isolate services from each other. The classes in the JARs
in WEB-INF/lib are loaded by the Web app class loader, which is the
parent of the AAR class loaders. It is therefore normal that a class
in WEB-INF/lib (or WEB-INF/classes) can't load a class from an AAR
file. There are ways around this, but first you should make sure that
you are not running into this issue because of a flaw in your design.
What is actually the use case for this?
Andreas
2009/5/14 Laurent Even <la...@sab2i.com>:
> Hi all,
>
> I have some classes in a jar which is located in the WEB-INF/lib directory
> of my application.
> I deployed several services in this application.
> So far so good but.... (always a but ;) )
> I'm doing a classforname from my jar fil (WEB-INF/lib) that try to
> instantiate a class inside a service (aar)
> I'm getting a classnotfound exception.
> I found several post on the internet talking of classnotfound exception but
> only for service deployment
> I also used the parameter ServiceTCCL for my service ( <parameter
> name="ServiceTCCL" locked="false">composite</parameter>) without success.
>
> If you have any clue on how to solve this problem, please, let me know
>
> Bye
> Laurent
>
> -----------------------------------------------------------
>
> Un geste responsable aujourd hui pour preserver demain.
> N imprimez ce message que si necessaire.
>
>
>
> Please, consider the environment before printing this email.
>
> ------------------------------------------------------------
>