Hi basically this happens when you don't provide InitialContexFactory to the Initialcontext when creating an InitialContext object. If your code resides inside tomcat you don't need to do this because it knows where its directory service is located. But if you want to connect to directory service from outside tomcat I am not sure whether you can do it or not? If you want to do it there is only one way? Find where the implementation of the factory interface is. It is responsibility of the service provider to provide its implementation. Once you find it create env properties accordingly and pass it to InitialContext constructor while creating object for that.
-----Original Message----- From: Pid [mailto:p...@pidster.com] Sent: Friday, March 26, 2010 6:42 PM To: Tomcat Users List Cc: David Calavera Subject: Re: Configuring a database connection pool by source On 24/03/2010 18:39, David Calavera wrote: > Hi, > > I'm working in an application that uses an embedded tomcat and I'd like to > add a feature to add a connection pool by source but when I run the server > I'm getting this error: > > javax.naming.NoInitialContextException: Need to specify class name in >> environment or system property, or as an applet parameter, or in an >> application resource file: java.naming.factory.initial That sounds like you haven't configued the InitialContext via a suitable Factory. I don't think Tomcat embedded does that automatically*, so you would need to provide it yourself. p * someone will correct me if I'm wrong. > I'm using the tomcat jars for the version 6.0.18, and this is how I'm trying > to do it: > > tomcat = new org.apache.catalina.startup.Tomcat() //creates the new server > > ... // configures the server > > StandardContext application = tomcat.addWebapp(); //creates the web >> application > > ... // configures the web application > > resource = org.apache.catalina.deploy.ContextResource() // creates the new >> JNDI resource > > ... // configures the JNDI resource with the name, type and properties > > application.getNamingResources().addResource(resource) // adds the resource >> to the application context > > >> tomcat.start() //start tomcat > > > This is more or less the code, seems I'm not configuring anything because > without the resource it works fine. > > Can anyone help me? > > Thank you > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org