IBM Support

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

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.

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Java Message Service (JMS)","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF012","label":"IBM i"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"},{"code":"PF035","label":"z\/OS"}],"Version":"9.0;8.5.5;8.0;7.0","Edition":"Base;Network Deployment","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SSNVBF","label":"Runtimes for Java Technology"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Java SDK","Platform":[{"code":"","label":""}],"Version":"","Edition":"","Line of Business":{"code":"LOB36","label":"IBM Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21114239