springMVC+CXF3.0 tomcat下启动正常,用脚本启动报错.

问题描述

如题.springMVC+CXF3.0,部署到tomcat下启动,一切ok.用脚本启动一直报错NoClassDefFoundError:Couldnotinitializeclasscom.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.网上查说是jdk版本的问题,但我的已经是1.6.24,应该不存在说的问题.看了一下,报错的这个类在jdk的rt.jar和jaxb-impl-2.2.7.jar下面都有.怀疑是类加载顺序问题,在jre的endorsed下放了jaxb-impl-2.2.7.jar也是没用.请教大家,这个可能是什么问题导致.启动脚本代码:publicclassSpringUtilTest{publicstaticApplicationContextapplicationContext=newClassPathXmlApplicationContext("classpath:spring*.xml");publicstaticApplicationContextgetApplicationContext(){returnapplicationContext;}publicstaticvoidmain(String[]args){System.out.println("springinitfinlished...");System.out.println(System.getProperty("java.endorsed.dirs"));System.out.println(System.getProperty("java.ext.dirs"));AccessCANcan=(AccessCAN)getApplicationContext().getBean("accessCAN");//BaseDaodao=(BaseDao)getApplicationContext().getBean("baseDao");////TransactionDaotdao=(TransactionDao)getApplicationContext().getBean("transactionDao");try{//System.out.println(JSON.toJSONString(dao.queryForList("selectinvnoasinvNofromBTAS_Transactionwhere1=1")));//System.out.println(JSON.toJSONString(tdao.getInvnosByTimestamp("","")));//can.orderupload(null);}catch(Exceptione){e.printStackTrace();}System.out.println("over");}}

CXF配置主要就是这句:<jaxws:endpointid="IurPoServices"implementor="jeecg.citsamex.hoteliur.ws.impl.IurPoServicesImpl"address="/IurPoServices"/>

报的错误:java.lang.ExceptionInInitializerErrorCausedby:org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'IurPoServices':Invocationofinitmethodfailed;nestedexceptionisjava.lang.NoClassDefFoundError:Couldnotinitializeclasscom.sun.xml.bind.v2.model.impl.RuntimeModelBuilderatorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)atorg.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)atorg.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)atorg.jeecgframework.core.util.SpringUtilTest.<clinit>(SpringUtilTest.java:17)Causedby:java.lang.NoClassDefFoundError:Couldnotinitializeclasscom.sun.xml.bind.v2.model.impl.RuntimeModelBuilderatcom.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:455)atcom.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:303)atcom.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:142)atcom.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1174)atcom.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:162)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:597)atjavax.xml.bind.ContextFinder.newInstance(ContextFinder.java:210)atjavax.xml.bind.ContextFinder.find(ContextFinder.java:368)atjavax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)atorg.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:347)atorg.apache.cxf.common.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:345)atjava.security.AccessController.doPrivileged(NativeMethod)atorg.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:345)atorg.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:246)atorg.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:470)atorg.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:325)atorg.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)atorg.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:467)atorg.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:704)atorg.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:527)atorg.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:261)atorg.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215)atorg.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)atorg.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159)atorg.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)atorg.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:456)atorg.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:334)atorg.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251)atorg.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:539)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:597)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1581)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1522)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)...12more

解决方案

解决方案二:
看上去还是版本问题,看看是不是第三方包里有了那个包,却没那个类
解决方案三:
java.lang.NoClassDefFoundError这个异常代表着jar包不存在或者冲突
解决方案四:
引用1楼defonds的回复:

看上去还是版本问题,看看是不是第三方包里有了那个包,却没那个类

第三方就只有tomcat了,我看了tomcat下的jar包,没有哪个包里有这个类的,工程引用的就前边提到的两个jar包里有这个类.
解决方案五:
引用2楼suciver的回复:

java.lang.NoClassDefFoundError这个异常代表着jar包不存在或者冲突

jar包肯定是存在的,因为部署到tomcat下是可以启动的.现在看就是有两个jar包都有这个类,所以猜测是引用错了,但这两个jar包感觉都不能删里面的类的,有什么方式可以设置先加载哪个类吗,我试着在jre下的设置好像是没有作用的.

