SSH整合常见异常。~ 新手篇

 初学SSH,基础整合常见异常

 

1.Unable to load configuration. - bean - jar:struts2-spring-plugin-2.2.1.1.jar!/struts-plugin.xml:29:132

( 在整合SSH时如果不导入struts2-spring-plugin-2.x.x.x.jar会出现Unable to load configuration. - action - ...Caused by: Action class [login] not found - action - ...)

但是导入struts2-spring-plugin-2.2.1.1.jar又会出现现在讨论的问题,为此问题纠结很久。后来没办法网上下源码跑别人的Demo可以,于是对比/lib下的jar包,发现是struts2-spring-plugin-2.1.6.jar,换上这个版本..继续运行..OK了..

 

严重: Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/D:/Program%20Files/Tomcat%206.0/webapps/zxdy/WEB-INF/lib/struts2-spring-plugin-2.2.1.1.jar!/struts-plugin.xml:29:132
....

Caused by: Unable to load configuration. - bean - jar:file:/D:/Program%20Files/Tomcat%206.0/webapps/zxdy/WEB-INF/lib/struts2-spring-plugin-2.2.1.1.jar!/struts-plugin.xml:29:132
... 29 more
Caused by: Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory class:org.apache.struts2.spring.StrutsSpringObjectFactory - bean - jar:file:/D:/Program%20Files/Tomcat%206.0/webapps/zxdy/WEB-INF/lib/struts2-spring-plugin-2.2.1.1.jar!/struts-plugin.xml:29:132
... 31 more
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name spring has already been loaded by bean - jar:file:/D:/Program%20Files/Tomcat%206.0/webapps/zxdy/WEB-INF/lib/struts2-spring-plugin-2.0.11.jar!/struts-plugin.xml:30:132 - bean - jar:file:/D:/Program%20Files/Tomcat%206.0/webapps/zxdy/WEB-INF/lib/struts2-spring-plugin-2.2.1.1.jar!/struts-plugin.xml:29:132
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216)
... 34 more
2011-4-14 15:19:17 org.apache.catalina.core.StandardContext start
严重: Error filterStart
2011-4-14 15:19:17 org.apache.catalina.core.StandardContext start
严重: Context [/zxdy] startup failed due to previous errors

 

2.Unable to load bean: type: struts-derfault.xml异常

solution:

导致其主要原因还是因为加错了包,只要将xwork-2.1.1.jarstruts2-core-2.1.2.jar,换成xwork-2.0.4.jar或者struts2-core-2.0.14.jar,

严重: Exception starting filter struts2
Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar:file:/D:/tomcat-5.5.27/webapps/strutsDemo/WEB-INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:29:72
 ......
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - jar:file:/D:/tomcat-5.5.27/webapps/strutsDemo/WEB-INF/lib/struts2-core-2.0.14.jar!/struts-default.xml:30:72 - bean - jar:file:/D:/tomcat-5.5.27/webapps/strutsDemo/WEB-INF/lib/struts2-core-2.1.2.jar!/struts-default.xml:29:72
 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:193)
 ... 33 more

 

3.java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

solution:

1.ContextLoaderListener这个类是在spring-web.jar包下,仔细检查了项目jar环境,发现该jar包确实存在,而且也能找到编译后的ContextLoaderListener.class文件>>>
 可能是:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
导入的仅仅是jar包的引用,例如在eclipse中通过build path加进user lib……(类似快捷方式)  
这种在Java Application中没问题,但在web Application中可能会出现找不到类的异常。  
在WEB Application中jar包最好放在webroot或webcontent下的lib文件夹内,特别是xml中用到的jar包。

2.各种导包方式之下疏忽,未导入 spring-web.jar 包!   

 

4.Caused by:java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)

solution:

SSH整合所需所有jar包都导好之后,把asm.jar,asm-attrs.jar,cglib-2.1.3.jar三个文件从项目里导出,并彻底删掉。

你可能感兴趣的:(异常什么的)