You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@openwebbeans.apache.org by Harald Wellmann <hw...@googlemail.com> on 2012/06/25 15:37:25 UTC

Classloaders

When creating multiple CDI containers from a single OpenWebBeans
library working with multiple classloaders in parallel, how do you
tell OpenWebBeans which classloader to use?

Is there any alternative to setting the Thread Context Class Loader?

Best regards,
Harald

Re: Classloaders

Posted by Mark Struberg <st...@yahoo.de>.
Let's start at the beginning: what do you like to achive? What is your goal? Usually a _user_ doesn't need to mess around with all that as it works perfectly fine out of the box for Java SE, WAR, isolated EAR and non-isolated EAR scenarios.


LieGrue,
strub



----- Original Message -----
> From: Harald Wellmann <hw...@googlemail.com>
> To: user@openwebbeans.apache.org; Mark Struberg <st...@yahoo.de>
> Cc: 
> Sent: Monday, June 25, 2012 4:47 PM
> Subject: Re: Classloaders
> 
> Hi Mark,
> 
> hmm yes, I had thought the SingletonService might help, but I'm not
> sure what it does and how to use it. What is this Object parameter in
> get(Object) and getSingletonClassloader(Object)? Besides, for
> overriding any SPI, the only way I've seen so far is setting a class
> name in openwebbeans.properties. But this amounts to OWB calling
> Class.newInstance() with a default constructor and then I can't pass
> any parameters to the given service implementation.
> 
> What I'd really like to be able to do is something like
> WebBeansContext.createNewContext(myClassLoader), to avoid messing
> around with the TCCL...
> 
> Best regards,
> Harald
> 
> 2012/6/25 Mark Struberg <st...@yahoo.de>:
>>  Hi Harald!
>> 
>>  By default OWB takes the TCCL (ThreadContextClassLoader) into account. An 
> EE server (e.g. WAS or Geronimo) could swap the SingletonService before starting 
> up the container. But by default each WebApp will start it's own BeanManager 
> instance and it's own Extensions.
>> 
>>  In our production app we e.g. have all the owb, myfaces, openjpa, bval, etc 
> jars in a shared ClassLoader. See the shared.loader setting in 
> ${catalina.home}/conf/catalina.properties
>> 
>>  Works superb!
>> 
>>  LieGrue,
>>  strub
>> 
>> 
>> 
>> 
>>  ----- Original Message -----
>>>  From: Harald Wellmann <hw...@googlemail.com>
>>>  To: user@openwebbeans.apache.org
>>>  Cc:
>>>  Sent: Monday, June 25, 2012 3:37 PM
>>>  Subject: Classloaders
>>> 
>>>  When creating multiple CDI containers from a single OpenWebBeans
>>>  library working with multiple classloaders in parallel, how do you
>>>  tell OpenWebBeans which classloader to use?
>>> 
>>>  Is there any alternative to setting the Thread Context Class Loader?
>>> 
>>>  Best regards,
>>>  Harald
>>> 
> 

Re: Classloaders

Posted by Harald Wellmann <hw...@googlemail.com>.
Hi Mark,

hmm yes, I had thought the SingletonService might help, but I'm not
sure what it does and how to use it. What is this Object parameter in
get(Object) and getSingletonClassloader(Object)? Besides, for
overriding any SPI, the only way I've seen so far is setting a class
name in openwebbeans.properties. But this amounts to OWB calling
Class.newInstance() with a default constructor and then I can't pass
any parameters to the given service implementation.

What I'd really like to be able to do is something like
WebBeansContext.createNewContext(myClassLoader), to avoid messing
around with the TCCL...

Best regards,
Harald

2012/6/25 Mark Struberg <st...@yahoo.de>:
> Hi Harald!
>
> By default OWB takes the TCCL (ThreadContextClassLoader) into account. An EE server (e.g. WAS or Geronimo) could swap the SingletonService before starting up the container. But by default each WebApp will start it's own BeanManager instance and it's own Extensions.
>
> In our production app we e.g. have all the owb, myfaces, openjpa, bval, etc jars in a shared ClassLoader. See the shared.loader setting in ${catalina.home}/conf/catalina.properties
>
> Works superb!
>
> LieGrue,
> strub
>
>
>
>
> ----- Original Message -----
>> From: Harald Wellmann <hw...@googlemail.com>
>> To: user@openwebbeans.apache.org
>> Cc:
>> Sent: Monday, June 25, 2012 3:37 PM
>> Subject: Classloaders
>>
>> When creating multiple CDI containers from a single OpenWebBeans
>> library working with multiple classloaders in parallel, how do you
>> tell OpenWebBeans which classloader to use?
>>
>> Is there any alternative to setting the Thread Context Class Loader?
>>
>> Best regards,
>> Harald
>>

Re: Classloaders

Posted by Mark Struberg <st...@yahoo.de>.
Hi Harald!

By default OWB takes the TCCL (ThreadContextClassLoader) into account. An EE server (e.g. WAS or Geronimo) could swap the SingletonService before starting up the container. But by default each WebApp will start it's own BeanManager instance and it's own Extensions.

In our production app we e.g. have all the owb, myfaces, openjpa, bval, etc jars in a shared ClassLoader. See the shared.loader setting in ${catalina.home}/conf/catalina.properties

Works superb!

LieGrue,
strub




----- Original Message -----
> From: Harald Wellmann <hw...@googlemail.com>
> To: user@openwebbeans.apache.org
> Cc: 
> Sent: Monday, June 25, 2012 3:37 PM
> Subject: Classloaders
> 
> When creating multiple CDI containers from a single OpenWebBeans
> library working with multiple classloaders in parallel, how do you
> tell OpenWebBeans which classloader to use?
> 
> Is there any alternative to setting the Thread Context Class Loader?
> 
> Best regards,
> Harald
>