时间: 2024-09-18 02:17:15

springMVC+CXF3.0 tomcat下启动正常,用脚本启动报错.的相关文章

tomcat日志调到debug,不报错但一直循环

问题描述 tomcat日志调到debug,不报错但一直循环 springmvc + spring + mybatis tomcat日志调到debug,不报错但一直循环,如下:. Creating shared instance of singleton bean 'trendsOperatorMapper' Creating instance of bean 'trendsOperatorMapper' Eagerly caching bean 'trendsOperatorMapper' to

tomcat 7.0正常启动没问题,debug报错,求大帮忙

问题描述 tomcat 7.0正常启动没问题,debug报错,求大帮忙 2015-01-12 10:11:56,519 ERROR [org.springframework.web.context.ContextLoader] java.lang.NoClassDefFoundError: Could not initialize class org.springframework.beans.factory.BeanCreationException at org.springframewor

tomcat正常启动后http://localhost:8080/报错404

问题描述 如题,tomcat正常启动后http://localhost:8080/报错404.tomcat的webapps目录下有正常部署好的项目,项目可以运行. 解决方案 解决方案二:Tomcat中配置的默认项目是什么??默认项目的默认主页又是什么??404就是找不到资源呗!解决方案三:http://localhost:8080/xxxx/xxxx一般是项目名称,你也可以配置为"/"解决方案四:我也遇到了这种情况,tomcat下面的项目可以正常访问,但是tomcat的manager页

druid+Atomikos+mysql+tomcat启动无响应也不报错

问题描述 druid+Atomikos+mysql+tomcat启动无响应也不报错 日志停在这然后就没然后了 2016-03-22 21:55:00,850 [// - - ] INFO org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'formAuthenticationFilter' of type [class org.apache.s

tomcat-Myeclipse10.7版本装Tomcat7.0,但是进行连接时,出现报错,请大神解答!

问题描述 Myeclipse10.7版本装Tomcat7.0,但是进行连接时,出现报错,请大神解答! 换过Myeclipse10.7版本准备装Tomcat7.0,就出现这错误,机子上还装有Eclipse.请问应该怎么做,求大神解答.在线等 解决方案 用15 稳定版,10版,个人觉得不好用, 解决方案二: 用低版本试试,版本太高了也容易出现问题 解决方案三: eclipse上貌似用不了tomcat吧,在myeclipse上找到tomcat7的路径,jdk路径也要正确

storm配置后启动nimbus后查看日志报错

问题描述 storm配置后启动nimbus后查看日志报错 [WARN] Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect java.net.NoRouteToHostException: 没有到主机的路由 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.7.0_45]

index-link如何对一个文件夹下的数据文件排序,报错,Index out of range

问题描述 link如何对一个文件夹下的数据文件排序,报错,Index out of range link如何对一个文件夹下的数据文件排序,报错,Index out of range List data = new List(); foreach (var file in Dictionary.GetFiles("e:华新采集", "*.txt")) { data.AddRange(File.ReadAllLines(file).Skip(2)); } var que

ssh使用tomcat中配置好的c3p0数据源报错

问题描述 ssh使用tomcat中配置好的c3p0数据源报错 tomcat中对应项目的xml文件配置为: <?xml version="1.0" encoding="UTF-8"?> <Context path="/Village" docBase="D:WorkspacesMyEclipse 10webprojectVillageWebRoot" reloadable= "true" p

path-tomcat问题 启动不了 web项目报错

问题描述 tomcat问题 启动不了 web项目报错 Demo13 is required and cannot be removed from the server 每个web项目都在run as 的时候,点击该项目命称,最上面就会出现这句话,前面有个红叉,最后运行时报错,但我的build path等配置并没问题,tomcat安装都没问题 解决方案 你是不是有两个tomcat,遇到这种问题最直接的方法是 点击删除tomcat,然后再把tomcat加进去 就好了 解决方案二: tomcat启动报