Second JNDI search in the code below, it is not performed with the exception of when run in a standalone application against Glassfish (which has been configured to provide QueueConnectionFactoryand DataSourcethrough JNDI). However, the code works fine when deleting a line jndiContext.close().
In real code close(), Spring's call is made JndiObjectFactoryBean, so I cannot remove it easily.
Is this a bug in Glassfish, or am I doing something wrong (e.g. wrong configuration or wrong coding)?
import javax.naming.Context;
import javax.naming.InitialContext;
public class TestInitCtx {
private final static String QUEUE_CONNECTION_FACTORY_JNDI_NAME = "QCF";
private final static String DATA_SOURCE_JNDI_NAME = "DS";
public static void main(String[] args) throws Exception {
Context jndiContext = new InitialContext();
jndiContext.lookup(QUEUE_CONNECTION_FACTORY_JNDI_NAME);
jndiContext.close();
jndiContext = new InitialContext();
jndiContext.lookup(DATA_SOURCE_JNDI_NAME);
}
}
source
share