Tomcat中的“Error listenerStart”錯誤信息:asm與cglib的版本兼容問題

tomcat啓動以後,webapp沒有正常部署,檢查tomcat控制檯,發現如下打印信息:

二月 28, 2014 7:07:16 下午 org.apache.catalina.core.StandardContext startInternal

嚴重: Error listenerStart


再檢查log日誌,發現有如下錯誤信息:

嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateSessionFactory' defined in ServletContext resource [/WEB-INF/classes/spring/hibernate/hibernate.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
...
Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
	at net.sf.cglib.core.DebuggingClassWriter.<init>(DebuggingClassWriter.java:47)
	at net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)
	at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
....
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
	... 25 more

從打印信息看,是在DebuggingClassWriter初始化過程中出錯的。找到47行出錯的地方:

       super(computeMaxs);

因爲DebuggingClassWriter的父類是org.objectweb.asm.ClassWriter,檢查源代碼,發現使用的包中,該類沒有對應的構造函數(boolean型),只有Int型。由此判斷,應該是引用的包版本不兼容。檢查了一下使用的包:cglib-2.1_3.jar和asm-3.3.jar。asm版本太新,回退到1.5.3就可以了。

這個錯誤的包是怎麼引起的呢?

原來在pom.xml中沒有定義asm,系統自動下載了3.3版本。在pom中重新添加:

		<dependency>
			<groupId>asm</groupId>
			<artifactId>asm</artifactId>
			<version>1.5.3</version>
		</dependency>


問題解決。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章