java:comp/env in JBoss EAP 6 / 7

Solution Verified - Updated -

Issue

  • In older version the comp/env used to work, how do I setup java:comp/env/jdbc/ExampleDS for my application to use the datasource java:jboss/datasources/ExampleDS defined in the JBoss EAP 6 standalone.xml ?

  • While migrating to JBoss EAP 6.2 the application fails when trying to use a datasource.
    The logfile of the application shows then the following error:

16:50:31,858 ERROR [dbRequest] (pool-4-thread-1) javax.naming.NameNotFoundException: java:comp/env
at org.jboss.as.naming.InitialContext.findContext(InitialContext.java:198)
at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:118)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:183)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
.
.
  • So below are some questions:
    • a) if java:comp/env is still available, why I get a NameNotFoundException when I use Context context = (Context)initialContext.lookup("java:comp/env");?
      Do I have to change something in the standalone.xml?
    • b) if java:comp/env isn't supported any longer, where can I find an official statement, that it isn't any longer?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.x
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.