-
1. Problem with environment entries in application.xml
ebross Feb 27, 2011 7:08 AM (in response to marcusportmann)Hi Marcus,
Use of "<env-entry>" in application.xml is rare to find, but are you not missing the "lookup-name" entry?
Cheers.
-
2. Problem with environment entries in application.xml
marcusportmann Feb 27, 2011 9:18 AM (in response to ebross)Hi Benjamin,
I have tried again with the following but none of the entries are being added to the JNDI.
<env-entry>
<env-entry-name>java:app/TestValueApp</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>Hello World!</env-entry-value>
<lookup-name>java:app/TestValueApp</lookup-name>
</env-entry>
<env-entry>
<env-entry-name>java:app/env/TestValueAppEnv</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>Hello World!</env-entry-value>
<lookup-name>java:app/env/TestValueAppEnv</lookup-name>
</env-entry>
<env-entry>
<env-entry-name>java:global/TestValueGlobal</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>Hello World!</env-entry-value>
<lookup-name>java:global/TestValueGlobal</lookup-name>
</env-entry>
<env-entry>
<env-entry-name>java:global/env/TestValueGlobalEnv</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>Hello World!</env-entry-value>
<lookup-name>java:global/env/TestValueGlobalEnv</lookup-name>
</env-entry>
Regards,
Marcus
-
3. Re: Problem with environment entries in application.xml
ebross Feb 27, 2011 11:56 AM (in response to marcusportmann)Hi Marcus,
Have you tried either [A] or [B] below:
<env-entry>
<env-entry-name>java:app/env/TestValueApp</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>Hello World!</env-entry-value>
</env-entry>
[A]
String valueApp = (String)InitialContext.doLookup("java:app/env/TestValueApp");
[B]
@Resource(name="java:app/env/TestValueApp")
private String valueApp;
Cheers
-
4. Problem with environment entries in application.xml
mp911de Feb 27, 2011 10:28 AM (in response to marcusportmann)Hi Marcus,
according to Sun/Oracle specs following Example should create an Entry that can be looked up with "java:comp/env/greetings"
<env-entry>
<description>welcome message</description>
<env-entry-name>greetings</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>Welcome to the Inventory Control
System</env-entry-value>
</env-entry>
In case that JBoss really does not add any Entries, check whether JBoss' processes/ignores your application.xml
See http://java.sun.com/developer/technicalArticles/xml/WebAppDev4/ for further Information.
Best regards,
Mark
-
5. Re: Problem with environment entries in application.xml
marcusportmann Feb 27, 2011 4:39 PM (in response to ebross)Hi Benjamin,
When trying option [A] I get a NameNotFoundException on the (env) component of the name.
When trying option [B] the value for the valueApp variable is null. This occurs when I use option [B] in a ServletContextListener and in a HttpServlet.
If I move the env-entry declaration to the web.xml file then option [A] works both in a ServletContextListener and in a HttpServlet but option [B] is still null in both instances.
Regards,
Marcus
-
6. Re: Problem with environment entries in application.xml
marcusportmann Feb 27, 2011 4:47 PM (in response to mp911de)Hi Mark,
I have tested your example, i.e. dropping the java:app prefix (using greetings as the env-entry-name), and what I found is that I get a NameNotFoundException when the env-entry is in the application.xml file but if I move it to the web.xml file then the InitialContext.doLookup approach works perfectly using the name (java:comp/env/greetings).
It appears as if the env-entry entries in the application.xml file are being ignored.
Regards,
Marcus
-
7. Re: Problem with environment entries in application.xml
marcusportmann Feb 27, 2011 5:20 PM (in response to ebross)Hi Benjamin,
I have done a bit more testing and I think I have discovered the reason why the @Resource annotation is not being correctly processed for my ServletContextListener and HttpServlet.
It is not related to whether the env-entry is declared in the application.xml or web.xml. Instead it seems to be as a result of my context listener and servlet being declared in another JAR which is included in my WAR. The servlets that form part of my WAR (under WEB-INF/classes) are being injected correctly when using the @Resource annotation. By correctly I mean that the injection works when then env-entry is declared in the web.xml file but I get a "NOT FOUND Depends" error when the env-entry is declared in the application.xml file.
Not sure whether I should open another discussion related to injection not working on web resources included from other JARs but referenced from the web.xml in a WAR.
Regards,
Marcus
-
8. Problem with environment entries in application.xml
jaikiran Mar 1, 2011 2:07 AM (in response to marcusportmann)Resource references and environment entries processing in application.xml isn't handled correctly in AS6. So yes this is a bug. I think there was a JIRA for this issue somewhere but I can't seem to locate it. Can you please create a JIRA here https://issues.jboss.org/browse/JBAS?