tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Eggers <its_toas...@yahoo.com>
Subject Re: jndi-lookup fails, cured by tomcat restart
Date Mon, 13 Dec 2010 23:45:56 GMT
Dale,

What happens if you try changing the jndi-name to its fully qualified version?

java:comp/env/propertiesFileName

Then change the context.xml file name to propertiesFileName (no leading slash)?

I'm basing these comments on some similar issues I've seen in the Spring forums, 
and similar configuration issues when using Hibernate with Tomcat.

Don't ask me to explain why this worked for a long time, and then all of a 
suddenly decided not to work.

Hope this helps.

. . . . just a guess.

/mde/


----- Original Message ----
From: Dale Ogilvie <Dale.Ogilvie@trimble.co.nz>
To: Tomcat Users List <users@tomcat.apache.org>
Sent: Mon, December 13, 2010 2:52:09 PM
Subject: RE: jndi-lookup fails, cured by tomcat restart


propsFileName is the name of the bean, which should be initialized with
the string value from the JNDI entry "propertiesFileName" defined in
$CATALINA_HOME/conf/context.xml

This was working, stopped working until a tomcat restart, and is working
again now. My concern is that this may be a bug in tomcat 

So what happens is that tomcat startup creates a JNDI environment entry
in the "cross-application" context called "propertiesFileName". 

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

When each spring app starts, the code <jee:jndi-lookup
id="propsFileName" jndi-name="propertiesFileName"/> in the application
context takes the JNDI environment entry and initializes a bean using
the id "propsFileName" with it.

Finally a spring PropertyPlaceholderConfigurer is created using the
propsFileName bean for the location of the properties file. We use this
to 

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

Looking more closely at the debug log, this line looks quite suspicious
"Name comp is not bound". comp is the root of the environment hierarchy,
why would that be missing?

2010-12-08 19:29:11,161 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.springframework.jndi.JndiObjectFactoryBean 

Log context follows:

2010-12-08 19:29:11,108 DEBUG ** Creating instance of bean
'propsFileName' **
org.springframework.beans.factory.support.DefaultListableBeanFactory
2010-12-08 19:29:11,116 DEBUG ** Eagerly caching bean 'propsFileName' to
allow for resolving potential circular references **
org.springframework.beans.factory.support.DefaultListableBeanFactory
2010-12-08 19:29:11,158 DEBUG ** Invoking afterPropertiesSet() on bean
with name 'propsFileName' **
org.springframework.beans.factory.support.DefaultListableBeanFactory
2010-12-08 19:29:11,158 DEBUG ** Looking up JNDI object with name
[java:comp/env/propertiesFileName] **
org.springframework.jndi.JndiTemplate
2010-12-08 19:29:11,161 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.springframework.jndi.JndiObjectFactoryBean
2010-12-08 19:29:11,161 DEBUG ** Looking up JNDI object with name
[propertiesFileName] ** org.springframework.jndi.JndiTemplate
2010-12-08 19:29:11,164 INFO  ** Destroying singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@493
02473: defining beans
[propsFileName,org.springframework.beans.factory.config.PropertyPlacehol
derConfigure
2010-12-08 19:29:11,165 ERROR ** Context initialization failed **
org.springframework.web.context.ContextLoader

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Tuesday, 14 December 2010 9:46 a.m.
To: Tomcat Users List
Subject: Re: jndi-lookup fails, cured by tomcat restart

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dale,

On 12/13/2010 3:08 PM, Dale Ogilvie wrote:
> 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

Technically speaking, I think that's the default local environment, not
the global environment. You can define <Environment> entries at the
<Server> level in server.xml which would be truly "global". It's all
semantics for this discussion and shouldn't impact this case.

> <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' **

'propsFileName' != 'propertiesFileName'

Are you sure you're looking at the right configuration file?

> 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

Perhaps propsFileName is bound, but not propertiesFileName.

> 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.PropertyPlaceholderCon
> fi
> gurer">
>        <property name="location" ref="propsFileName"/>
>     </bean>

I don't see where the data is ultimately defined... I just see a bunch
of references that don't point to anything. propertiesFileName ->
propsFileName -> ???

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0GhfkACgkQ9CaO5/Lv0PB5OQCfa20jn6k8gt/jvp211sFgA+KZ
YRsAn3FFKu9rx2BidCKz64FKo+Vnb7LO
=HtIz
-----END PGP SIGNATURE-----

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


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


      

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


Mime
View raw message