title: Why do I need "java:/" prefix for @Resource injection in Wildfly 12?
body: <p>Starting with a running EAR on Weblogic 12 I need to get this app working with Wildfly 12, too.</p>
  
  <p>We've got some JMS queues which we inject like this on Weblogic:</p>
  
  <pre><code>@Resource(lookup = "jms/Queues/MYQUEUE")
  private Queue destination;
  
  @Resource(lookup = "jms/QueueConnectionFactories/MYQUEUECF")
  private QueueConnectionFactory connectionFactory;
  </code></pre>
  
  <p>With Wildfly I defined the queue in standalone-full.xml</p>
  
  <pre><code>&lt;jms-queue name="MYQUEUE" entries="jms/Queues/MYQUEUE" durable="true"/&gt;
  &lt;connection-factory name="MYQUEUECF" entries="jms/QueueConnectionFactories/MYQUEUECF" connectors="in-vm"/&gt;
  </code></pre>
  
  <p>But injection fails on server startup. </p>
  
  <pre><code>service jboss.naming.context.java.comp.XXX.ejb.JMSMessageProducer.env.jms.Queues.MYQUEUE (missing) dependents: [service jboss.naming.context.java.comp.XXX.ejb.JMSMessageProducer.env."com.xxx.webservices.components.communication.ejb.JMSMessageProducerBean".destination] [[...]
  </code></pre>
  
  <p>To fix this, I need to use</p>
  
  <pre><code>@Resource(lookup = "java:/jms/Queues/MYQUEUE")
  private Queue destination;
  </code></pre>
  
  <p>Without the "java:/" prefix, injection won't work. </p>
  
  <p>Unfortunately this does not work with Weblogic (which is the leading/productive system).</p>
  
  <p>Since I cannot change the weblogic configuration I have to make my Wildfly config compatible with it or change injection code so it works on both app servers.</p>
  
  <p>Why does Wildfly need this prefix in the @Resource annotation to get the injection right?</p>
  
  <p>Is there a way to change its config so the code works without the "java:/" prefix?</p>
  
  <p>Thanks in advance ;-)</p>
  
  <p>Mark.</p>
  
  <p>PS: When I remove the @Resource annotations and do a context lookup, it succeeds without the "java:/" - strange ;-)</p>