Hi,
I am currently working on PAXWEB-630 (interpret and use the
tomcat-server.xml). One of the entities that can be configured are
GlobalNamingResources. With my changes, I can see the configured options in
the MBean tree, but when I tried to test them in an integration test it did
not work. On further investigation I also did not manage to reference JNDI
resources configured in the web.xml, neither with the tomcat container nor
with the web container. I also tried a life karaf container, but this also
did not work.
What I did:
1. I added the following coding to the web.xml of the servlet war:
<env-entry>
<env-entry-name>envEntryName</env-entry-name>
<env-entry-value>envEntryValue</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
2. I added the following coding to my servlet coding:
Context env = (Context)new
InitialContext().lookup("java:comp/env");
String value = (String)env.lookup("envEntryName");
In the integration test and on the normal karaf instance, i received the
following error:
javax.naming.NoInitialContextException: Need to specify class name in
environment or system property, or as an applet parameter, or in an
application resource file: java.naming.factory.initial
at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)[:1.8.0_121]
at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)[:1.8.0_121]
at
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:350)[:1.8.0_121]
at
javax.naming.InitialContext.lookup(InitialContext.java:417)[:1.8.0_121]
If I add the JNDI feature into the karaf installation, I got the following
error:
javax.naming.NotContextException: java:comp/env
at
org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:165)[85:org.apache.xbean.naming:3.18.0]
at
org.apache.xbean.naming.context.AbstractContext.lookup(AbstractContext.java:605)[85:org.apache.xbean.naming:3.18.0]
at
org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)[30:org.apache.aries.jndi.core:1.0.2]
at
javax.naming.InitialContext.lookup(InitialContext.java:417)[:1.8.0_121]
These errors were independent from whether I was using tomcat or jetty as
the web container.
If I deploy the same servlet into a plain tomcat container, the lookup will
work (and return envEntryValue) as the result.
So the aries-jndi stuff seems to do something, but the context defined in
the web.xml are not honored.
Has anybody managed to get JNDI lookups from the web container environment
running with pax-web? Is there something I missed there? I could not find
any context lookups anywhere in the Pax-Web coding (including the tests).
Is it possible that this feature is not available at all?
Best regards
Stephan
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.