[jboss-jira] [JBoss JIRA] (WFLY-2777) JNDI external context binding doesn't properly set a module class loader

Ivo Studensky (JIRA) issues at jboss.org
Mon Jan 20 05:31:28 EST 2014


Ivo Studensky created WFLY-2777:
-----------------------------------

             Summary: JNDI external context binding doesn't properly set a module class loader
                 Key: WFLY-2777
                 URL: https://issues.jboss.org/browse/WFLY-2777
             Project: WildFly
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: Naming
    Affects Versions: 8.0.0.CR1
            Reporter: Ivo Studensky
            Assignee: Ivo Studensky
             Fix For: 8.0.0.Final


The current implementation of JNDI external context binding takes a module class loader if based by a module for loading a initialContextClassName only (note that this initialContextClassName is one of InitialContext, InitialDirContext or InitialLdapContext). While it rather needs to switch TCCL to the module class loader to be available when trying to get a new instance of it at line 87, see the snippet below. As this is the moment when it constructs a new initial context from a factory class given by environment properties.

{code:java|title=naming/src/main/java/org/jboss/as/naming/ExternalContextObjectFactory.java}
83             Module module = Module.getBootModuleLoader().loadModule(ModuleIdentifier.fromString(initialContextModule));
84             loader = module.getClassLoader();
85             initialContextClass = Class.forName(initialContextClassName, true, module.getClassLoader());
86             Constructor ctor = initialContextClass.getConstructor(Hashtable.class);
87             context = (Context) ctor.newInstance(newEnvironment);
{code}
Due to this issue the binding fails with an exception as follows:
{noformat}
17:02:46,740 ERROR [stderr] (default task-1) Caused by: java.lang.reflect.InvocationTargetException
17:02:46,740 ERROR [stderr] (default task-1)   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
17:02:46,740 ERROR [stderr] (default task-1)   at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
17:02:46,741 ERROR [stderr] (default task-1)   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
17:02:46,741 ERROR [stderr] (default task-1)   at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
17:02:46,742 ERROR [stderr] (default task-1)   at org.jboss.as.naming.ExternalContextObjectFactory.createContext(ExternalContextObjectFactory.java:87)
17:02:46,742 ERROR [stderr] (default task-1)   at org.jboss.as.naming.ExternalContextObjectFactory.getObjectInstance(ExternalContextObjectFactory.java:46)
17:02:46,743 ERROR [stderr] (default task-1)   at org.jboss.as.naming.subsystem.NamingBindingAdd$2.getReference(NamingBindingAdd.java:255)
17:02:46,743 ERROR [stderr] (default task-1)   ... 36 more
17:02:46,744 ERROR [stderr] (default task-1) Caused by: javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jboss.security.jndi.JndiLoginInitialContextFactory from classloader ModuleClassLoader for Module "deployment.messagesender.war:main" from Service Module Loader
17:02:46,744 ERROR [stderr] (default task-1)   at org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:116)
17:02:46,744 ERROR [stderr] (default task-1)   at org.jboss.as.naming.InitialContext.init(InitialContext.java:99)
17:02:46,745 ERROR [stderr] (default task-1)   at javax.naming.InitialContext.<init>(InitialContext.java:216)
17:02:46,745 ERROR [stderr] (default task-1)   at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:101)
17:02:46,745 ERROR [stderr] (default task-1)   at org.jboss.as.naming.InitialContext.<init>(InitialContext.java:90)
17:02:46,746 ERROR [stderr] (default task-1)   at org.jboss.as.naming.InitialContextFactory.getInitialContext(InitialContextFactory.java:44)
17:02:46,746 ERROR [stderr] (default task-1)   at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
17:02:46,746 ERROR [stderr] (default task-1)   at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
17:02:46,746 ERROR [stderr] (default task-1)   at javax.naming.InitialContext.init(InitialContext.java:242)
17:02:46,747 ERROR [stderr] (default task-1)   at javax.naming.InitialContext.<init>(InitialContext.java:216)
17:02:46,747 ERROR [stderr] (default task-1)   ... 43 more
{noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list