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

S

Sven Jacobs

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.
 
F

Finomosec

Sven said:
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.

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;
 
S

Sven Jacobs

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.

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?
 
R

Robert Klemme

Sven said:
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.

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...tProperty(java.lang.String, java.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/ServletContextListener.html

Regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top