Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] javax.naming.NamingException: This context is immutable; remaining name 'env'

Hello,

I was just able to make JNDI work on my project. I am using jetty 7.1.4.v20100610.

On JETTY_HOME/etc/jetty.xml, I added an ActiveMQConnectionFactory that will be looked up from the code:

   <New id="cf" class="org.eclipse.jetty.plus.jndi.Resource">
     <Arg><Ref id="Server"/></Arg>
     <Arg>jms/connectionFactory</Arg>
     <Arg>
       <New class="org.apache.activemq.ActiveMQConnectionFactory">
         <Arg>tcp://localhost:61616</Arg>
       </New>
     </Arg>
   </New>

and looked up as

       InitialContext context = null;
       ConnectionFactory connectionFactory = null;
       try {
           context = new InitialContext();
connectionFactory = (ConnectionFactory)context.lookup("java:comp/env/jms/connectionFactory");
       } catch (NamingException e) {
           logger.error("initConnection", e);
       }

This is actually working on every jetty server restart.

Problem starts when I do a redeploy of the WAR app that does the looking up for ActiveMQConnectionFactory. I use cargo for redeployment. Cargo successfully redeploys the WAR file but right after the deployment, I get this from jetty's log:

javax.naming.NamingException: This context is immutable; remaining name 'env' at org.eclipse.jetty.jndi.NamingContext.createSubcontext(NamingContext.java:432) at org.eclipse.jetty.jndi.NamingContext.createSubcontext(NamingContext.java:515) at org.eclipse.jetty.plus.webapp.EnvConfiguration.createEnvContext(EnvConfiguration.java:203) at org.eclipse.jetty.plus.webapp.EnvConfiguration.preConfigure(EnvConfiguration.java:62) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:379) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55) at org.codehaus.cargo.deployer.jetty.DeployerServlet.deployArchive(DeployerServlet.java:258) at org.codehaus.cargo.deployer.jetty.DeployerServlet.doPut(DeployerServlet.java:192)

At first I thought that this was just being caused by hot deployment and redeploy raise condition, but it was not. The deployed app is not working not until I do a manual jetty server restart which after that, everything works fine again.

Any ideas?

Thanks in advance.
-don


Back to the top