Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 98811 invoked from network); 16 Apr 2010 05:09:56 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Apr 2010 05:09:56 -0000 Received: (qmail 67099 invoked by uid 500); 16 Apr 2010 05:09:55 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 67049 invoked by uid 500); 16 Apr 2010 05:09:55 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 67042 invoked by uid 99); 16 Apr 2010 05:09:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Apr 2010 05:09:55 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of xhhsld@gmail.com designates 209.85.221.179 as permitted sender) Received: from [209.85.221.179] (HELO mail-qy0-f179.google.com) (209.85.221.179) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Apr 2010 05:09:47 +0000 Received: by qyk9 with SMTP id 9so2508389qyk.1 for ; Thu, 15 Apr 2010 22:09:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:content-type; bh=hwFtcLxMaKbSfDSf9K4AnTGnkT8+RxuW2OTFjOAe+EQ=; b=D4TsOzhtd/J2zaBWpWkky6oezUB01/+PYF/0WjpM5mwvyvtNU7Aij38AGP+qNKq5pC bOMuV+qTIQa8ZzLzqupdOzdByihj2GDrocmbg0CEL1d/9JWn0AKRrs8lCaEPTwS9quon /p/gubDS7PmP/wEqqsdJnXcn6IDhRNbSxy9vA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=ppslwkS3vWsJunEaeCPI5OUciI985shVU2zYI69bfJmZd6zoybeOOItNkSlg0vgQNT jG1As3rvePrplDBq4ojnlfNcQMj6kLR0qTCq84xM7/fuV+7vkX6dXHt/HIddcNsrNOwy K8THYBs6UVWU+H5MakVsUKg+FT4NBeCrgqGwE= MIME-Version: 1.0 Received: by 10.229.235.143 with HTTP; Thu, 15 Apr 2010 22:09:05 -0700 (PDT) In-Reply-To: References: <20100416035439.9765E238897D@eris.apache.org> Date: Fri, 16 Apr 2010 13:09:05 +0800 Received: by 10.229.212.4 with SMTP id gq4mr1405558qcb.62.1271394546201; Thu, 15 Apr 2010 22:09:06 -0700 (PDT) Message-ID: Subject: Re: svn commit: r934679 - /geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java From: Ivan To: dev@geronimo.apache.org Content-Type: multipart/alternative; boundary=0016363100f3512a9a0484539ca6 X-Virus-Checked: Checked by ClamAV on apache.org --0016363100f3512a9a0484539ca6 Content-Type: text/plain; charset=ISO-8859-1 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 > 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, 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 --0016363100f3512a9a0484539ca6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I am fine with adding it in the gbeaninstance class, it might slove most of= the problems.=A0
Usually, I add the set action in the first line of th= e try block, so that it should make sure that finally block would always be= executed. ^_^

2010/4/16 Jarek Gawor <= jgawor@gmail.com>
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, =A0<xuhaihong@apache.org> wrote:
> Author: xuhaihong
> Date: Fri Apr 16 03:54:39 2010
> New Revision: 934679
>
> URL: http://svn.apache.org/viewvc?rev=3D934679&view=3D= rev
> Log:
> Set thread context classloader, as Tomcat needs it to load Connector M= Bean while adding connector
>
> Modified:
> =A0 =A0geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/= java/org/apache/geronimo/tomcat/TomcatContainer.java
>
> Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/ma= in/java/org/apache/geronimo/tomcat/TomcatContainer.java
> URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plu= gins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/Tomca= tContainer.java?rev=3D934679&r1=3D934678&r2=3D934679&view=3Ddif= f
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D
> --- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/jav= a/org/apache/geronimo/tomcat/TomcatContainer.java (original)
> +++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/jav= a/org/apache/geronimo/tomcat/TomcatContainer.java Fri Apr 16 03:54:39 2010<= br> > @@ -92,6 +92,7 @@ public class TomcatContainer implements
> =A0 =A0 private final WebManager manager;
> =A0 =A0 private static boolean first =3D true;
> =A0 =A0 private final BundleContext bundleContext;
> + =A0 =A0private final ClassLoader classLoader;
>
> =A0 =A0 /**
> =A0 =A0 =A0* GBean constructor (invoked dynamically when the gbean is = declared in a plan)
> @@ -116,7 +117,7 @@ public class TomcatContainer implements
> =A0 =A0 =A0 =A0 if (engineGBean =3D=3D null && server =3D=3D n= ull) throw new IllegalArgumentException("Server and EngineGBean cannot= both be null.");
>
> =A0 =A0 =A0 =A0 this.bundleContext =3D bundleContext;
> -
> + =A0 =A0 =A0 =A0this.classLoader =3D classLoader;
> =A0 =A0 =A0 =A0 // Register a stream handler factory for the JNDI prot= ocol
> =A0 =A0 =A0 =A0 URLStreamHandlerFactory streamHandlerFactory =3D
> =A0 =A0 =A0 =A0 =A0 =A0 new DirContextURLStreamHandlerFactory();
> @@ -339,7 +340,13 @@ public class TomcatContainer implements
> =A0 =A0 }
>
> =A0 =A0 public void addConnector(Connector connector) {
> - =A0 =A0 =A0 =A0embedded.addConnector(connector);
> + =A0 =A0 =A0 =A0ClassLoader oldClassLoader =3D Thread.currentThread()= .getContextClassLoader();
> + =A0 =A0 =A0 =A0try {
> + =A0 =A0 =A0 =A0 =A0 =A0Thread.currentThread().setContextClassLoader(= classLoader);
> + =A0 =A0 =A0 =A0 =A0 =A0embedded.addConnector(connector);
> + =A0 =A0 =A0 =A0} finally {
> + =A0 =A0 =A0 =A0 =A0 =A0Thread.currentThread().setContextClassLoader(= oldClassLoader);
> + =A0 =A0 =A0 =A0}
> =A0 =A0 }
>
> =A0 =A0 public void removeConnector(Connector connector) {
>
>
>



--
Ivan
--0016363100f3512a9a0484539ca6--