3 Replies Latest reply on Dec 13, 2016 4:06 AM by Dariusz M

    Error using jboss-ejb-client.properties in tomcat

    Travis H Newbie

      Currently I have a web application that is running in tomcat and is making a remote EJB call and is using the method where the jboss-ejb-client.properties file is in the class path. The remote call works perfectly fine, but if you go to shutdown tomcat you will get the following stack trace.


      java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load [org.jboss.remoting3.spi.AbstractHandleableCloseable$2]. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.

        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1352)

        at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForClassLoading(WebappClassLoaderBase.java:1340)

        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1205)

        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166)

        at org.jboss.remoting3.spi.AbstractHandleableCloseable.close(AbstractHandleableCloseable.java:140)

        at org.jboss.ejb.client.remoting.ConnectionPool.safeClose(ConnectionPool.java:177)

        at org.jboss.ejb.client.remoting.ConnectionPool.shutdown(ConnectionPool.java:115)

        at org.jboss.ejb.client.remoting.ConnectionPool.access$300(ConnectionPool.java:57)

        at org.jboss.ejb.client.remoting.ConnectionPool$ShutdownTask.run(ConnectionPool.java:272)

        at java.lang.Thread.run(Thread.java:745)


      We are using tomcat 8.0.36, java 1.8.0_45-b15, and wildfly 10.0.0.Final.


      Here is the java code that is being used to call the remote ejb


          final Hashtable props = new Hashtable();

          props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");




            final Context context = new InitialContext(props);

            TestBeantRemote remote = (TestBeantRemote) context.lookup("ejb:test/test-ejb/TestBean!com.test.bean.remote.TestBeantRemote");

            List<User> userList = remote.findAllUsers();



          catch(NamingException ex)






      Here are my properties from the jboss-ejb-client.properties file










      Any help on this would be greatly appreciated.

        • 1. Re: Error using jboss-ejb-client.properties in tomcat
          jaikiran pai Master

          The EJB client library adds a shutdown hook to the JVM to cleanup certain things (connection pool in this case). It appears that this shutdown hook is invoked and the application has been undeployed by Tomcat and that's what it's *warning* about. I think there's not much that can be done here other than ignore it.

          • 2. Re: Error using jboss-ejb-client.properties in tomcat
            Dariusz M Newbie

            I have exactly the same problem. Sometimes (not always) during stopping of Tomcat this error occures (after my web application do some ejb calls using ejb-client from WildFly).
            My environment: java, Tomcat 7.0.73, WildFly 10.1.0.Final

            It seems that some jboss-client async thread is trying to close some connection from a pool but web application is already closed by Tomcat (classloader of this web application).

            Sometimes I'm forced to kill tomcat (end its process) because tomcat is waiting for ejb-client threads to stop and hangs.

            I think this is a bug (in jboss ejb-client / ejb-remoting), but fortunatelly does not affect web application and system (memory and socket  usage), so I'm forced to live with it


            Another problem I noticed is that during stopping of Tomcat in it's log there are messages like :

                gru 09, 2016 1:32:37 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

                SEVERE: The web application [/xxx] appears to have started a thread named [Remoting "client-endpoint" xxx] but has failed to stop it. This is very likely to create a memory leak.

            for about 18-21 (ie. 16 + few)  threads, separately for all my web applications (each application has it's own classloader).

            I think ejb-client creates this threads to async ejb calls (using connection pool) and Tomcat has problem to stop them. This is probably also a bug in ejb-client/remonting lib.

            Fortunatelly does not affect my web applications (i did some stress tests, but maybe not full enough).


            But this kind of errors in tomcat log looks awful

            Does anybody smart expert know what can be done with this?

            Any help would be appreciated!

            • 3. Re: Error using jboss-ejb-client.properties in tomcat
              Dariusz M Newbie

              I think I've found the sollution.

              Look into my thread: https://developer.jboss.org/thread/273298

              I've found and called "EJBClientContext.getCurrent().close()" method when context is destroyed of each my web application.

              I hope it helps you too.