I think you must send the properties : // Set up the naming provider; this may not always be necessary, depending // on how your Java system is configured. Properties env = new Properties(); env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); env.setProperty("java.naming.provider.url", "localhost"); // env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
try { // Get a naming context System.out.println("before Got context"); jndiContext = new InitialContext(env); System.out.println("Got context"); } catch(Exception e) { // System.out.println(e.toString()); e.printStackTrace(); } At 16:28 4/2/2002 +0100, you wrote: > >Hi, > >I try to use the following line of code in a servlet: > > Context con = new InitialContext(); > >The Servlet is loaded on startup. I get the following exception using >Tomcat 4.0.1 > >javax.naming.NoInitialContextException: > Cannot instantiate class: org.apache.naming.java.javaURLContextFactory. >Root exception is java.lang.ClassCastException: > org.apache.naming.java.javaURLContextFactory > at >javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:659) > at >javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:250) > at javax.naming.InitialContext.init(InitialContext.java:226) > at javax.naming.InitialContext.<init>(InitialContext.java:182) > at ko.shopping.KOWizard.loadExternalResources(KOWizard.java:24) > >Using the same code in a JSP works fine. Is the InitialContext not >available at the time? Any ideas? > >thanks a lot! > >volker turau >FH Wiesbaden Fachbereich Informatik >Tel.: +49-611-9495-205 FAX +49-611-9495-210 >http://www.informatik.fh-wiesbaden.de/~turau/jsp > > >-- >To unsubscribe: <mailto:[EMAIL PROTECTED]> >For additional commands: <mailto:[EMAIL PROTECTED]> >Troubles with the list: <mailto:[EMAIL PROTECTED]> > > Emerson Cargnin TRE-SC Setor de Desenvolvimento Tel: (48) 251-3700 - Ramal 3134 -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>