Leandro,

It's not clear to me what the actual classloader hierarchy that gets set up by 
classworlds for the Phoenix realm.  Does it process the load directives in order and 
chain the classloaders together or does it create a single classloader with all of the 
classes and jars references by the load directives in it?

IIRC the problem with using getClass().getClassLoader() is that it returns the 
'application' classloader rather than the classloader which was used to load the 
class. So in order to get your singleton to work (without modifying James), you need 
to ensure that your singleton class is loadable via the 'application' classloader for 
the Phoenix realm as well as any classes used by your singleton.

Otherwise you could probably change James MailetLoader to use the 
Thread.currentThread().getContextClassLoader().

Steve

> -----Original Message-----
> From: Leandro Rodrigo Saad Cruz [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, April 15, 2004 7:56 AM
> To: James Users List
> Subject: RE: Using specific classloaders for mailets
> 
> 
> On Wed, 2004-04-14 at 18:51, Steve Short wrote:
> > Not sure - but maybe if you can provide some more 
> information we can 
> > sort something out.
> > 
> > - Which classloader do you want the MailerLoader to use?
> 
> RealClassLoader from classworlds.
> 
> > - Can you describe the classloader hierarchy you have set up with 
> > classworlds. (Including the Phoenix classloaders)
> 
> Sure.
> 
> main is br.com.ibnetwork.e2.loader.E2Loader from e2loader
> 
> [e2loader]
>         load ${app.home}/bin/classes/common/
>         load /usr/share/jars/servletapi-2.3.jar
> 
> [phoenix]
>         import br.com.ibnetwork.e2.loader.Startable from e2loader
>         load ${app.home}/bin/classes/phoenix/
>         load ${phoenix.home}/bin/phoenix-loader.jar
>         load ${xingu.home}/xingu-container-alpha-0.1.jar
>         
> [tomcat]
>         import br.com.ibnetwork.e2.loader.Startable from e2loader
>         load ${app.home}/bin/classes/tomcat/
>         load ${tomcat.home}/bin/commons-logging-api.jar
>         load ${tomcat.home}/server/lib/*.jar
>         load ${tomcat.home}/common/lib/*.jar
> 
> [jetty]
>         import br.com.ibnetwork.e2.loader.Startable from e2loader
>         load ${app.home}/bin/classes/jetty/
>         load ${jetty.home}/lib/*.jar
>         load ${jetty.home}/ext/jasper-compiler.jar
>         load ${jetty.home}/ext/jasper-runtime.jar
> 
> > - Which class is your singleton and which classloader is 
> being used to 
> > load it?
> 
> I want to put my singleton on [e2loader]. But I'm testing it 
> on [phoenix]. It's placed on xingu-container-alpha-0.1.jar
> 
> > - Why are you using classworlds?  What does it buy you in this 
> > scenario?
> 
> AFAIK, singletons are unique on each classloader, so, I must 
> use the same classloader to load it on all my apps, right ? 
> Both on jetty and phoenix/james.
> 
> 
> > 
> > Steve
> > 
> > > -----Original Message-----
> > > From: Leandro Rodrigo Saad Cruz [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, April 14, 2004 2:40 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Using specific classloaders for mailets
> > > 
> > > 
> > > Hi all.
> > > 
> > > I'd like to use a specific classloader for one mailet
> > > that should share a singleton with other app running on the same 
> > > JVM.
> > > 
> > > For this to work I'm using classworlds to start phoenix/james
> > > and jetty. Both apps mess with the classloader. Is it 
> > > possible to make a make let run using a specific classloader ?
> > > 
> > > This code was extracted from MailetLoader.java. The
> > > classloader always references this.getClass().getClassLoader();
> > > 
> > > <MailetLoader>
> > > ClassLoader theClassLoader = null;
> > > try {
> > >   MailetConfigImpl configImpl = new MailetConfigImpl();
> > >   configImpl.setMailetName(mailetName);
> > >   configImpl.setConfiguration(configuration);
> > >   configImpl.setMailetContext(context);
> > >   if (theClassLoader == null) 
> > >   {
> > >     theClassLoader = this.getClass().getClassLoader();
> > >   }
> > > ...
> > > ...
> > > </MailetLoader>
> > > 
> > > --
> > > Leandro Rodrigo Saad Cruz
> > > InterBusiness Tecnologia e Servi�os
> > > IB    - www.ibnetwork.com.br
> > > DB    - www.digitalbrand.com.br
> > > OJB   - db.apache.org/ojb
> > > XINGU - xingu.sf.net
> > > 
> > > 
> > > 
> --------------------------------------------------------------------
> > > -
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > 
> > > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> -- 
> Leandro Rodrigo Saad Cruz
> InterBusiness Tecnologia e Servi�os
> IB    - www.ibnetwork.com.br
> DB    - www.digitalbrand.com.br
> OJB   - db.apache.org/ojb
> XINGU - xingu.sf.net
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to