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 / General / February 2006

Tip: Looking for answers? Try searching our database.

[Tomcat] How to pass application specific parameters to the JVM?

Thread view: 
Sven Jacobs - 20 Feb 2006 07:29 GMT
Dear newsgroup,

I'm using the JPOX implementation (www.jpox.org) of the JDO standard in a
Java web application. I now want to enable the logging functionality. As
described in the docs at http://www.jpox.org/docs/1_1/logging.html I have
to pass an argument to the JVM
(-Dlog4j.configuration=file:log4j.properties).

My question is now: How do I pass this web application specific argument to
the JVM? I'm using the NetBeans 5.0 IDE with the integrated Tomcat 5.5
server.

Signature

Sincerely
Sven Jacobs

Finomosec - 20 Feb 2006 07:40 GMT
Sven Jacobs schrieb:
> Dear newsgroup,
>
[quoted text clipped - 7 lines]
> the JVM? I'm using the NetBeans 5.0 IDE with the integrated Tomcat 5.5
> server.

I only know how it works on a standard Tomcat installation.
We modify the catalina.sh and (as far as i remember) set the
CATALINA_OPTS-Variable to (in your case)
"-Dlog4j.configuration=file:log4j.properties".

Maybe you can configure the start-parameters from within your NetBeans
5.0 IDE.

Greetings Finomosec;
Sven Jacobs - 20 Feb 2006 07:51 GMT
> I only know how it works on a standard Tomcat installation.
> We modify the catalina.sh and (as far as i remember) set the
[quoted text clipped - 3 lines]
> Maybe you can configure the start-parameters from within your NetBeans
> 5.0 IDE.

I didn't find such a setting in the NetBeans IDE... Can JVM arguments be
set in the web.xml or context.xml configuration files? This would be really
nice because I don't have to adjust another Tomcat server if I deploy the
application elsewhere.

How does the Tomcat server work internally? Will it startup a new JVM for
each web application it's running or will it use the same JVM which runs
the Tomcat server? If it's the first option then there must be a way to
tell Tomcat what arguments to pass to the JVM, right?

Signature

Sincerely
Sven Jacobs

Robert Klemme - 20 Feb 2006 09:29 GMT
>> I only know how it works on a standard Tomcat installation.
>> We modify the catalina.sh and (as far as i remember) set the
[quoted text clipped - 9 lines]
> be really nice because I don't have to adjust another Tomcat server
> if I deploy the application elsewhere.

They can't.  At the moment when these files are read the JVM is already up
and running.

> How does the Tomcat server work internally? Will it startup a new JVM
> for each web application it's running or will it use the same JVM
> which runs the Tomcat server? If it's the first option then there
> must be a way to tell Tomcat what arguments to pass to the JVM, right?

There is just a single JVM.

But properties can also be set at runtime:

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#setProperties(java
.util.Properties
)

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#setProperty(java.l
ang.String,%20java.lang.String
)

You could write initialization code that does this and execute it via a
listener that listens on application startup and shutdown events:

http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletContextLis
tener.html


Regards

   robert


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



©2009 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.