IBM Support

"javax.jms.IllegalStateException: Method setMessageListener not permitted" in a Java Enterprise Edition (J2EE) application

Technote (troubleshooting)


Problem(Abstract)

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.


Cross reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK

Document information

More support for: WebSphere Application Server
Java Message Service (JMS)

Software version: 7.0, 8.0, 8.5.5, 9.0

Operating system(s): AIX, HP-UX, IBM i, Linux, Solaris, Windows, z/OS

Software edition: Base, Network Deployment

Reference #: 1114239

Modified date: 17 September 2007


Translate this page: