Context
- You are building a Java web application with JMS.
- You have added a reference to JMS queue with
<res-ref-name>xxx/yyy/zzz</res-ref-name>inweb.xml. - You have changed the configuration file from
standalone.xmltostandalone-full.xmlto use JMS module. - You have added a JMS queue with
jboss-cli. - Now you are going to deploy the application to Wildfly with ActiveMQ.
Problem
- You will get the
WFLYCTL0412orWFLYCTL0180error when you deploy the application. It says that you could not findjboss.naming.context.java.jboss.resources.xxx.yyy.zzz. - The error will be not resolved when you add a JMS queue with following command in
jboss-cli:
jms-queue add --queue-address=xxx.yyy.zzz --entries=xxx/yyy/zzz
- You will get another error when you try to add a JMS queue
java:comp/env/xxx/yyy/zzzwith following command injboss-cli:
jms-queue add --queue-address=xxx.yyy.zzz --entries=java:comp/env/xxx/yyy/zzz
Reason
jboss.naming.context.java.jboss.resources.xxx.yyy.zzzin the error message correspond to a JNDI namejava:jboss/resources/xxx/yyy/zzz.java:comp/env/is ENC (Environment Naming Context). It is a naming convention to refer JNDI resources from web application. You cannot use ENC in application server settings (it does not tied to specific web application).
Solution
You can add a JMS queue corresponding to jboss.naming.context.java.jboss.resources.xxx.yyy.zzz with the following command in jboss-cli:
jms-queue add --queue-address=xxx.yyy.zzz --entries=java:jboss/resources/xxx/yyy/zzz
Note that xxx.yyy.zzz in --queue-address option is an arbitrary name of JMS queue. You can see this name in the result of /subsystem=naming:jndi-view.