JNDI configuration in Tomcat

I am trying to configure a JNDI search in a web application that will be deployed to Tomcat 7. I have specified the following properties in the jndi.properties file:

java.naming.factory.initial = org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs = org.jboss.naming: org.jnp.interfaces, java.naming.provider.url = local: 1199

But when I get the initial context and check its attributes, it discovers that java.naming.factory.initial changes to org.apache.naming.java.JavaURLContextFactory and all other properties remain the same as in the jndi.properties file. I don’t understand why this one property gets changes? How can I prevent this and force tomcat to use the property that I specified?

+4
source share
3 answers

I believe that JNDI properties should be vendor specific. What you are trying to set is for Jboss JNDI properties and may have returned to Tomcat Specific Proerties. Although you may try to overwrite them programmatically, this may not work.

+1
source

You must put all this in the Resource element in your META-INF / context.xml file and find this resource through the java url: comp / env. What Tomcat is trying to tweak here: the factory object for this namespace.

0
source

I think you should add your properties to your catalina.properties file, this is under your $ tomcat_home / conf.

0
source

Source: https://habr.com/ru/post/1486194/


All Articles