Troubleshooting
Problem
Application receives message javax.jms.IllegalStateException: Method setMessageListener not permitted when running inside IBM® WebSphere® Application Server EJB or Web container.
Cause
It is forbidden to use the method setMessageListener for asynchronous messaging in a WebSphere Application Server EJB or Web container application due a restriction by the Java EE Specification. The Java EE Specification lists a number of interfaces that may not be used by "portable Java EE applications". It also lists a number of methods that may be used in "the application client container" but not in the EJB nor Web container. This is listed in section EE.6.7 Java™ Message Service (JMS) 1.1 Requirements of the Java EE 6 Specification (JSR 316)
One of the methods listed in the list of methods forbidden from the EJB and Web containers is the method
- javax.jms.Session method setMessageListener
For the complete list of methods, see the Java EE 6 Specification.
Resolving The Problem
Refer to the WebSphere Application Server Knowledge Center article Programming to use asynchronous messaging, which includes the Java EE based programming models, such as Message Driven Beans and also includes links for developing JMS Client applications which can call setMessageListener since they run outside of a WebSphere EJB or Web container.
Also refer to article Designing an enterprise application to use JMS which includes the same setMessageListener restriction information.
Was this topic helpful?
Document Information
Modified date:
15 June 2018
UID
swg21114239