[alibaba/fastjson]1.2.37版本开始增加的SPI:AutoDiscoverable,weblogic部署冲突问题

2024-08-30 765 views
1

系统使用了CXF组件、Fastjson组件(1.2.34).并部署在weblogic上版本为12.2.1.3.0

近期修复oday漏洞,升级fastjson组件到1.2.58时发现如下错误

MultiException stack 1 of 2
java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "com.alibaba.fastjson.support.jaxrs.FastJsonAutoDiscoverable.configure(Ljavax/ws/rs/core/FeatureContext;)V" the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) of the current class, com/alibaba/fastjson/support/jaxrs/FastJsonAutoDiscoverable, and the class loader (instance of com/oracle/classloader/weblogic/LaunchClassLoader) for interface org/glassfish/jersey/internal/spi/AutoDiscoverable have different Class objects for the type javax/ws/rs/core/FeatureContext used in the signature
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
    at java.lang.Class.getDeclaredConstructors(Class.java:2020)
    at org.jvnet.hk2.internal.Utilities$3.run(Utilities.java:1378)
    at org.jvnet.hk2.internal.Utilities$3.run(Utilities.java:1374)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.jvnet.hk2.internal.Utilities.getAllConstructors(Utilities.java:1374)
    at org.jvnet.hk2.internal.Utilities.findProducerConstructor(Utilities.java:1317)
    at org.jvnet.hk2.internal.DefaultClassAnalyzer.getConstructor(DefaultClassAnalyzer.java:83)
    at org.glassfish.jersey.internal.inject.JerseyClassAnalyzer.getConstructor(JerseyClassAnalyzer.java:144)
    at org.jvnet.hk2.internal.Utilities.getConstructor(Utilities.java:180)
    at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:129)
    at org.jvnet.hk2.internal.ClazzCreator.initialize(ClazzCreator.java:180)
    at org.jvnet.hk2.internal.SystemDescriptor.internalReify(SystemDescriptor.java:740)
    at org.jvnet.hk2.internal.SystemDescriptor.reify(SystemDescriptor.java:694)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor(ServiceLocatorImpl.java:464)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.narrow(ServiceLocatorImpl.java:2310)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.access$1200(ServiceLocatorImpl.java:128)
    at org.jvnet.hk2.internal.ServiceLocatorImpl$9.compute(ServiceLocatorImpl.java:1395)
    at org.jvnet.hk2.internal.ServiceLocatorImpl$9.compute(ServiceLocatorImpl.java:1390)
    at org.glassfish.hk2.utilities.cache.internal.WeakCARCacheImpl.compute(WeakCARCacheImpl.java:116)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetAllServiceHandles(ServiceLocatorImpl.java:1452)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServiceHandles(ServiceLocatorImpl.java:1377)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServiceHandles(ServiceLocatorImpl.java:1366)
    at org.glassfish.jersey.internal.inject.Providers.getServiceHandles(Providers.java:354)
    at org.glassfish.jersey.internal.inject.Providers.getProviders(Providers.java:187)
    at org.glassfish.jersey.model.internal.CommonConfig.configureAutoDiscoverableProviders(CommonConfig.java:616)
    at org.glassfish.jersey.server.ResourceConfig.configureAutoDiscoverableProviders(ResourceConfig.java:811)
    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:447)
    at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184)
    at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
    at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
    at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:347)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
MultiException stack 2 of 2
java.lang.IllegalArgumentException: Errors were discovered while reifying SystemDescriptor(
    implementation=com.alibaba.fastjson.support.jaxrs.FastJsonAutoDiscoverable
    contracts={org.glassfish.jersey.internal.spi.AutoDiscoverable}
    scope=org.glassfish.hk2.api.PerLookup
    qualifiers={}
    descriptorType=CLASS
    descriptorVisibility=NORMAL
    metadata=
    rank=0
    loader=org.glassfish.hk2.utilities.binding.AbstractBinder$2@2240c2bd
    proxiable=null
    proxyForSameScope=null
    analysisName=null
    id=80
    locatorId=3
    identityHashCode=841721784
    reified=false)
    at org.jvnet.hk2.internal.SystemDescriptor.reify(SystemDescriptor.java:705)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.reifyDescriptor(ServiceLocatorImpl.java:464)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.narrow(ServiceLocatorImpl.java:2310)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.access$1200(ServiceLocatorImpl.java:128)
    at org.jvnet.hk2.internal.ServiceLocatorImpl$9.compute(ServiceLocatorImpl.java:1395)
    at org.jvnet.hk2.internal.ServiceLocatorImpl$9.compute(ServiceLocatorImpl.java:1390)
    at org.glassfish.hk2.utilities.cache.internal.WeakCARCacheImpl.compute(WeakCARCacheImpl.java:116)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetAllServiceHandles(ServiceLocatorImpl.java:1452)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServiceHandles(ServiceLocatorImpl.java:1377)
    at org.jvnet.hk2.internal.ServiceLocatorImpl.getAllServiceHandles(ServiceLocatorImpl.java:1366)
    at org.glassfish.jersey.internal.inject.Providers.getServiceHandles(Providers.java:354)
    at org.glassfish.jersey.internal.inject.Providers.getProviders(Providers.java:187)
    at org.glassfish.jersey.model.internal.CommonConfig.configureAutoDiscoverableProviders(CommonConfig.java:616)

经分析,fastjson在1.2.37开始增加了spi

org.glassfish.jersey.internal.spi.AutoDiscoverable:com.alibaba.fastjson.support.jaxrs.FastJsonAutoDiscoverable

开启此spi时会导致cxf、weblogic、fastjson组件冲突,是否可默认不开启此spi,由使用jersey的应用自行开启。

回答

2

遇到相同的问题了,赞同把这个功能去掉,jersey本来是用fastxml反序列化,现在自动加spi反倒报错了!!!

5

请问怎么解决的?

5

启动参数增加 -Dfastjson.auto.discoverable=false 或者fastjson.properties配置文件增加fastjson.auto.discoverable=false禁用