title: JNDI context initialization fails in Tomcat when connecting via JMX
body: <p>I have a webapp deployed in Tomcat 7.0.8. Recently I started implementing MBeans to be able to monitor a few actions, which normally are invoked from a quartz scheduler. I connect to Tomcat's MBean server using JConsole and invoke a method, which tries to connect to a database via JNDI. </p>
  
  <p>When execution reaches
  <code>Context initContext = new InitialContext();</code> the following exception is thrown:</p>
  
  <blockquote>
    <p>javax.naming.NoInitialContextException: Cannot instantiate class: org.apache.naming.java.javaURLContextFactory [Root exception is java.lang.ClassNotFoundException: org.apache.naming.java.javaURLContextFactory]</p>
  </blockquote>
  
  <p>When the method is called from the regular servlet (a JAX-WS webservice), there are no problems with the class loading. It seems class loading works differently when JMX is involved, but I can't figure out how... Could it have something to do with <code>RMI class loader disabled</code>, which JConsole tells me? </p>