0
votes

Was working fine with Spring but not with Spring Boot 2.

After WAR redeployment to Wildfly 10 JMS stops working with error:

ERROR [org.springframework.jms.listener.DefaultMessageListenerContainer] (DefaultMessageListenerContainer-1) Could not refresh JMS Connection for destination 'wfQueue' - retrying using FixedBackOff{interval=5000, currentAttempts=44, maxAttempts=unlimited}. Cause: Failed to create session factory; nested exception is java.lang.IllegalStateException: Server locator is closed (maybe it was garbage collected)

Restart fixes the problem but downtime is undesirable.

Dependencies:

        <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc7</artifactId>
        <version>12.1.0.2.0</version>
    </dependency>





    <!-- Spring -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
          </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-entitymanager</artifactId>
       <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-autoconfigure</artifactId>
    </dependency>


    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-activemq</artifactId>
    </dependency>



    <!-- Appache commons -->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.5</version>
    </dependency>

    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.2</version>
    </dependency>


    <!-- POI -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.10-FINAL</version>           
    </dependency>

    <!-- For documents at the stmt screene -->
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongo-java-driver</artifactId>
    </dependency>



    <!-- Gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
    </dependency>

    <!-- Mail -->
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.7</version>
    </dependency>

    <!-- xstream -->
    <dependency>
        <groupId>com.thoughtworks.xstream</groupId>
        <artifactId>xstream</artifactId>
        <version>1.4.9</version>
    </dependency>


    <!--############################# JSP RELATED ####################### -->
    <!-- JSP Dependency -->
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>2.3.1</version>
    </dependency>

    <!-- Servlet Dependency -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
    </dependency>


    <dependency>
        <groupId>javax.servlet.jsp.jstl</groupId>
        <artifactId>javax.servlet.jsp.jstl-api</artifactId>
        <version>1.2.1</version>
    </dependency>

    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency>





    <dependency>
        <groupId>displaytag</groupId>
        <artifactId>displaytag</artifactId>
        <version>1.2</version>
        <exclusions>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
        </exclusions>           
    </dependency>


    <dependency>
        <groupId>org.apache.taglibs</groupId>
        <artifactId>taglibs-standard-impl</artifactId>
        <version>1.2.5</version>
    </dependency>

    <!-- EJB -->
    <dependency>
        <groupId>org.jboss</groupId>
        <artifactId>jboss-remote-naming</artifactId>
        <version>2.0.4.Final</version>
    </dependency>

    <dependency>
        <groupId>org.jboss.xnio</groupId>
        <artifactId>xnio-nio</artifactId>
        <version>3.4.2.Final</version>
    </dependency>


    <dependency>
        <groupId>org.jboss.marshalling</groupId>
        <artifactId>jboss-marshalling</artifactId>
        <version>1.4.11.Final</version>
    </dependency>

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-ejb-client-bom</artifactId>
        <version>10.0.0.Final</version>
        <type>pom</type>
    </dependency>
1

1 Answers

0
votes

From here How connect to WildFly 10.1.0.Final ActiveMQ Artemis using JNDI and Spring?

1) remove spring.jms.jndi-name=java:/ConnectionFactory from application.properties

2) add to boot configuration

 public ConnectionFactory notificacionesConnectionFactory() throws IllegalArgumentException, NamingException {
     JndiObjectFactoryBean jndi = new JndiObjectFactoryBean();
     jndi.setJndiName("java:/ConnectionFactory");
     jndi.setLookupOnStartup(true);
     jndi.setProxyInterface(ConnectionFactory.class);
     jndi.afterPropertiesSet();
     return  new  SingleConnectionFactory((ConnectionFactory)jndi.getObject());
 }