james2611nov
james2611nov

Reputation: 473

NoSuchMethodError error when using JMS on Websphere 8.5

I have a Java application which is deployed on Websphere 8.5. It gets a message which I am trying to use it but this is the error I get even though I have the right JMS jars on line getBody()
Code Snippet:

if (arg0 instanceof BytesMessage)
{
    byte[] payload = arg0.getBody(byte[].class);
    myMessage = new String(payload);
}    

Jar Files:

<dependency>
   <groupId>javax.jms</groupId>
   <artifactId>javax.jms-api</artifactId>
   <version>2.0.1</version>
   <scope>compile</scope>
</dependency>
<dependency>
   <groupId>javax</groupId>
   <artifactId>javaee-api</artifactId>
   <version>6.0</version>
   <scope>provided</scope>
</dependency>

Error from Websphere logs:

  Caused by: java.lang.NoSuchMethodError: javax/jms/Message.getBody(Ljava/lang/Class;)Ljava/lang/Object; (loaded from file:/opt/was_static/websphere_8.5.5.15.1/appserver/plugins/javax.j2ee.jms.jar by org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@6d5d04f3) called from class com.mycompany.myapplication.sync.mdb.myapplicationSyncOutboundMDB (loaded from file:/opt/was_static/profiles/appsrv01/installedApps/eaodr01Cell01/myapplication-ear-mydomain.com-editionmyapplication-ear-0.9.6.ear/myapplication-ejb-0.9.6.jar by 
com.ibm.ws.classloader.CompoundClassLoader@19abf904[app:myapplication-ear-mydomain.com-editionmyapplication-ear-0.9.6]
   Local ClassPath: 
   Parent: com.ibm.ws.classloader.ExtJarClassLoader@890f8480[PF][server:0]
   Delegation Mode: PARENT_FIRST)  

Websphere CLassloading:
strong text

Any ideas why my application, which compiles fine as it sees javax.jms.Message in the code but the Websphere can't find this?

Upvotes: 0

Views: 1103

Answers (1)

Alasdair
Alasdair

Reputation: 3176

WebSphere Application Server 8.5.5 supports Java EE 6 which includes JMS 1.1, not JMS 2.0 and the getBody(Class) method was added in JMS 2.0 which is Java EE 7 and newer.

If you want to use JMS 2.0 then you need to upgrade to WebSphere Application Server 9.0.

Upvotes: 1

Related Questions