File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Class Loading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Class Loading" Watch "Class Loading" New topic
Author

Class Loading

Neil Richards
Greenhorn

Joined: Jan 22, 2002
Posts: 9
I am running Tomcat 4.1.27 and am using Quartz to schedule a job at regular intervals. The task of the job is to get from the database any outstanding quotation requests, send an email to the respective parties, and then update the database to indicate that the request is no longer outstanding. I noticed that multiple emails were being sent to the same supplier for the same request, and having added some debug code, it appears that the job is running multiple times each time it is scheduled to run. I also noticed that when I added further debug information, the old version of the class ran AND so did the new version. I am assuming it is a class loading issue as the job implements StatefulJob (which is supposed to prevent concurrent running) and the delegate which the job calls is a Singleton (which is also running concurrently).

I can't understand why my job is loaded by more than one class loader - and (as you'd expect) I'd really like to avoid it. Can anybody tell me what I can do to resolve this problem?

Thanks!
Neil Richards
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Can you tell us a little about how you deployed your app?
Where the files are? the Quartz jars.
Any configuration changes to server.xml etc...


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Neil Richards
Greenhorn

Joined: Jan 22, 2002
Posts: 9
Ben,

Sorry - yes. Quartz jar is in /webapps/app/WEB-INF/lib.

Server.xml changes are as follows:

Commented out<i>
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
</i>
and using<i>
<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8009" minProcessors="5" maxProcessors="75"
acceptCount="10" debug="0"/>
</i>
instead of <i>
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8009" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="0"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
</i>
My context is<i>
<Context path="/zodiac" docBase="zodiac"
debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="prodn_log." suffix=".txt" timestamp="true"/>
<Resource name="jdbc/danaos"
auth="Container" type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/danaos">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>

<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>

<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>

<parameter>
<name>username</name>
<value>dan00</value>
</parameter>

<parameter>
<name>password</name>
<value>xxxxx</value>
</parameter>

<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>

<parameter>
<name>url</name>
<value>jdbc racle:thin:@10.1.0.3:1521 rcl</value>
</parameter>
</ResourceParams>
</Context></i>

No other unusual configuration that I can think of.

Thanks,
Neil
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Where you've explicitly defined your app's context in server.xml and placed it in the root directory of the host (tomcat/webapps I assume), I wonder if Tomcat deployed it twice.

Did you shut off autoDeploy (in the Host node of server.xml)?

Try using the manager app to list all deployed apps and see if it got deployed twice. If you don't have the manager app installed, you could add a context listener that logs something when the app starts up.
Neil Richards
Greenhorn

Joined: Jan 22, 2002
Posts: 9
The manager app only lists the application once. autoDeploy is set to true. The other piece of information worthy of note is that I have a handful of Quartz jobs scheduled, but this is the only one that seems to run multiple times.

The job config for this particular job is as follows:



Thanks again,
Neil
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class Loading