Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

How to add a JMS queue corresponding to jboss.naming.context.java.jboss.resources.xxx.yyy.zzz with jboss-cli

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> in web.xml.
  • You have changed the configuration file from standalone.xml to standalone-full.xml to 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 WFLYCTL0412 or WFLYCTL0180 error when you deploy the application. It says that you could not find jboss.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/zzz with following command in jboss-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.zzz in the error message correspond to a JNDI name java: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.