I have a spring app configured to have a property file configuration on xml as
<context:property-placeholder location="classpath:app.properties"/>
I have classes that looks up values from here using the @Value annotation. However, everytime I run my junit test without a java application server (Websphere) it takes a while to look up the value, like 1 second for each field. turning on DEBUG mode revealed it is the JNDI lookup causing it.
2016-09-23 17:50:29,462{ISO8601 [P=25904:O=0:CT] org.springframework.core.env.PropertySourcesPropertyResolver DEBUG - Searching for key 'spring.liveBeansView.mbeanDomain' in [servletConfigInitParams]
2016-09-23 17:50:29,462{ISO8601 [P=25904:O=0:CT] org.springframework.core.env.PropertySourcesPropertyResolver DEBUG - Searching for key 'spring.liveBeansView.mbeanDomain' in [servletContextInitParams]
2016-09-23 17:50:29,462{ISO8601 [P=25904:O=0:CT] org.springframework.core.env.PropertySourcesPropertyResolver DEBUG - Searching for key 'spring.liveBeansView.mbeanDomain' in [jndiProperties]
2016-09-23 17:50:29,462{ISO8601 [P=25904:O=0:CT] org.springframework.jndi.JndiTemplate DEBUG - Looking up JNDI object with name [java:comp/env/spring.liveBeansView.mbeanDomain]
Sep 23, 2016 5:50:29 PM null null
**SEVERE: javaAccessorNotSet**
2016-09-23 17:50:29,463{ISO8601 [P=25904:O=0:CT] org.springframework.jndi.JndiLocatorDelegate DEBUG - Converted JNDI name [java:comp/env/spring.liveBeansView.mbeanDomain] not found - trying original name [spring.liveBeansView.mbeanDomain]. javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment.
2016-09-23 17:50:29,463{ISO8601 [P=25904:O=0:CT] org.springframework.jndi.JndiTemplate DEBUG - Looking up JNDI object with name [spring.liveBeansView.mbeanDomain]
2016-09-23 17:50:30,474{ISO8601 [P=25904:O=0:CT] org.springframework.jndi.JndiPropertySource DEBUG - JNDI lookup for name [spring.liveBeansView.mbeanDomain] threw NamingException with message: Could not obtain an initial context due to a communication failure. Since no provider URL was specified, the default provider URL of "corbaloc:iiop:1.0@mymachine:2809/NameService" was used. Make sure that any bootstrap address information in the URL is correct and that the target name server is running. Possible causes other than an incorrect bootstrap address or unavailable name server include the network environment and workstation network configuration.. Returning null.
No problems with getting the value from the property file.
I need help to find the best way to configure the application to skip jndi lookups
I created a spring.properties file and added this value spring.jndi.ignore=true