Using TCCL is really a pretty dreadful non-modular hack.  I'd prefer to avoid 
supplying temptation to use it to all gbeans and only supply it where it's 
really essential.

If you decide to put it in anyway, I think there's another commented out line 
1117 to consider.

thanks
david jencks

On Apr 15, 2010, at 10:09 PM, Ivan wrote:

> I am fine with adding it in the gbeaninstance class, it might slove most of 
> the problems.  
> Usually, I add the set action in the first line of the try block, so that it 
> should make sure that finally block would always be executed. ^_^
> 
> 2010/4/16 Jarek Gawor <[email protected]>
> Ivan,
> 
> Heh. I think we might have been looking at the same problem at the
> same time. I was actually thinking of a more general solution by
> restoring the setContextClassLoader() call in GBeanInstance.java at
> line 912. What do you think?
> 
> Jarek
> 
> On Thu, Apr 15, 2010 at 11:54 PM,  <[email protected]> wrote:
> > Author: xuhaihong
> > Date: Fri Apr 16 03:54:39 2010
> > New Revision: 934679
> >
> > URL: http://svn.apache.org/viewvc?rev=934679&view=rev
> > Log:
> > Set thread context classloader, as Tomcat needs it to load Connector MBean 
> > while adding connector
> >
> > Modified:
> >    
> > geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
> >
> > Modified: 
> > geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
> > URL: 
> > http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=934679&r1=934678&r2=934679&view=diff
> > ==============================================================================
> > --- 
> > geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
> >  (original)
> > +++ 
> > geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
> >  Fri Apr 16 03:54:39 2010
> > @@ -92,6 +92,7 @@ public class TomcatContainer implements
> >     private final WebManager manager;
> >     private static boolean first = true;
> >     private final BundleContext bundleContext;
> > +    private final ClassLoader classLoader;
> >
> >     /**
> >      * GBean constructor (invoked dynamically when the gbean is declared in 
> > a plan)
> > @@ -116,7 +117,7 @@ public class TomcatContainer implements
> >         if (engineGBean == null && server == null) throw new 
> > IllegalArgumentException("Server and EngineGBean cannot both be null.");
> >
> >         this.bundleContext = bundleContext;
> > -
> > +        this.classLoader = classLoader;
> >         // Register a stream handler factory for the JNDI protocol
> >         URLStreamHandlerFactory streamHandlerFactory =
> >             new DirContextURLStreamHandlerFactory();
> > @@ -339,7 +340,13 @@ public class TomcatContainer implements
> >     }
> >
> >     public void addConnector(Connector connector) {
> > -        embedded.addConnector(connector);
> > +        ClassLoader oldClassLoader = 
> > Thread.currentThread().getContextClassLoader();
> > +        try {
> > +            Thread.currentThread().setContextClassLoader(classLoader);
> > +            embedded.addConnector(connector);
> > +        } finally {
> > +            Thread.currentThread().setContextClassLoader(oldClassLoader);
> > +        }
> >     }
> >
> >     public void removeConnector(Connector connector) {
> >
> >
> >
> 
> 
> 
> -- 
> Ivan

Reply via email to