Archiva

Shutdown of Tomcat causes Exception when running Archiva Project

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 1.1.3
  • Fix Version/s: 1.3.1
  • Component/s: Web Interface
  • Labels:
    None
  • Environment:
    SUSE LINUX Enterprise Server 9 (i586)(Patchversion: 9.4) - Linux version 2.6.5-7.312-bigsmp (32Bit)
  • Patch Submitted:
    Yes
  • Number of attachments :
    2

Description

It looks like the Quartz thread is still running because the web-context has been unloaded before.
This could maybe happen because the Quartz threads are not yet under Spring control (http://jira.springframework.org/browse/SPR-5065).

Exception summary :

INFO: Illegal access: this web application instance has been stopped already. Could not load org.quartz.StatefulJob. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1273)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.quartz.JobDetail.class$(JobDetail.java:59)
at org.quartz.JobDetail.isStateful(JobDetail.java:396)
at org.quartz.simpl.RAMJobStore.triggerFired(RAMJobStore.java:1207)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:307)
Exception in thread "defaultScheduler_QuartzSchedulerThread" java.lang.NoClassDefFoundError: org.quartz.StatefulJob

  1. ArchivaStartup.java
    04/Jun/09 3:25 AM
    9 kB
    Marcus Dimand
  2. catalina.out
    19/Jan/09 10:09 AM
    101 kB
    Marcus Dimand

Activity

Hide
Marcus Dimand added a comment -

To Mr. Brett Porter

Dear Brett,

We need to know how to go on with Maven Archiva in our installation. Could you please answer the following questions, regarding the bug we reported:

1) Are you planning to fix this bug?
2) When will you be able to do this?
3) Are we on the right track waiting for a solution or should we find alternatives?

Thanks and regards,
Marcus Dimand

Show
Marcus Dimand added a comment - To Mr. Brett Porter Dear Brett, We need to know how to go on with Maven Archiva in our installation. Could you please answer the following questions, regarding the bug we reported: 1) Are you planning to fix this bug? 2) When will you be able to do this? 3) Are we on the right track waiting for a solution or should we find alternatives? Thanks and regards, Marcus Dimand
Hide
James William Dumay added a comment - - edited

Committed in r744785.

Marcus, this fix will be in the upcoming Archiva 1.2-m2 release. Could you please test this?

Show
James William Dumay added a comment - - edited Committed in r744785. Marcus, this fix will be in the upcoming Archiva 1.2-m2 release. Could you please test this?
Hide
James William Dumay added a comment -

As a note, when the context is destroyed we call close() on the ApplicationContext. This is because we initialize it ourselves in Plexus-Spring.

Show
James William Dumay added a comment - As a note, when the context is destroyed we call close() on the ApplicationContext. This is because we initialize it ourselves in Plexus-Spring.
Hide
Marcus Dimand added a comment -

Implementation of r744785 does not solve the problem.
We checked the correct implementation and tested again but the problem still exists.

Best regards,
Marcus

Show
Marcus Dimand added a comment - Implementation of r744785 does not solve the problem. We checked the correct implementation and tested again but the problem still exists. Best regards, Marcus
Hide
Marcus Dimand added a comment -

Dear Mr. Brett Porter,
Dear Mr. James William Dumay,

As mentioned previously we checked your provided bug fix. Unfortunally it doesn't solve the bug.
We worked also on a solution and we realized following:

  • When the application starts, it's lifecycle starts also some Queues and Schedulers.
  • Those Threads are still running even the application has shutdown,
    because the application's lifecycle doesn't stop those threads.
  • Hence the shutdown process is not proper performed.
  • The execution of a scheduled thread raises an exception as the application is already stopped.

Unfortunally we didn't find any way to solve this issue in the lifecycle configuration of the application,
as we are not familiar with plexus and the archiva architecture.
But we were able to implement a workaround in the ArchivaStartup class that shutdown the mentioned
ressources and closes the application context.
To reproduce the bug it is important to wait till all threads (ThreadPool) are started, the solution is to set the "Managed Repository" scan cronjob to a minute interval and then wait till all threads are started.
We have tested this piece of code and it seems to work.
Please be so kind and review the changes and maybe some one of you guys is able to solve the issue
on right place. We hope that our workaround helps you a little bit to find a proper solution. You can
find the piece of code attached to the issue.

Best regards,
Marcus Dimand

Show
Marcus Dimand added a comment - Dear Mr. Brett Porter, Dear Mr. James William Dumay, As mentioned previously we checked your provided bug fix. Unfortunally it doesn't solve the bug. We worked also on a solution and we realized following:
  • When the application starts, it's lifecycle starts also some Queues and Schedulers.
  • Those Threads are still running even the application has shutdown, because the application's lifecycle doesn't stop those threads.
  • Hence the shutdown process is not proper performed.
  • The execution of a scheduled thread raises an exception as the application is already stopped.
