2 Replies Latest reply on Jun 10, 2014 3:56 AM by jaikiran

    Exception in Datasource init: java:comp/env

    ketanparihar

      HI,

       

      I am trying to do lookup using my InitialContext object which looks like this. initialContext = (Context) initialContext.lookup("java:comp/env");

      But i am getting an NameNotFoundException. The jndi name in my datasource file is "java :/<app-name>" and res-ref is jdbc/<app-name> in jboss-web.xml and web.xml.

      I am using Jboss EAP 6.2

      Could you help me resolving the issue.

      Thanks in advance.

        • 1. Re: Exception in Datasource init: java:comp/env
          jaikiran

          A better way to getting someone to help is by posting all relevant details including the snippets of the configuration files and the entire exception stacktrace and the relevant snippet of code.

          • 2. Re: Exception in Datasource init: java:comp/env
            jaikiran

            Like I suspected, you are doing the lookup of java:comp namespace from a random thread. That won't work. The java:comp (like some other namespaces) is a special namespace of the managed component. It is accessible only from the component to which it belongs. For example, if you are configuring the java:comp of a web module, then the servlets within that web module can access it.