title: Custom MBean in Tomcat - cannot find javaURLContextFactory when creating InitialContext
body: <p>I've written a custom MBean that deploys in Tomcat 6. One of its tasks is to query a database value. I'm doing this by loading up the database resource using JNDI - the resource is defined in Tomcat's server.xml. </p>
  
  <p>The problem is that when I create an instance of <code>javax.naming.InitialContext</code> it throws a <code>ClassNotFoundException</code> as it can't find <code>org.apache.naming.java.javaURLContextFactory</code>. 
  This class is in <code>catalina.jar</code> and loaded by the common classloader. The jar containing my MBean code is loaded by a shared classloader. </p>
  
  <p>Any ideas as to how I can get around this?</p>
  
  <p>To note: my MBean is loaded by a ContextListener which I've defined in the <code>tomcat/conf/web.xml</code>. I've also defined it in a webapp <code>web.xml</code> which makes no difference. I can't really move my jar so as to be loaded by the common classloader as it relies on classes loaded by the shared classloader.</p>
  
  <p>Thanks in advance, </p>
  
  <p>Will</p>