1

I'm trying to get a <env-entry> entry I defnined in the web.xml of a war inside a .ear deployed application in Weblogic 12c :

<env-entry>
    <env-entry-name>java:app/test</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>1111111</env-entry-value>
</env-entry>

and, in my code :

Object test = InitialContext.doLookup("java:app/test");
System.out.println(test);

An exception is throwned :

javax.naming.NameNotFoundException: While trying to look up /app/test in /app/webapp/xxx/yyy/1243828215.; remaining name '/app/test'

Weblogic seems to modify something in the JNDI resolution process : "xxx/yyy" is the context-root of my application in Weblogic and "1243828215" is a random number!

Any idea how I can defined the <env-entry> entries so they can be retrieved using InitialContext.doLookup()?

electrotype
  • 8,342
  • 11
  • 59
  • 96
  • 1
    What happens when you use `app/test` `InitialContext.doLookup("app/test");` I do not think you need to pre-pend `java:` as that is already done for you automatically by the container – Display Name is missing Nov 05 '14 at 19:53
  • Sadly : `javax.naming.NameNotFoundException: While trying to lookup 'app.test' didn't find subcontext 'app'. Resolved ''; remaining name 'app/test'"` – electrotype Nov 05 '14 at 20:56

1 Answers1

-1

Try this:

@Resource(name = "java:app/test")
private String test;