3 Replies Latest reply on Sep 6, 2015 8:41 PM by Alex Roberts

    How do I use a JNDI entry in my application running on WildFly?

    Alex Roberts Newbie

      I am trying to read a JNDI value in my web application using the WildFly naming subsystem, similar to what is in the https://docs.jboss.org/author/display/WFLY9/JNDI+Reference

      Here is the relevent section of my standalone.xml

       

      <subsystem xmlns="urn:jboss:domain:naming:2.0" >

           <bindings>

                <simple name="java:global/myId" value="ID001" type="java.lang.String" />

           </bindings>

           <remote-naming/>

      </subsystem>

       

      Here is the code I'm using to lookup the JNDI entry:

       

      @Resource(lookup = "java:global/myId")

      private String myId;

       

      When I deploy, the field myId doesn't get set and I get the following output on the console:

       

      17:18:43,115 INFO [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-1) Creating Service {http://example.com}MyAppService from class com.abc.MyAppPort
      17:18:43,428 INFO [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-1) Setting the server's publish address to be http://localhost:9080/MA/MyAppService
      17:18:43,443 FINE [org.apache.cxf.resource.DefaultResourceManager] (MSC service thread 1-1) resolving resource <com.example.impl.MyApp/myId> type <class java.lang.String>
      17:18:43,443 FINE [org.apache.cxf.resource.DefaultResourceManager] (MSC service thread 1-1) resolving resource <null> type <class java.lang.String>
      17:18:43,443 INFO [org.apache.cxf.common.injection.ResourceInjector] (MSC service thread 1-1) failed to resolve resource com.example.impl.MyApp/myId