前言
不知道前面对eclipse做了什么,使用maven来创建项目,然后转成web,启动的时候一直报错。我弄了好久,还是无法解决,先记录
正文
错误信息
tomcat启动的时候报了下面的错误
严重: Exception sending context initialized event to listener instance of class com.demo.web.listener.InitApplicationListener java.lang.IllegalArgumentException at org.springframework.asm.ClassReader.<init>(Unknown Source) at org.springframework.asm.ClassReader.<init>(Unknown Source) at org.springframework.asm.ClassReader.<init>(Unknown Source) at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:52) at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80) at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101) at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76) at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:298) at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:300) at org.springframework.context.annotation.ConfigurationClassParser.getImports(ConfigurationClassParser.java:300) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:230) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:153) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:130) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:285) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:223) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:630) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) at com.demo.web.listener.InitApplicationListener.contextInitialized(InitApplicationListener.java:32) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1768) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
前几天一个项目导入eclipse,jdk为1.8版本,也是这样的错误,我用1.6就可以了,也没有深究。这次,使用maven创建项目,转成web项目的时候又出现了这个错误,之所以没有换jdk,是因为之前都是可以跑起来的,所以这次查阅各种资料,花了很长时间,到最后还是无法解决
这是出现的原因
问题解决
隔了一天,重新看昨天出现的错误,我新建了一个传统的Web项目,部署以后还是出现同样的问题,这次我把tomcat在控制台启动的信息详细的看了一下,里面有一段下面的信息
息: Deploying web application archive D:workbenchapache-tomcat-8.0.24webappsdemo-web-0.0.1-SNAPSHOT.war
- 1
原来我在tomcat的webapp目录下面放了一个war包,在tomcat启动的时候会部署这个war包,错误就是发生在这里面的。看来头痛医脚的道理在程序中同样适用。以后看到问题,不能只盯着报错的信息,其他东西也要看看
这个war包出现的错误,如stackoverflow里面大神所讲的,是jdk不兼容。
笔者注:按照博文里的方法,笔者改变了3.2.0.RELEASE改成4.3.8RELEASE然后项目基本就能正常运行了