问题描述
我有一段简单的代码实例化JBoss Hot Rod客户端,它部署在Jboss 7上的.ear文件中
I have a simple piece of code instantiating a JBoss Hot Rod client and this is deployed in an .ear file on Jboss 7
System.out.println("Attempting to RemoteCacheManager at: "+ipAddress);
Configuration conf = new
ConfigurationBuilder().addServer().host(ipAddress).port(11222).build();
RemoteCacheManager manager = new RemoteCacheManager(conf);
RemoteCache defaultCache = manager.getCache();
System.out.println("SUCCESS OUT: Connected to RemoteCacheManager at: "+ipAddress);
logger.info("SUCCESS: Connected to RemoteCacheManager at {}",ipAddress);
然而,当我部署应用程序时,它无法找到类/方法RemoteCacheManager
However when I deploy the app it cannot find the the class/method RemoteCacheManager
Caused by: java.lang.NoSuchMethodError: org.infinispan.client.hotrod.RemoteCacheManager.<init>(Lorg/infinispan/client/hotrod/configuration/Configuration;)V
我的应用程序有这样的结构
My App has a structure like this
--ear
---lib
---infinispan-client-hotrod-6.0.2-FINAL.jar
--- other .jars
---META-INF
---MANIFEST.MF
---myservice.jar
---mysrvice.war
这是因为我将最新的热棒客户端作为maven依赖项包含但是旧版本可用作模块。如何告诉Jboss在其模块中排除旧的实现
This is caused because I include the latest hot rod client as a maven dependency but an older version is available as a module. How can I tell Jboss to exclude the older implementation in its module
谢谢
推荐答案
这个案子的问题并不像我想的那样。问题是JBoss已经包含了旧版本的热棒作为模块,因此java.lang.NoSuchMethodError
the issue in this case was not as I thought. The issue was JBoss already included an older version of hot rod as a module and hence the "java.lang.NoSuchMethodError"
解决方案,排除模块并提供通过新的maven依赖的新实现是使用jboss-deployment-structure.xml。将此文件放在ear> src> main> META-INF> application
The solution, to exclude a module and provide a new implementation via new maven dependency is to use the jboss-deployment-structure.xml. Place this file in ear>src>main>META-INF>application
下面我要特别注意从主要部署和子部署中排除并将其留在这里用于说明目的。我稍后会删除一个条目...
I am being extra careful below by excluding from main deployment and subdeployment and left it here for illustration purposes. I will remove one entry later...
<?xml version="1.0"?>
<exclusions>
<module name="org.infinispan.client.hotrod"/>
</exclusions>
<sub-deployment name="myservice-ejb-1.0.1-SNAPSHOT.jar">
<!-- This corresponds to the module for a web deployment -->
<!-- it can use all the same tags as the <deployment> entry above -->
<exclusions>
<module name="org.infinispan.client.hotrod"/>
</exclusions>
</sub-deployment>
</deployment>
这篇关于JBoss 7类加载器 - 排除模块实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!