2011-03-31 23 views
6

He configurado algunos programadores en la primavera. Cuando trato de iniciar mi aplicación web, arroja el siguiente error y se detiene. Mi aplicación no se ha iniciado realmente. Mi planificador se ve así también cuando i cierre Tomcat un poco de hilo de cuarzo no se apaganError al iniciar/detener Tomcat 6.0.29

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean" destroy-method="destroy"> 
    <property name="triggers"> 
     <list> 
      <ref bean="scheduler.localAdaptorCronTrigger"/> 
     </list> 
    </property> 
</bean> 

<bean id="localAdaptor" class="LocalAdaptor" /> 

<bean id="scheduler.localFSSlaAdaptorJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> 
     <property name="targetObject" ref="Adaptor"/> 
     <property name="targetMethod" value="xxxxxx"/> 
</bean> 

<bean id="scheduler.localAdaptorCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> 
     <property name="jobDetail" ref="scheduler.localAdaptorJobDetail"/> 
     <!-- run every morning at 12 AM --> 
     <property name="cronExpression" value="0 0 0 * * ?"/> 
    </bean> 
    <bean id="scheduler.localFSSlaAdaptorSimpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> 
     <!-- see the example of method invoking job above --> 
     <property name="jobDetail" ref="scheduler.localAdaptorJobDetail"/> 
     <!-- runs after 10 seconds for single time...--> 
     <property name="startDelay" value="1000"/> 
     <!-- repeated once --> 
     <property name="repeatCount" value="0"/> 
     <!-- useless as the repeat count is 0, so it will run once after 10 seconds of the startup of the application.... --> 
     <property name="repeatInterval" value="60000"/> 
</bean> 

StackTrace:

INFO: Closing Spring root WebApplicationContext 
Mar 31, 2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc 
SEVERE: The web application [/] registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 
Mar 31, 2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 
SEVERE: The web application [/] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak. 
Mar 31, 2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 
SEVERE: The web application [/] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] but has failed to stop it. This is very likely to create a memory leak. 
Mar 31, 2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 
SEVERE: The web application [/c] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] but has failed to stop it. This is very likely to create a memory leak. 
Mar 31, 2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads 
SEVERE: The web application [/] appears to have started a thread named [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] but has failed to stop it. This is very likely to create a memory leak. 
Mar 31, 2011 10:02:22 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap 
SEVERE: The web application [/] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [[email protected]]) and a value of type [org.apache.cxf.bus.CXFBusImpl] (value [[email protected]]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak. 

he implementado oyente:

import javax.servlet.ServletContext; 
import javax.servlet.ServletContextEvent; 
import javax.servlet.ServletContextListener; 
import org.quartz.SchedulerException; 
import org.quartz.impl.StdSchedulerFactory; 
import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 


public class QuartzServletContextListener implements ServletContextListener { 

    final Logger log = LoggerFactory.getLogger(QuartzServletContextListener.class); 
    public static final String QUARTZ_FACTORY_KEY = 
      "org.quartz.impl.StdSchedulerFactory.KEY"; 
    private ServletContext ctx = null; 
    private StdSchedulerFactory factory = null; 

    public void contextInitialized(ServletContextEvent sce) { 
     ctx = sce.getServletContext(); 

     try { 

      factory = new StdSchedulerFactory(); 

      // Start the scheduler now 

      factory.getScheduler().start(); 

      log.info("Storing QuartzScheduler Factory at" 
        + QUARTZ_FACTORY_KEY); 

      ctx.setAttribute(QUARTZ_FACTORY_KEY, factory); 

     } catch (Exception ex) { 
      log.error("Quartz failed to initialize", ex); 
     } 
    } 

    public void contextDestroyed(ServletContextEvent sce) { 
     try { 

      log.info("shutting down"); 
      factory.getScheduler().shutdown(); 
      Thread.sleep(1000); 
     } catch (InterruptedException ex) { 
      log.error("Quartz failed to shutdown", ex); 
     } catch (SchedulerException ex) { 
      log.error("Quartz failed to shutdown", ex); 
     } 
    } 
} 

Y añadió en web.xml

<listener> 
     <listener-class>xx.yy.QuartzServletContextListener</listener-class> 
    </listener> 

Cuando intento utilizar shutdown.sh que puede en sí todavía algunos hilos proceso java activo y Tomcat activo.

También mencionar que tengo un poco de 3 a 4 programadores de trabajo diferente como se mencionó anteriormente en el contexto de aplicación.

+0

Ver http://stackoverflow.com/questions/4899205/tomcat-6-memory-leaks-log-entries –

+0

relacionado: http://stackoverflow.com/questions/5054265/is-it-worth-cleaning- threadlocals-en-filter-a-resolver-relacionados-hilo-piscina-temas – Bozho

Respuesta

6

En cuanto a los recursos relacionados con Quartz que informa Tomcat, esto se debe a que Tomcat está un poco demasiado ansioso por buscar recursos no liberados cuando Quartz tarda más de unos pocos milisegundos en cerrar sus recursos.

Véase la discusión aquí (junto con una sencilla solución alternativa):

http://forums.terracotta.org/forums/posts/list/3479.page

+1

le agradecen resolvió el problem.I también implementó un oyente a shutdow – constantlearner

+1

grande, ¿qué hay de marcar esta respuesta como la correcta? – jhouse

+0

@jhouse: No puedo aceptar, pero votaré su respuesta :) –

5

No es un problema. Tomcat elimina automáticamente los hilos no deseados y las ubicaciones de subprocesos, pero simplemente le dice que su código o bibliotecas están haciendo algo "arriesgado".

Es posible que desee informar problemas a las bibliotecas respectivas (c3p0 y CXF) que deberían limpiar al apagar.

Cuestiones relacionadas