[jboss-jira] [JBoss JIRA] (WFCORE-4901) TCCL not set to application classloader when MBean Notification is invoked

Moulali Shikalwadi (Jira) issues at jboss.org
Thu Apr 2 03:30:52 EDT 2020


     [ https://issues.redhat.com/browse/WFCORE-4901?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Moulali Shikalwadi updated WFCORE-4901:
---------------------------------------
    Workaround Description: 
Manually set the TCCL before invoking the method.

{quote}

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);
       }
{quote}

  was:
Manually set the TCCL before invoking the method.

{quote}
avax.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
{quote}





> TCCL not set to application classloader when MBean Notification is invoked
> --------------------------------------------------------------------------
>
>                 Key: WFCORE-4901
>                 URL: https://issues.redhat.com/browse/WFCORE-4901
>             Project: WildFly Core
>          Issue Type: Bug
>            Reporter: Moulali Shikalwadi
>            Assignee: Moulali Shikalwadi
>            Priority: Major
>
> 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



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jboss-jira mailing list