tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dale Ogilvie" <Dale.Ogil...@trimble.co.nz>
Subject jndi-lookup fails, cured by tomcat restart
Date Mon, 13 Dec 2010 01:57:39 GMT
Hi there,

We are using a spring jndi-lookup to pull the name of a context file
from the global "environment" in our apps. We have set this up in tomcat
6.0.29 like so:

$CATALINA_HOME/conf/context.xml

<Environment name="/propertiesFileName"
value="classpath:test-application.properties" type="java.lang.String"
override="true"/>

This has worked fine for lots of applications, but last week it started
failing for one application when it was redeployed. This results in the
application failing to start.

The error message below suggests that the environment value cannot be
found.

Tomcat 6.0.29 log output:
 
2010-12-08 19:27:24,674 DEBUG ** Invoking afterPropertiesSet() on bean
with name 'propsFileName' **
org.springframework.beans.factory.support.DefaultListableBeanFactory
2010-12-08 19:27:24,674 DEBUG ** Looking up JNDI object with name
[java:comp/env/propertiesFileName] **
org.springframework.jndi.JndiTemplate
2010-12-08 19:27:24,677 DEBUG ** Converted JNDI name
[java:comp/env/propertiesFileName] not found - trying original name
[propertiesFileName]. javax.naming.NameNotFoundException: Name comp is
not bound in this Context ** org.springframe
2010-12-08 19:27:24,677 DEBUG ** Looking up JNDI object with name
[propertiesFileName] ** org.springframework.jndi.JndiTemplate
2010-12-08 19:27:24,679 INFO  ** Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@226
5b1ac: defining beans
[propsFileName,org.springframework.beans.factory.config.PropertyPlacehol
derConfigure
2010-12-08 19:27:24,681 ERROR ** Context initialization failed **
org.springframework.web.context.ContextLoader
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name
'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#
0' defined in class path resource [applicationContext-shared.xml]:
Cannot resolve reference to bean 'propsFileName' while setting bean
property 'location'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'propsFileName': Invocation of init method failed; nested
exception is javax.naming.NameNotFoundException: Name propertiesFileName
is not bound in this Context

Numerous redeployments, failed to resolve the issue for the app.

I restarted tomcat, and the problem went away. I don't want to encounter
such a problem on production, any thoughts as to why this might have
happened? It seems like the global context value went missing for one
app, across redeployments of that app, until tomcat was bounced to
restore it. 

The relevant bits of the application config are below:

Spring application web.xml

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:applicationContext-shared.xml
        </param-value>
    </context-param>

    <listener>
 
<listener-class>org.springframework.web.context.ContextLoaderListener</l
istener-class>
    </listener>

applicationContext-Shared.xml

    <jee:jndi-lookup id="propsFileName" jndi-name="propertiesFileName"
/>

    <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfi
gurer">
       <property name="location" ref="propsFileName"/>
    </bean>

Thanks

Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message