jedis报LinkageError错误:javax/management/MBeanServer


使用jedis客户端时,遇到下面异常信息:

Horrible Exception: java.lang.LinkageError: loading constraint violation: loader "com/ibm/ws/classloader/CompoundClassLoader@6a36fae" previously initiated loading for a different type with name "javax/management/MBeanServer" defined by loader "com/ibm/oti/vm/BootstrapClassLoader@7853887"
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:262)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:69)
at com.ibm.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:829)
at com.ibm.ws.classloader.CompoundClassLoader.localFindClass(CompoundClassLoader.java:744)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:585)
at java.lang.ClassLoader.loadClass(ClassLoader.java:627)
at org.apache.commons.pool2.impl.BaseGenericObjectPool.jmxRegister(BaseGenericObjectPool.java:947)
at org.apache.commons.pool2.impl.BaseGenericObjectPool.(BaseGenericObjectPool.java:132)
at org.apache.commons.pool2.impl.GenericObjectPool.(GenericObjectPool.java:107)
at redis.clients.util.Pool.initPool(Pool.java:43)
at redis.clients.util.Pool.(Pool.java:31)
at redis.clients.jedis.JedisPool.(JedisPool.java:80)
at redis.clients.jedis.JedisClusterInfoCache.setNodeIfNotExist(JedisClusterInfoCache.java:107)
at redis.clients.jedis.JedisClusterInfoCache.discoverClusterNodesAndSlots(JedisClusterInfoCache.java:54)
at redis.clients.jedis.JedisClusterConnectionHandler.initializeSlotsCache(JedisClusterConnectionHandler.java:39)
at redis.clients.jedis.JedisClusterConnectionHandler.(JedisClusterConnectionHandler.java:28)
at redis.clients.jedis.JedisSlotBasedConnectionHandler.(JedisSlotBasedConnectionHandler.java:21)
at redis.clients.jedis.JedisSlotBasedConnectionHandler.(JedisSlotBasedConnectionHandler.java:16)
at redis.clients.jedis.BinaryJedisCluster.(BinaryJedisCluster.java:39)
at redis.clients.jedis.JedisCluster.(JedisCluster.java:45)
at redis.clients.jedis.JedisCluster.(JedisCluster.java:32)
at com.hc360.redis.util.RedisConnection.createCluster(RedisConnection.java:65)
at com.hc360.redis.RedisClusterClient.(RedisClusterClient.java:26)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:233)
at com.hc360.my.modules.screens.corcenter.company.morelogin.doBuildTemplate(morelogin.java:104)
at com.hc360.my.common.secure.MyLogSecureScreen.doBuildTemplate(MyLogSecureScreen.java:64)
at org.apache.turbine.modules.screens.TemplateScreen.doBuild(TemplateScreen.java:100)
at org.apache.turbine.modules.Screen.build(Screen.java:57)
at org.apache.turbine.modules.ScreenLoader.eval(ScreenLoader.java:107)
at org.apache.turbine.modules.layouts.VelocityOnlyLayout.doBuild(VelocityOnlyLayout.java:93)
at org.apache.turbine.modules.Layout.build(Layout.java:53)
at org.apache.turbine.modules.LayoutLoader.exec(LayoutLoader.java:101)
at org.apache.turbine.modules.pages.DefaultPage.doBuild(DefaultPage.java:146)
at org.apache.turbine.modules.Page.build(Page.java:53)
at org.apache.turbine.modules.PageLoader.exec(PageLoader.java:101)
at org.apache.turbine.Turbine.doGet(Turbine.java:799)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1214)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:92)
at com.hc360.waf.filter.WafFilter.doFilter(WafFilter.java:87)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.hc360.security.authz.SecurityFilter.doFilter(SecurityFilter.java:161)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.hc360.my.common.filter.ScriptFilter.doFilter(ScriptFilter.java:58)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.hc360.my.common.filter.InjectRefuseFilter.doFilter(InjectRefuseFilter.java:58)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.hc360.mmt.j2ee.conf.PersistenceSessionFilter.doFilter(PersistenceSessionFilter.java:73)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.hc360.sso.client.SSOFilter.doFilter(SSOFilter.java:674)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.hc360.my.common.filter.CharSetFilter.doFilter(CharSetFilter.java:42)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:926)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1023)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.proce***equest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)


工程部署在websphere中,很明显类加载冲突:

Horrible Exception: java.lang.LinkageError: loading constraint violation: loader "com/ibm/ws/classloader/CompoundClassLoader@6a36fae" previously initiated loading for a different type with name "javax/management/MBeanServer" defined by loader "com/ibm/oti/vm/BootstrapClassLoader@7853887"


在工程中搜索javax/management/MBeanServer,发现在jdk的rt.jar包中和jboss-jmx.jar中出现了相同的类;


想不明白为什么jboss-jmx.jar中会出现跟jdk同样的类,但都在使用,也不能添加一个功能而牺牲别的功能;

有一个疑问,以前工程中就存在这个包了,为什么没有报错呢?而现在咋就报了呢?


猜测以前没有使用到该类!


那无疑jedis中使用到了该类javax/management/MBeanServer,显然这个类是jmx的,在使用redis中,我也不需要这个功能,是否可以去掉呢?

查看源码发现,JedisCluster创建实例时,可以传递配置信息,配置信息中可以设置是否使用jmx,只要设为false即可:

GenericObjectPoolConfig copc = new GenericObjectPoolConfig();
copc.setJmxEnabled(false);
jedisCluster = new JedisCluster(clusterNodes,3000,1000,copc);