Visualizzazione dei risultati da 1 a 1 su 1
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2007
    Messaggi
    331

    Java Spring Webapp: threads non chiusi correttamente durante lo shutdown e scheduler avviati due volte

    Salve a tutti.
    Ho un'app spring che gira su tomcat8 e ho notato che, facendo lo stop del server rimangono appesi dei thread e devo killare il processo.
    Da log vedo questi problemi legati ai thread:

    1) 19-Apr-2017 12:24:03.498 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.c learReferencesJdbc The web application [myapp] registered the JDBC 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.

    2) 19-Apr-2017 12:24:03.500 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.c learReferencesThreads The web application [myapp] appears to have started a thread named [FirebaseDatabaseWorker] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: sun.misc.Unsafe.park(Native Method)

    3) 19-Apr-2017 12:24:03.502 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.c learReferencesThreads The web application [myapp] appears to have started a thread named [pool-4-thread-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
    sun.misc.Unsafe.park(Native Method)

    4) 19-Apr-2017 12:24:03.503 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.c learReferencesThreads The web application [myapp] appears to have started a thread named [pool-4-thread-2] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
    java.net.PlainSocketImpl.socketConnect(Native Method)

    5) 19-Apr-2017 12:24:03.504 WARNING [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.c learReferencesThreads The web application [myapp] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
    java.lang.Object.wait(Native Method)

    Inoltre noto che delle classi con il tag @Component ed @EnableScheduling viene avviata due volte.

    I miei files di configurazione sono i seguenti:

    /webapp/WEB-INF/web.xml
    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">

    <display-name>Server</display-name>

    <servlet>
    <servlet-name>mvc-dispatcher</servlet-name>
    <servlet-class>
    org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>


    <servlet-mapping>
    <servlet-name>mvc-dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
    </servlet-mapping>

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
    </context-param>

    <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/css/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/img/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>default</servlet-name>
    <url-pattern>/js/*</url-pattern>
    </servlet-mapping>

    <!-- Rimosso per evitare il fatto che gli scheduler siano lanciati due volte -->
    <!-- Workaround suggerito qui: http://stackoverflow.com/questions/1...xecuting-twice -->
    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListe ner
    </listener-class>
    </listener>

    </web-app>

    /webapp/WEB-INF/web.xml
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schem...ring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd">


    <context:component-scan base-package="it.telecomitalia.familyhubserver" />

    <bean
    class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="prefix">
    <value>/WEB-INF/pages/</value>
    </property>
    <property name="suffix">
    <value>.jsp</value>
    </property>
    </bean>

    </beans>


    Provando a commentare questa parte:
    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListe ner
    </listener-class>
    </listener>


    il problema del doppio avvio della classe @Component non si verifica (soluzione trovata qui http://stackoverflow.com/questions/1...xecuting-twice) ma non vorrei che i due problemi descritti nel post siano correlati.
    Ho googleggiato un pò ma non ho trovato delle spiegazioni chiare di entrambi i problemi.

    Qualcuno che ne sa può illuminarmi? Mi piacerebbe una soluzione pulita per non avere il problema della doppia esecuzione e capire il problema dei threads non chiusi correttamente!

    Grazie in anticipo a chi risponderà!
    Ultima modifica di DarthSandr; 19-04-2017 a 14:21

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.