Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / September 2004

Tip: Looking for answers? Try searching our database.

tomcat and loading of web apps

Thread view: 
luca - 16 Sep 2004 14:53 GMT
is there a way to tell tomcat not to load (or even look at)
a certain application?

here is my problem, I am developing a java library which contains a singleton.
I have different version of the library running in different applications
for different tests. Unfortunately, when tomcat starts,
the classloader loads all of the versions with unpredictable results and
a lot of confusion.
The only surefire way to avoid that tomcat (4.1.30) loads the
application is to remove the application subdirectory
from 'webapps' completely, but this is not very practical for me.

Is there a way to configure tomcat (either in conf/server.xml
or in the WEBINF/web.xml) so that a given application is totally ignored?

thanks

Luca
Oscar kind - 16 Sep 2004 22:25 GMT
> is there a way to tell tomcat not to load (or even look at)
> a certain application?

Not that I know of.

> here is my problem, I am developing a java library which contains a singleton.
> I have different version of the library running in different applications
> for different tests. Unfortunately, when tomcat starts,
> the classloader loads all of the versions with unpredictable results and
> a lot of confusion.

Is the singleton located in a shared context, or in the WEB-INF/lib
directory of each application? In the latter case, they are completely
separated through Tomcat's different classloaders (unless you added
another common dependency such as a file/socket/...).

Signature

Oscar Kind                                    http://home.hccnet.nl/okind/
Software Developer                    for contact information, see website

PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2

luca - 17 Sep 2004 10:42 GMT
Hallo

> Is the singleton located in a shared context, or in the WEB-INF/lib
> directory of each application? In the latter case, they are completely
> separated through Tomcat's different classloaders (unless you added
> another common dependency such as a file/socket/...).

yeah, this is the case. There is a big file which initializes
some sort of in-memory database. Initialization is heavy. I want it to happen
only once, this is the reason for the singleton.

Luca
John Fereira - 16 Sep 2004 23:51 GMT
> is there a way to tell tomcat not to load (or even look at)
> a certain application?
[quoted text clipped - 11 lines]
> or in the WEBINF/web.xml) so that a given application is totally
> ignored?

If the web app is already in the webapps directory Tomcat will load it.  
That's what Tomcat is supposed to.  I suppose that you could replace the
web.xml file with a broken version that will generate errors when trying to
load all the servlets.  You might try playing with the load-on-startup
values for each servlet (make the value a negative number or something) to
keep the servlets from loading.

Have you tried using the Manager client and stopping the context?

On my test system I often have more web apps that I might want to deploy at
a given time so I keep all the source code and related files in a separate
directoy and deploy it to Tomcat when I want to test it using the Jakarta
Ant build tool (which I highly recommend).  I have tomcat-undeploy tasks in
the Ant build.xml file so I can undeploy/deploy whenever I want.  You could
even build your webapp as a war file and copy it to the webapps directoy
when you want to deploy it and remove it, and use the Manager client to
undeploy when you don't need it.
luca - 17 Sep 2004 10:46 GMT
> If the web app is already in the webapps directory Tomcat will load it.  
> That's what Tomcat is supposed to.  I suppose that you could replace the
> web.xml file with a broken version that will generate errors when trying to
> load all the servlets.  You might try playing with the load-on-startup
> values for each servlet (make the value a negative number or something) to
> keep the servlets from loading.

actually, this is sort of like the quick and dirty solution that I have been
suing so far: I renamed one servlet that does initialization at startup
and this apparently did the job. Not very elegant, though :)

> Have you tried using the Manager client and stopping the context?
>
[quoted text clipped - 6 lines]
> when you want to deploy it and remove it, and use the Manager client to
> undeploy when you don't need it.

this makes sense. Not as quick as I hoped, but it definitely makes sense.
Is also there an Ant task to restart tomcat?

thanks

Luca
Juha Laiho - 17 Sep 2004 19:02 GMT
luca <luca_remove@tin.it> said:
>is there a way to tell tomcat not to load (or even look at)
>a certain application?
[quoted text clipped - 7 lines]
>application is to remove the application subdirectory
>from 'webapps' completely, but this is not very practical for me.

Check the Tomcat configuration documentation; you can disable the automatic
deployment/refresh of webapps. Of course, doing this means that you
separately load ( =configure) each of those webapps you want to get loaded.

One wonders, though, what is the reason to keep deployed webapps you don't
want to use?
Signature

Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
        PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.