java.lang.ArrayStoreException:servicemix上的sun.reflect.annotation.TypeNotPresentExceptionProxy

时间:2017-09-06 06:28:31

标签: java spring osgi apache-servicemix

我尝试使用spring boot来开发WebService服务并在ServiceMix中发布它,但我得到了这样的异常:

      .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                        

java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
    at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
    at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
    at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
    at java.lang.Class.createAnnotationData(Class.java:3521)
    at java.lang.Class.annotationData(Class.java:3510)
    at java.lang.Class.getAnnotations(Class.java:3446)
    at org.springframework.core.type.StandardAnnotationMetadata.getMetaAnnotationTypes(StandardAnnotationMetadata.java:84)
    at org.springframework.context.annotation.AnnotationBeanNameGenerator.determineBeanNameFromAnnotation(AnnotationBeanNameGenerator.java:90)
    at org.springframework.context.annotation.AnnotationBeanNameGenerator.generateBeanName(AnnotationBeanNameGenerator.java:69)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:146)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:128)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.register(AnnotatedBeanDefinitionReader.java:123)
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:159)
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:135)
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:127)
    at org.springframework.boot.SpringApplication.load(SpringApplication.java:635)
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:355)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:301)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
    at com.glodon.webservice_1.App.start(App.java:22)
    at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:697)
    at org.apache.felix.framework.Felix.activateBundle(Felix.java:2238)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:2144)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1253)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1225)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1213)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:507)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312)

这意味着某些注释引用了类路径上没有的类,但是如何知道错过哪个类? 我的Manifest Headers是:

Bnd-LastModified: 1504594453579
Build-Jdk: 1.8.0_144
Built-By: yangez
Bundle-Activator: com.glodon.webservice_1.App
Bundle-ManifestVersion: 2
Bundle-Name: webservice_1
Bundle-SymbolicName: com.glodon.webservice_1
Bundle-Version: 0.0.1.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: com.glodon.webservice_1; uses:="javax.jws, javax.xml.ws, org.apache.cxf.bus.spring, org.osgi.framework, org.springframework.boot.autoconfigure, org.springframework.boot.web.servlet, org.springframework.context.annotation"; version="0.0.1"
Import-Package: javax.jws; resolution:=optional, javax.servlet; resolution:=optional, javax.xml.ws; resolution:=optional, org.apache.cxf; resolution:=optional; version="[3.1, 4)", org.apache.cxf.bus.spring; resolution:=optional; version="[3.1, 4)", org.apache.cxf.jaxws; resolution:=optional; version="[3.1, 4)", org.apache.cxf.transport.servlet; resolution:=optional; version="[3.1, 4)", org.osgi.framework; resolution:=optional; version="[1.6, 2)", org.springframework.boot; resolution:=optional, org.springframework.boot.autoconfigure; resolution:=optional, org.springframework.boot.web.servlet; resolution:=optional, org.springframework.context; resolution:=optional, org.springframework.context.annotation; resolution:=optional
Manifest-Version: 1.0
Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.3.0.201609221906 

1 个答案:

答案 0 :(得分:0)

您的大多数导入都是resolution:=optional,这意味着您的捆绑包可能始终会解决,但您无法保证在需要时可以使用所需的类。像你目前的情况。可选的解决方案适用于真正可选的软件包,以及您的软件包准备处理缺少的类型的软件包。但是,如果您的代码必须包含类型,则必须导入这些类型的包。

我建议您从导入中删除resolution:=optional,看看情况如何。由于缺少包的导出器,您可能会收到解决错误,但这会告诉您捆绑包需要什么。