Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-18689

[GSS](7.3.z) TCCL not set to application classloader when MBean Notification is invoked

    XMLWordPrintable

Details

    • +
    • Workaround Exists
    • Hide

      Manually set the TCCL before invoking the method.

      private void invoke() {
            ClassLoader previous = null;
            try {
                previous = Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
                Context ctx = getInitialContext("localhost", 8080, ...);
                // look up and invoke remote ejb that uses WildflyInitialContextFactory
              } finally {
                // reset the TCCL
                Thread.currentThread().setContextClassLoader(previous);
             }
      
      Show
      Manually set the TCCL before invoking the method. private void invoke() { ClassLoader previous = null ; try { previous = Thread .currentThread().getContextClassLoader(); Thread .currentThread().setContextClassLoader( this .getClass().getClassLoader()); Context ctx = getInitialContext( "localhost" , 8080, ...); // look up and invoke remote ejb that uses WildflyInitialContextFactory } finally { // reset the TCCL Thread .currentThread().setContextClassLoader(previous); }
    • Hide

      deploy remote.jar or callback.war
      start JBoss
      It will log ClassNotFound

      start JBoss with -Dworkaround and it will enable the workaround and not throw the exception

      Show
      deploy remote.jar or callback.war start JBoss It will log ClassNotFound start JBoss with -Dworkaround and it will enable the workaround and not throw the exception

    Description

      TCCL not set to application classloader when MBean Notification is invoked
      If an application registers an MBean notification and it receives a notification, the Thread Context ClassLoader is not set to the application, this causes ClassNotFound exceptions on classes that are in the application's classpath.

      javax.naming.NamingException: WFLYNAM0027: Failed instantiate InitialContextFactory org.wildfly.naming.client.WildFlyInitialContextFactory from classloader ModuleClassLoader for Module "org.jboss.as.server" version 6.0.21.Final-redhat-00001 from local module loader @dfd3711 (finder: local module finder @42d3bd8b (roots: /tmp/jboss-eap-7.2/modules,/tmp/jboss-eap-7.2/modules/system/layers/base)) [Root exception is java.lang.ClassNotFoundException: org.wildfly.naming.client.WildFlyInitialContextFactory from [Module "org.jboss.as.server" version 6.0.21.Final-redhat-00001 from local module loader @dfd3711 (finder: local module finder @42d3bd8b (roots: /tmp/jboss-eap-7.2/modules,/tmp/jboss-eap-7.2/modules/system/layers/base))]]
      	at org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:120)
      	at org.jboss.as.naming.InitialContext.init(InitialContext.java:101)
      	at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154)
      	at org.jboss.as.naming.InitialContext.<init>(InitialContext.java:91)
      	at org.jboss.as.naming.InitialContextFactory.getInitialContext(InitialContextFactory.java:43)
      	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
      	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
      	at javax.naming.InitialContext.init(InitialContext.java:244)
      	at javax.naming.InitialContext.<init>(InitialContext.java:216)
      	at test.Client.getInitialContext(Client.java:66)
      	at test.Client.invoke(Client.java:44)
      	at test.Client.handleNotification(Client.java:117)
      	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor$ListenerWrapper.handleNotification(DefaultMBeanServerInterceptor.java:1754)
      	at javax.management.NotificationBroadcasterSupport.handleNotification(NotificationBroadcasterSupport.java:275)
      	at javax.management.NotificationBroadcasterSupport$SendNotifJob.run(NotificationBroadcasterSupport.java:352)
      	at javax.management.NotificationBroadcasterSupport$1.execute(NotificationBroadcasterSupport.java:337)
      	at javax.management.NotificationBroadcasterSupport.sendNotification(NotificationBroadcasterSupport.java:248)
      	at javax.management.MBeanServerDelegate.sendNotification(MBeanServerDelegate.java:209)
      	at org.jboss.as.jmx.model.ModelControllerMBeanServerPlugin$ResourceRegistrationNotificationHandler.handleNotification(ModelControllerMBeanServerPlugin.java:431)
      	at org.jboss.as.controller.notification.NotificationSupports.fireNotifications(NotificationSupports.java:126)
      	at org.jboss.as.controller.notification.NotificationSupports.access$000(NotificationSupports.java:47)
      	at org.jboss.as.controller.notification.NotificationSupports$NonBlockingNotificationSupport$1.run(NotificationSupports.java:105)
      	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
      	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
      	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
      	at java.lang.Thread.run(Thread.java:748)
      	at org.jboss.threads.JBossThread.run(JBossThread.java:485)
      Caused by: java.lang.ClassNotFoundException: org.wildfly.naming.client.WildFlyInitialContextFactory from [Module "org.jboss.as.server" version 6.0.21.Final-redhat-00001 from local module loader @dfd3711 (finder: local module finder @42d3bd8b (roots: /tmp/jboss-eap-7.2/modules,/tmp/jboss-eap-7.2/modules/system/layers/base))]
      	at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
      	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
      	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
      	at java.lang.Class.forName0(Native Method)
      	at java.lang.Class.forName(Class.java:348)
      	at org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:115)
      	... 27 more
      

      Attachments

        1. callback.war
          13 kB
        2. remote.jar
          8 kB

        Issue Links

          Activity

            People

              mshikalw Moulali Shikalwadi
              rhn-support-bmaxwell Brad Maxwell
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: