You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sascha Rodekamp <sa...@googlemail.com> on 2012/02/14 08:12:22 UTC

JNDI Access in Lifecycle Listener

Hi,
i load a spring xml with my own lifecycle listener. Which works pretty
well actually.
In my spring xml i try to get a datasource from the JNDI context. I
put the definition in the server.xml under <GlobalNamingResources>.
My lifecycle listener is loaded after the GlobalResourcesLifecycleListener

During the startup catalina.out tells me:
      javax.naming.NameNotFoundException: Name java:comp is not bound
in this Context

My first idea was, that the JNDI context is not published when loading
the spring xml file, so i tried to add a specific environment to the
spring lookup
		<jee:environment>
 			java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory
			java.naming.provider.url=file:${catalina.base}/conf/server.xml
			java.naming.factory.url.pkgs=org.apache.naming
		</jee:environment>

That doesn't help.

Can someone tell me how to access the context in this early state of loading.

Best Regards,
Sascha Rodekamp

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


Re: JNDI Access in Lifecycle Listener

Posted by Sascha Rodekamp <sa...@googlemail.com>.
Hey,
thanks for the reply. I found a solution.

The issue was, that i load my spring xml during the INIT lifecycle
event. In this state the jndi context isn't available. I moved my code
to the START event and it works as expected.

Regards
Sascha

2012/2/14 chris derham <ch...@derham.me.uk>:
>>
>> i load a spring xml with my own lifecycle listener. Which works pretty
>> well actually.
>> In my spring xml i try to get a datasource from the JNDI context. I
>> put the definition in the server.xml under <GlobalNamingResources>.
>> My lifecycle listener is loaded after the GlobalResourcesLifecycleListener
>>
>> During the startup catalina.out tells me:
>>      javax.naming.NameNotFoundException: Name java:comp is not bound
>> in this Context
>>
>> My first idea was, that the JNDI context is not published when loading
>> the spring xml file, so i tried to add a specific environment to the
>> spring lookup
>>                <jee:environment>
>>
>>  java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory
>>
>>  java.naming.provider.url=file:${catalina.base}/conf/server.xml
>>                        java.naming.factory.url.pkgs=org.apache.naming
>>                </jee:environment>
>>
>> That doesn't help.
>>
>> Can someone tell me how to access the context in this early state of
>> loading.
>>
>> Please provide the configuration of the jndi lookup in spring.xml and the
> tomcat jndi configuration. Version details of java/tomcat/spring may also
> help
>
> Thanks
>
> Chris



-- 

Sascha Rodekamp
    Visit the new german OFBiz Blog: http://www.ofbiz.biz
    Lynx-Consulting GmbH
    Johanniskirchplatz 6
    D-33615 Bielefeld
    http://www.lynx.de

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


Re: JNDI Access in Lifecycle Listener

Posted by chris derham <ch...@derham.me.uk>.
>
> i load a spring xml with my own lifecycle listener. Which works pretty
> well actually.
> In my spring xml i try to get a datasource from the JNDI context. I
> put the definition in the server.xml under <GlobalNamingResources>.
> My lifecycle listener is loaded after the GlobalResourcesLifecycleListener
>
> During the startup catalina.out tells me:
>      javax.naming.NameNotFoundException: Name java:comp is not bound
> in this Context
>
> My first idea was, that the JNDI context is not published when loading
> the spring xml file, so i tried to add a specific environment to the
> spring lookup
>                <jee:environment>
>
>  java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory
>
>  java.naming.provider.url=file:${catalina.base}/conf/server.xml
>                        java.naming.factory.url.pkgs=org.apache.naming
>                </jee:environment>
>
> That doesn't help.
>
> Can someone tell me how to access the context in this early state of
> loading.
>
> Please provide the configuration of the jndi lookup in spring.xml and the
tomcat jndi configuration. Version details of java/tomcat/spring may also
help

Thanks

Chris