2 Replies Latest reply on Jul 6, 2017 10:49 AM by cht_love_2

    wildfly can't graceful shut down perfectly about JNDI

    cht_love_2

      Hi,

      I am facing an issue recently with my WildFly8.1 about the destorying time of JNDI.

      I create a spring bean which will query MySQL by JNDI last for some time, but  the query operation will throw exception when I shutdown wildfly suddenly.

      JNDI is configed in wildfly standalone.xml, like this:

      pastedImage_1.png

      I obtain datasource by spring configuration file, like this:

      pastedImage_0.png

      My test class is DalServiceImpl which implements DalService and is configed in spring.

      The main part of class DalServiceImpl is:

      @Override
      public void destroy() throws Exception {
        System.out.println("destory --------------search");
        int result = search();
        System.out.println("destory --------------search result:" + result);
      }
      
      
      @Override
      public void afterPropertiesSet() throws Exception {
        System.out.println("init --------------search");
        for(int i=0; i<100; i++){
        int result = search();
        Thread.sleep(2000); //2s
        System.out.println("init --------------search result:" + result);
        }
      }
      
      private int search() {
        Map<String, String> map = new HashMap<String, String>();
        List<Map<String, Object>> result = this.dalClient.queryForList("macro.getAllMethodKeys", map);
        return result.size();
      }
      
      
      
      
      

       

      the main part of exception is :

      .......

      2017-07-04 14:11:44,841 INFO  [stdout] (MSC service thread 1-8) init --------------search result:14450

      2017-07-04 14:11:47,040 INFO  [stdout] (MSC service thread 1-8) init --------------search result:14450

      2017-07-04 14:11:47,886 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) JBAS010418: Stopped Driver service with driver-name = web-test-0.0.1-SNAPSHOT.war_com.mysql.jdbc.Driver_5_1

      2017-07-04 14:11:47,903 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010409: Unbound data source [java:jboss/jdbc/testDS]

      2017-07-04 14:11:47,902 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) JBAS010418: Stopped Driver service with driver-name = sybase

      2017-07-04 14:11:47,901 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) JBAS010418: Stopped Driver service with driver-name = oracle

      2017-07-04 14:11:47,899 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010409: Unbound data source [java:jboss/jdbc/wfcWDS]

      2017-07-04 14:11:47,889 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) JBAS010418: Stopped Driver service with driver-name = com.db2

      2017-07-04 14:11:47,913 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) JBAS010418: Stopped Driver service with driver-name = com.mysql

      2017-07-04 14:11:49,219 INFO  [stdout] (MSC service thread 1-8) init --------------search result:14450

      2017-07-04 14:11:49,226 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-8) Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@eaafc0: defining beans [dataSource,dalClient,dalService]; root of factory hierarchy

      2017-07-04 14:11:49,230 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-8) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dalService' defined in class path resource [conf/spring/appContext.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: javax.resource.ResourceException: IJ000451: The connection manager is shutdown: java:jboss/jdbc/testDS

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

       

       

      But I run the same test code in apache-tomcat-8.0.36 and websphere7, there is nothing exception happend.

      In other words, the shutting down of JNDI is before the job of querying database to finish in WildFly8.1.

       

      So, I think it's whether a bug of WildFly8.1 or there is some config paramters which I don't know to achieve  graceful shut down.

      And is it implemented in the new version, how to config?

       

       

      Appreciate your help... if replies

       

      Thanks