Remove JNDI from Spring initialization

user7294900 :

I'm loading Spring application in maven tomcat plugin. I'm not using Spring boot.

On loading I'm getting debug logs of failing to load JNDI properties, for example:

[localhost-startStop-1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [server_useforwardheaders]
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiPropertySource - JNDI lookup for name [server_useforwardheaders] threw NamingException with message: Name [server_useforwardheaders] is not bound in this Context. Unable to find [server_useforwardheaders].. Returning null.
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/server.USE-FORWARD-HEADERS]
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/server.USE-FORWARD-HEADERS] not found - trying original name [server.USE-FORWARD-HEADERS]. javax.naming.NameNotFoundException: Name [server.USE-FORWARD-HEADERS] is not bound in this Context. Unable to find [server.USE-FORWARD-HEADERS].
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [server.USE-FORWARD-HEADERS]
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiPropertySource - JNDI lookup for name [server.USE-FORWARD-HEADERS] threw NamingException with message: Name [server.USE-FORWARD-HEADERS] is not bound in this Context. Unable to find [server.USE-FORWARD-HEADERS].. Returning null.
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/server_USE-FORWARD-HEADERS]
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/server_USE-FORWARD-HEADERS] not found - trying original name [server_USE-FORWARD-HEADERS]. javax.naming.NameNotFoundException: Name [server_USE-FORWARD-HEADERS] is not bound in this Context. Unable to find [server_USE-FORWARD-HEADERS].
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [server_USE-FORWARD-HEADERS]
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiPropertySource - JNDI lookup for name [server_USE-FORWARD-HEADERS] threw NamingException with message: Name [server_USE-FORWARD-HEADERS] is not bound in this Context. Unable to find [server_USE-FORWARD-HEADERS].. Returning null.
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/server.USE_FORWARD_HEADERS]
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/server.USE_FORWARD_HEADERS] not found - trying original name [server.USE_FORWARD_HEADERS]. javax.naming.NameNotFoundException: Name [server.USE_FORWARD_HEADERS] is not bound in this Context. Unable to find [server.USE_FORWARD_HEADERS].
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [server.USE_FORWARD_HEADERS]
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiPropertySource - JNDI lookup for name [server.USE_FORWARD_HEADERS] threw NamingException with message: Name [server.USE_FORWARD_HEADERS] is not bound in this Context. Unable to find [server.USE_FORWARD_HEADERS].. Returning null.
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/server_USE_FORWARD_HEADERS]
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/server_USE_FORWARD_HEADERS] not found - trying original name [server_USE_FORWARD_HEADERS]. javax.naming.NameNotFoundException: Name [server_USE_FORWARD_HEADERS] is not bound in this Context. Unable to find [server_USE_FORWARD_HEADERS].
[localhost-startStop-1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [server_USE_FORWARD_HEADERS]

Can I disable/ignore JNDI in my spring projects?

vancleff :

It's a good read: what is JNDI?

Basic use of JNDI is to allows distributed applications to look up services in an abstract, resource-independent way.


To disable JNDI

create a spring.properties file in src/main/resources (ignore if already created) and add this value spring.jndi.ignore=true

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=151537&siteId=1