Julian Payne wrote:
>
> Hi,
>
> I have been using Jakarta-Tomcat 3.2.1 and when I upgraded to the 4.0 beta 3
> I have a propblem with my JNDI configuration.
>
> I have a servlet that uses an EJB container that requires the following
> "jndi.properties" :
>
> java.naming.factory.initial
> com.sun.jndi.rmi.registry.RegistryContextFactory
> java.naming.provider.url rmi://localhost:1099
> java.naming.factory.url.pkgs org.objectweb.jonas.naming
>
> With 3.2.1 I just needed to make sure that I had my jndi.properties file on
> the classpath, with 4.0 beta 3 I do not seem to be able to get this read by
> any means. The only mechanism that I found to get this to work is if I call
> "System.setProperty()" in my servlet just before I call "new
> javax.naming.InitialContext()". If I do not do this I get the following
> error message:
>
> javax.naming.NoInitialContextException: Cannot instantiate class:
> org.apache.naming.java.javaURLContextFactory. Root exception is
> java.lang.ClassCastException: org.apache.naming.java.javaURLContextFactory
>
> Can anyone tell me how I am supposed to set this for my servlet? I tried the
> following without any success:
>
> 1) Using env-entry in my WEB-INF/web.xml
> 2) Putting the jndi.properties into the classpath
> 3) Using <Resource> in the server.xml (except that I was not sure of the
> correct parameters to use...)
This is what I use inside a Context element in server.xml;
<Resource name="jndi/ContextPool" auth="SERVLET"
type="com.ecomda.ldap.ContextPool"/>
<ResourceParams name="jndi/ContextPool">
<parameter><name>factory</name><value>com.ecomda.ldap.ContextPoolFactory</value></parameter>
<parameter><name>providerURL</name><value>ldap://trabant.intern.ecomda.de:389</value></parameter>
<parameter><name>searchBase</name><value>ou=People,o=ecomda.de</value></parameter>
<parameter><name>authentication</name><value>simple</value></parameter>
<parameter><name>maxPoolSize</name><value>20</value></parameter>
</ResourceParams>
This is fairly similar to the connection pooling factories that tomcat
provides itself.
There is a classpath problem though. The ResourceFactory class doesn't
recognize the ResourceRef class unless you replace the (... instanceof
ResourceRef) with a ( ..getClass().getName().equals("...ResourceRef").
--
- Torgeir