简体   繁体   English

在 Websphere 8.5 上使用 JMS 时出现 NoSuchMethodError 错误

[英]NoSuchMethodError error when using JMS on Websphere 8.5

I have a Java application which is deployed on Websphere 8.5.我有一个部署在 Websphere 8.5 上的 Java 应用程序。 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()它收到一条我正在尝试使用它的消息,但这是我得到的错误,即使我在 getBody() 线上有正确的 JMS jars
Code Snippet:代码片段:

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

Jar Files: Jar 文件:

<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: Websphere 日志中的错误:

  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 : Websphere 类加载
强文本

Any ideas why my application, which compiles fine as it sees javax.jms.Message in the code but the Websphere can't find this?任何想法为什么我的应用程序编译良好,因为它在代码中看到javax.jms.Message但 Websphere 找不到它?

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. WebSphere Application Server 8.5.5 支持 Java EE 6,其中包括 JMS 1.1,而不是 JMS 2.0,并且 getBody(Class) 方法是在 Java EE 7 和更新版本的 JMS 2.0 中添加的。

If you want to use JMS 2.0 then you need to upgrade to WebSphere Application Server 9.0.如果您想使用 JMS 2.0,那么您需要升级到 WebSphere Application Server 9.0。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM