我有一个maven pom,它将我所需的所有库构建到我的WEB-INF / lib文件夹中,然后将其打包为战争。当我尝试部署此战争时,Tomcat会抛出许多ClassNotFoundExceptions - 最新的一个是“java.lang.ClassNotFoundException:javax.xml.bind.annotation.AccessorOrder”;我发现修复它的唯一方法是从我的WEB-INF / lib文件夹中复制所需的库文件并将它们扔进tomcat / lib,但这不是正确的方法。
我是否有必要对tomcat进行查看以使其显示在我的WEB-INF / lib文件夹中? 在我的源代码中有什么东西要告诉tomcat看那里吗? 我不得不让我的tomcat / lib文件夹中装满50多个罐子吗?
也许它是相关的,但我正在使用CXF和Spring-MVC技术。
我发布了源代码,但我不知道要放哪个文件,所以我会发布这个当前错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'publisher' defined in ServletContext resource [/WEB-INF/forum-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [publisher.Publisher]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/annotation/AccessorOrder at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:883) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [publisher.Publisher]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/annotation/AccessorOrder
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
... 36 more
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/AccessorOrder
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createClassInfo(RuntimeModelBuilder.java:59)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createClassInfo(RuntimeModelBuilder.java:41)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:123)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:49)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:41)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:189)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:204)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:327)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:198)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
感谢您的帮助
答案 0 :(得分:0)
以正确的方式使用Maven:使用“war”打包并将所有需要的库作为依赖项。