Unexpected object received after JNDI lookup "java:comp/env"
Issue
- Objectsbound to the "java:comp/env" JNDI context aren't returned as expected.
The objects that are returned in a lookup call are wrapped in an org.jnp.interfaces.MarshalledValuePair object, where I am expecting the original object to be returned, unwrapped.
package test;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class TestContextListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent e) {
try {
InitialContext ic = new InitialContext();
ic.bind("java:comp/env/Test", Integer.valueOf(8));
Object x = ic.lookup("java:comp/env/Test");
System.out.println("Returned class: " + x.getClass());
} catch (NamingException e1) {
e1.printStackTrace();
}
}
public void contextDestroyed(ServletContextEvent e) {
}
}
- The result that is printed in the Sytem.out call when starting a web application with this example is:
[STDOUT] Returned class: class org.jnp.interfaces.MarshalledValuePair
Environment
- JBoss Enterprise Application Platform (EAP)
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.