Unfortunally we didn't find any way to solve this issue in the lifecycle configuration of the application, as we are not familiar with plexus and the archiva architecture. But we were able to implement a workaround in the ArchivaStartup class that shutdown the mentioned ressources and closes the application context. To reproduce the bug it is important to wait till all threads (ThreadPool) are started, the solution is to set the "Managed Repository" scan cronjob to a minute interval and then wait till all threads are started. We have tested this piece of code and it seems to work. Please be so kind and review the changes and maybe some one of you guys is able to solve the issue on right place. We hope that our workaround helps you a little bit to find a proper solution. You can find the piece of code attached to the issue. Best regards, Marcus Dimand
Hide
Marcus Dimand added a comment - - edited

Workaround see above under 'File Attachments'

Show
Marcus Dimand added a comment - - edited Workaround see above under 'File Attachments'
Hide
Maria Odea Ching added a comment -

Thanks for the submitting the workaround Marcus I'll take a look at it.

Show
Maria Odea Ching added a comment - Thanks for the submitting the workaround Marcus I'll take a look at it.
Hide
Gwen Harold Autencio added a comment -

Tried to replicate issue using trunk r806019.

Steps that I took.
1. Setup archiva webapp in tomcat
2. Add a managed repository and set cron expression to 1 minute
3. After a while, stop archiva.

Logs in catalina.out displays.

Aug 20, 2009 10:00:00 AM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already. Could not load org.apache.maven.archiva.scheduled.tasks.DatabaseTask. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1272)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at org.apache.maven.archiva.scheduled.DatabaseTaskJob.execute(DatabaseTaskJob.java:59)
at org.quartz.core.JobRunShell.run(JobRunShell.java:191)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516)
Exception in thread "defaultScheduler_Worker-0" java.lang.NoClassDefFoundError: org/apache/maven/archiva/scheduled/tasks/DatabaseTask
at org.apache.maven.archiva.scheduled.DatabaseTaskJob.execute(DatabaseTaskJob.java:59)
at org.quartz.core.JobRunShell.run(JobRunShell.java:191)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516)

Show
Gwen Harold Autencio added a comment - Tried to replicate issue using trunk r806019. Steps that I took. 1. Setup archiva webapp in tomcat 2. Add a managed repository and set cron expression to 1 minute 3. After a while, stop archiva. Logs in catalina.out displays. Aug 20, 2009 10:00:00 AM org.apache.catalina.loader.WebappClassLoader loadClass INFO: Illegal access: this web application instance has been stopped already. Could not load org.apache.maven.archiva.scheduled.tasks.DatabaseTask. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact. java.lang.IllegalStateException at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1272) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at org.apache.maven.archiva.scheduled.DatabaseTaskJob.execute(DatabaseTaskJob.java:59) at org.quartz.core.JobRunShell.run(JobRunShell.java:191) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516) Exception in thread "defaultScheduler_Worker-0" java.lang.NoClassDefFoundError: org/apache/maven/archiva/scheduled/tasks/DatabaseTask at org.apache.maven.archiva.scheduled.DatabaseTaskJob.execute(DatabaseTaskJob.java:59) at org.quartz.core.JobRunShell.run(JobRunShell.java:191) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516)
Hide
Markus Markl added a comment -

Is there a possibilty to include a fix in version 1.2.3 as planned recently?

Thanks!

Regards,
Markus

Show
Markus Markl added a comment - Is there a possibilty to include a fix in version 1.2.3 as planned recently? Thanks! Regards, Markus
Hide
Brett Porter added a comment -

for review in 1.3.1, patch attached.

Show
Brett Porter added a comment - for review in 1.3.1, patch attached.
Hide
Maria Odea Ching added a comment -

I'm still able to reproduce this problem in 1.3.x branch. Although I don't get the exact same stack trace, I can see the thread still running after I've shutdown Tomcat.

Show
Maria Odea Ching added a comment - I'm still able to reproduce this problem in 1.3.x branch. Although I don't get the exact same stack trace, I can see the thread still running after I've shutdown Tomcat.
Hide
Maria Odea Ching added a comment -

Thanks for the patch Marcus! I tweaked it a bit and applied it to 1.3.x branch in -r946618 and merged it to trunk in -rr946631.

Show
Maria Odea Ching added a comment - Thanks for the patch Marcus! I tweaked it a bit and applied it to 1.3.x branch in -r946618 and merged it to trunk in -rr946631.

People

Vote (3)
Watch (5)

Dates

  • Created:
    Updated:
    Resolved: