java.lang.LinkageError:加载程序约束冲突:加载程序以前为名为“的其他类型启动加载;org/json/JSONObject“;

java.lang.LinkageError:加载程序约束冲突:加载程序以前为名为“的其他类型启动加载;org/json/JSONObject“;,java,json,apache-karaf,apache-servicemix,Java,Json,Apache Karaf,Apache Servicemix,当我用maven在本地构建代码时,我没有错误 但当我在karaf ServiceMix上升级代码时,我的包仍然处于“失败”状态 错误堆栈: karaf@root>Exception in thread "SpringOsgiExtenderThread-83" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logService': FactoryBean thr

当我用maven在本地构建代码时,我没有错误
但当我在karaf ServiceMix上升级代码时,我的包仍然处于“失败”状态

错误堆栈:

karaf@root>Exception in thread "SpringOsgiExtenderThread-83" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logService': FactoryBean threw exception on object creation; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of org/springframework/osgi/context/internal/classloader/ChainedClassLoader) previously initiated loading for a different type with name "org/json/JSONObject"
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:173)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1467)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:632)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
    at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
    at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/springframework/osgi/context/internal/classloader/ChainedClassLoader) previously initiated loading for a different type with name "org/json/JSONObject"
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at com.sun.proxy.$Proxy285.<clinit>(Unknown Source)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:739)
    at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:119)
    at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:109)
    at org.springframework.osgi.service.util.internal.aop.ProxyUtils$1.run(ProxyUtils.java:65)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.osgi.service.util.internal.aop.ProxyUtils.createProxy(ProxyUtils.java:62)
    at org.springframework.osgi.service.util.internal.aop.ProxyUtils.createProxy(ProxyUtils.java:39)
    at org.springframework.osgi.service.importer.support.AbstractServiceProxyCreator.createServiceProxy(AbstractServiceProxyCreator.java:107)
    at org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean.createProxy(OsgiServiceProxyFactoryBean.java:206)
    at org.springframework.osgi.service.importer.support.AbstractServiceImporterProxyFactoryBean.getObject(AbstractServiceImporterProxyFactoryBean.java:86)
    at org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean.getObject(OsgiServiceProxyFactoryBean.java:161)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:166)
    ... 12 more
karaf@root>线程“SpringOsgiExtenderThread-83”org.springframework.beans.factory.BeanCreationException中出现异常:创建名为“logService”的bean时出错:FactoryBean在创建对象时引发异常;嵌套的异常是java.lang.LinkageError:加载程序约束冲突:加载程序(org/springframework/osgi/context/internal/classloader/ChainedClassLoader的实例)以前为名为“org/json/JSONObject”的不同类型启动加载
位于org.springframework.beans.factory.support.FactoryBeanRegistrySupport.dogetObject fromFactoryBean(FactoryBeanRegistrySupport.java:173)
位于org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
位于org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1467)
位于org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246)
位于org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
位于org.springframework.beans.factory.support.DefaultListableBeanFactory.PreInstanceSingleton(DefaultListableBeanFactory.java:632)
位于org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
位于org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
位于org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
位于org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
位于org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.CompleteFresh(AbstractDelegatedExecutionApplicationContext.java:320)
位于org.springframework.osgi.extender.internal.dependencietraApplicationContextExecutor$CompleteRefreshTask.run(dependencyWaiteraApplicationContextExecutor.java:132)
运行(Thread.java:745)
原因:java.lang.LinkageError:loader约束冲突:loader(org/springframework/osgi/context/internal/classloader/ChainedClassLoader的实例)先前启动了名为“org/json/JSONObject”的其他类型的加载
位于java.lang.Class.forName0(本机方法)
位于java.lang.Class.forName(Class.java:264)
在com.sun.proxy.$Proxy285(未知来源)
位于sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)
位于sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
位于java.lang.reflect.Constructor.newInstance(Constructor.java:423)
位于java.lang.reflect.Proxy.newProxyInstance(Proxy.java:739)
位于org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:119)
位于org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:109)
位于org.springframework.osgi.service.util.internal.aop.ProxyUtils$1.run(ProxyUtils.java:65)
位于java.security.AccessController.doPrivileged(本机方法)
位于org.springframework.osgi.service.util.internal.aop.ProxyUtils.createProxy(ProxyUtils.java:62)
位于org.springframework.osgi.service.util.internal.aop.ProxyUtils.createProxy(ProxyUtils.java:39)
位于org.springframework.osgi.service.importer.support.AbstractServiceProxyCreator.createServiceProxy(AbstractServiceProxyCreator.java:107)
位于org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean.createProxy(OsgiServiceProxyFactoryBean.java:206)
位于org.springframework.osgi.service.importer.support.AbstractServiceImporterProxyFactoryBean.getObject(AbstractServiceImporterProxyFactoryBean.java:86)
位于org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean.getObject(OsgiServiceProxyFactoryBean.java:161)
位于org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:166)
... 还有12个
我也有同样的例外。 我以前在应用程序中使用Memcached,重启后,整个servicemix问题就消失了。也许会有帮助