You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bob DeRemer <bo...@thingworx.com> on 2011/06/30 18:08:15 UTC

UPDATE - RE: how to use VirtualWebappLoader - either in META-INF/context.xml or programmatically on startup

I was able to get this to work.  I had a hunch, so I moved the extensions folder outside the WEB-INF directory.    Any idea why these extra repositories cannot be under the WEB-INF/lib folder ?

Also, ONE OTHER QUESTION: 

Is there a way to have new JAR(s) that get dropped into the extensions folder picked up automatically [without] restarting the webapp or tomcat?  We'd like to have the classloader actually fallback to reading from this extensions location if I can't load it normally.
* would this require a custom classloader that derived from VirtualWebappLoader - so it would pickup existing extensions at startup, but could also check/load the JAR(s) dynamically if it can't load them?
** if it does require a custom classloader, can someone point me to an example of how to do this?

Thanks again,
Bob

-----Original Message-----
From: Bob DeRemer [mailto:bob.deremer@thingworx.com] 
Sent: Thursday, June 30, 2011 11:53 AM
To: Tomcat Users List
Subject: RE: how to use VirtualWebappLoader - either in META-INF/context.xml or programmatically on startup

Thanks Konstantin, but that didn't do it.  I can see that Tomcat copies the context.xml over to <tomcat>/conf/Catalina/localhost and names it <mywebapp>.xml.  Is there any way to printout the classpath my webapp is using in the context of tomcat - to try and debug this?

The exact contents is:

<Context path="/Bob">
	<Loader className="org.apache.catalina.loader.VirtualWebappLoader"
		  virtualClasspath="${catalina.base}/webapps/Bob/WEB-INF/lib/extensions/*.jar" /> </Context>

Do I need to do anything programmatically to enable this?

-bob

-----Original Message-----
From: Konstantin Kolinko [mailto:knst.kolinko@gmail.com]
Sent: Thursday, June 30, 2011 11:27 AM
To: Tomcat Users List
Subject: Re: how to use VirtualWebappLoader - either in META-INF/context.xml or programmatically on startup

2011/6/30 Bob DeRemer <bo...@thingworx.com>:
>           virtualClasspath="/WEB-INF/lib/extensions/*.jar"/>

The above should be an absolute path.

You can use system variables, e.g.
${catalina.base}/webapps/mywebapp/WEB-INF/lib/extensions/*.jar

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: UPDATE - RE: how to use VirtualWebappLoader - either in META-INF/context.xml or programmatically on startup

Posted by Bob DeRemer <bo...@thingworx.com>.
Thank you!

Since it looks like I need to create my own classloader [to get it to check my extensions folder "on the fly"], can you point me to some links or samples that show how to do this?  I can't believe more people haven't had to dynamically load JAR(s) to resolve classes "on the fly" for extensible applications that need to remain running.

-bob

-----Original Message-----
From: Konstantin Kolinko [mailto:knst.kolinko@gmail.com] 
Sent: Thursday, June 30, 2011 12:25 PM
To: Tomcat Users List
Subject: Re: UPDATE - RE: how to use VirtualWebappLoader - either in META-INF/context.xml or programmatically on startup

2011/6/30 Bob DeRemer <bo...@thingworx.com>:
> I was able to get this to work.  I had a hunch, so I moved the extensions folder outside the WEB-INF directory.    Any idea why these extra repositories cannot be under the WEB-INF/lib folder ?

I think classes should be loadable, but IIRC annotation and resources scanning won't work for the. There was a bug about that and it was closed as WONTFIX.
The short version is that it is hard to differ between app's own WEB-INF and your directory, and WEB-INF is explicitly skipped to avoid scanning it twice.

>
> Also, ONE OTHER QUESTION:
>
> Is there a way to have new JAR(s) that get dropped into the extensions folder picked up automatically [without] restarting the webapp or tomcat?

No, it is not possible. You need to restart the webapp.

>  We'd like to have the classloader actually fallback to reading from this extensions location if I can't load it normally.
> * would this require a custom classloader that derived from VirtualWebappLoader - so it would pickup existing extensions at startup, but could also check/load the JAR(s) dynamically if it can't load them?
> ** if it does require a custom classloader, can someone point me to an example of how to do this?

YMMV.  You may start reading with the ones implemented by Tomcat.
There is classloader for JSPs that supports reloading (if JspServlet is being run in "development"=true mode).

VirtualWebappLoader is not a classloader. It is just a component that configures one.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: UPDATE - RE: how to use VirtualWebappLoader - either in META-INF/context.xml or programmatically on startup

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/6/30 Bob DeRemer <bo...@thingworx.com>:
> I was able to get this to work.  I had a hunch, so I moved the extensions folder outside the WEB-INF directory.    Any idea why these extra repositories cannot be under the WEB-INF/lib folder ?

I think classes should be loadable, but IIRC annotation and resources
scanning won't work for the. There was a bug about that and it was
closed as WONTFIX.
The short version is that it is hard to differ between app's own
WEB-INF and your directory, and WEB-INF is explicitly skipped to avoid
scanning it twice.

>
> Also, ONE OTHER QUESTION:
>
> Is there a way to have new JAR(s) that get dropped into the extensions folder picked up automatically [without] restarting the webapp or tomcat?

No, it is not possible. You need to restart the webapp.

>  We'd like to have the classloader actually fallback to reading from this extensions location if I can't load it normally.
> * would this require a custom classloader that derived from VirtualWebappLoader - so it would pickup existing extensions at startup, but could also check/load the JAR(s) dynamically if it can't load them?
> ** if it does require a custom classloader, can someone point me to an example of how to do this?

YMMV.  You may start reading with the ones implemented by Tomcat.
There is classloader for JSPs that supports reloading (if JspServlet
is being run in "development"=true mode).

VirtualWebappLoader is not a classloader. It is just a component that
configures one.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org