找不到AnnotationReader类
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了找不到AnnotationReader类相关的知识,希望对你有一定的参考价值。
我在ServiceMix中遇到依赖项问题。
我尝试开始捆绑。这个包有几个导入:
Import-Package =
org.apache.camel;version="[2.16,3)",
org.apache.camel.builder;version="[2.16,3)",
org.apache.camel.osgi;version="[2.16,3)",
org.springframework.cglib.core,
org.springframework.cglib.proxy,
org.springframework.beans.factory,
org.springframework.cglib.reflect,
org.apache.camel.spring;version="[2.16,3)",
com.sun.xml.bind.v2.model.annotation;resolution:=optional;version="[2.2.0,3.0.0)"
这些要求解决如下:
osgi.wiring.package; (&(osgi.wiring.package=org.apache.camel)(version>=2.16.0)(!(version>=3.0.0))) resolved by:
osgi.wiring.package; org.apache.camel 2.16.5 from org.apache.camel.camel-core [46]
osgi.wiring.package; (&(osgi.wiring.package=org.apache.camel.builder)(version>=2.16.0)(!(version>=3.0.0))) resolved by:
osgi.wiring.package; org.apache.camel.builder 2.16.5 from org.apache.camel.camel-core [46]
osgi.wiring.package; (&(osgi.wiring.package=org.apache.camel.osgi)(version>=2.16.0)(!(version>=3.0.0))) resolved by:
osgi.wiring.package; org.apache.camel.osgi 2.16.5 from org.apache.camel.camel-spring [50]
osgi.wiring.package; (osgi.wiring.package=org.springframework.cglib.core) resolved by:
osgi.wiring.package; org.springframework.cglib.core 3.2.18.RELEASE from org.apache.servicemix.bundles.spring-core [155]
osgi.wiring.package; (osgi.wiring.package=org.springframework.cglib.proxy) resolved by:
osgi.wiring.package; org.springframework.cglib.proxy 3.2.18.RELEASE from org.apache.servicemix.bundles.spring-core [155]
osgi.wiring.package; (osgi.wiring.package=org.springframework.beans.factory) resolved by:
osgi.wiring.package; org.springframework.beans.factory 3.2.18.RELEASE from org.apache.servicemix.bundles.spring-beans [152]
osgi.wiring.package; (osgi.wiring.package=org.springframework.cglib.reflect) resolved by:
osgi.wiring.package; org.springframework.cglib.reflect 3.2.18.RELEASE from org.apache.servicemix.bundles.spring-core [155]
osgi.wiring.package; (&(osgi.wiring.package=org.apache.camel.spring)(version>=2.16.0)(!(version>=3.0.0))) resolved by:
osgi.wiring.package; org.apache.camel.spring 2.16.5 from org.apache.camel.camel-spring [50]
osgi.wiring.package; (&(osgi.wiring.package=com.sun.xml.bind.v2.model.annotation)(version>=2.2.0)(!(version>=3.0.0))) resolved by:
osgi.wiring.package; com.sun.xml.bind.v2.model.annotation 2.2.11 from org.apache.servicemix.bundles.jaxb-impl [562]
osgi.ee; (&(osgi.ee=JavaSE)(version=1.5)) resolved by:
osgi.ee; JavaSE [1.0.0, 1.1.0, 1.2.0, 1.3.0, 1.4.0, 1.5.0, 1.6.0, 1.7.0, 1.8.0] from org.apache.felix.framework [0]
service; [org.osgi.service.packageadmin.PackageAdmin] provided by:
org.apache.felix.framework [0]
service; [org.xml.sax.EntityResolver] provided by:
org.springframework.osgi.extender [219]
service; [org.springframework.beans.factory.xml.NamespaceHandlerResolver] provided by:
org.springframework.osgi.extender [219]
但是,当我开始我的包时,我有以下错误:
2018-01-10 17:45:19,950 | ERROR | ExtenderThread-1 | ContextLoaderListener | 219 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=myBundle, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL [bundle://638.0:0/META-INF/spring/camel-context.xml]; nested exception is java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:413)[152:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)[152:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)[152:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)[152:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)[152:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)[152:org.apache.servicemix.bundles.spring-beans:3.2.18.RELEASE_1]
at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:164)[218:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:136)[218:org.springframework.osgi.core:1.2.1]
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)[153:org.apache.servicemix.bundles.spring-context:3.2.18.RELEASE_1]
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:545)[153:org.apache.servicemix.bundles.spring-context:3.2.18.RELEASE_1]
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$800(AbstractDelegatedExecutionApplicationContext.java:69)[218:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$3.run(AbstractDelegatedExecutionApplicationContext.java:269)[218:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)[218:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.startRefresh(AbstractDelegatedExecutionApplicationContext.java:247)[218:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:214)[219:org.springframework.osgi.extender:1.2.1]
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:169)[219:org.springframework.osgi.extender:1.2.1]
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175)[218:org.springframework.osgi.core:1.2.1]
at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:716)[219:org.springframework.osgi.extender:1.2.1]
at java.lang.Thread.run(Thread.java:748)[:1.8.0_151]
Caused by: java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader
at java.lang.ClassLoader.defineClass1(Native Method)[:1.8.0_151]
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)[:1.8.0_151]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.defineClass(BundleWiringImpl.java:2310)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2094)
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1518)
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1958)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_151]
at java.lang.Class.getDeclaredMethods0(Native Method)[:1.8.0_151]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)[:1.8.0_151]
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)[:1.8.0_151]
at java.lang.Class.getMethod0(Class.java:3018)[:1.8.0_151]
at java.lang.Class.getMethod(Class.java:1784)[:1.8.0_151]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:137)[:2.8.0]
at javax.xml.bind.ContextFinder.find(ContextFinder.java:310)[:2.8.0]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:446)[:2.8.0]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:409)[:2.8.0]
at org.apache.camel.impl.DefaultModelJAXBContextFactory.newJAXBContext(DefaultModelJAXBContextFactory.java:31)
at org.apache.camel.spring.handler.CamelNamespaceHandler.getJaxbContext(CamelNamespaceHandler.java:200)
at org.apache.camel.spring.handler.CamelNamespaceHandler$CamelContextBeanDefinitionParser.doParse(CamelNamespaceHandler.java:361)
at org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:85)
at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1432)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1422)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:147)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:101)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:495)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
... 18 more
Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.v2.model.annotation.AnnotationReader
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)[:1.8.0_151]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)[:1.8.0_151]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_151]
at org.apache.felix.framework.BundleWiringImpl.doImplicitBootDelegation(BundleWiringImpl.java:1764)[org.apache.felix.framework-5.6.2.jar:]
at org.apache.felix.framework.BundleWiringImpl.searchDynamicImports(BundleWiringImpl.java:1693)[org.apache.felix.framework-5.6.2.jar:]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1528)[org.apache.felix.framework-5.6.2.jar:]
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:79)[org.apache.felix.framework-5.6.2.jar:]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1958)[org.apache.felix.framework-5.6.2.jar:]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_151]
... 48 more
...好像我的包找不到包com.sun.xml.bind.v2.model.annotation虽然已经解决了...
当我列出捆绑包“org.apache.servicemix.bundles.jaxb-impl [562]”提供的所有类时:
karaf@root>bundle:classes 562 | grep AnnotationReader
com/sun/xml/bind/v2/model/annotation/AbstractInlineAnnotationReaderImpl.class
com/sun/xml/bind/v2/model/annotation/AnnotationReader.class
com/sun/xml/bind/v2/model/annotation/RuntimeAnnotationReader.class
com/sun/xml/bind/v2/model/annotation/RuntimeInlineAnnotationReader.class
...我找到了AnnotationReader类。
有人知道我的捆绑包找不到这个课程的原因吗?
非常感谢!
Hejk
答案
问题似乎是bundle的导入以下内容:
com.sun.xml.bind.v2.model.annotation;resolution:=optional;version="[2.2.0,3.0.0)"
从JVM导入实现包并不是一个好主意,在这种情况下,导入在不应该被标记为可选时。
通常,OSGi框架可以引导委托内部JVM类型,但在这种情况下,bundle已经显式地导入了包,这意味着它必须来自OSGi框架内的包布线。由于导入是可选的,因此允许框架不创建此连线,如果不是,那么就导入包而言,包不会存在。正确处理可选性的是进口商的工作,在这种情况下显然不会发生这种情况。
要解决此问题,可能就足以删除违规导入并依赖于使用可移植JAXB API。您是否知道为什么导入可能首先在那里?除非您的构建工具已明确配置为添加它们,否则存在可选导入是不常见的。
以上是关于找不到AnnotationReader类的主要内容,如果未能解决你的问题,请参考以下文章