tomcat6目转jboss5的问题
环境:JDK1.6+JBoss5.1+Struts2.1+Spring2.5
项目由tomcat6转jboss5.1之后
访问页面出现异常:
HTTP Status 500 -
exception
Unable to instantiate Action, loginAction, defined for 'login' in namespace '/'loginAction from BaseClassLoader@43ea37{VFSClassLoaderPolicy@c5f44e{ ......
root cause
java.lang.ClassNotFoundException: loginAction from BaseClassLoader@43ea37{VFSClassLoaderPolicy@c5f44e{...............
解决过程:
1.添加jboss-as-sprint-int-5.0.0.GA.jar,jboss-spring-int-vfs.jar两个jar文件
[考https://jira.springframework.org/browse/SPR-5120,下载jboss-as-sprint-int-5.0.0.GA.jar和jboss-spring-int-vfs.jar]
web.xml文件
<context-param>
<param-name>contextClass</param-name>
<param-value>org.jboss.spring.vfs.context.VFSXmlWebApplicationContext</param-value>
</context-param>
2.在WEB-INF下加jboss-web.xml 设置Web应用加载时使用JBoss统一的classloader 。[JBoss类隔离]:
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
<jboss-web>
<class-loading java2ClassLoadingCompliance="true">
<loader-repository>
*:archive= *.war
<loader-repository-config>
java2ParentDelegation=true
</loader-repository-config>
</loader-repository>
</class-loading>
</jboss-web>
原因:
JBOSS 5.0后采用 VFS系统,解析XML文件时对spring支持的不好.
具体情况见: http://jira.springframework.org/browse/SPR-5120
在解决问题的过程中也是很郁闷
classpath:applicationContext*.xml 这样的配置始终不能正常运行,改成classpath:applicationContext.xml,classpath:applicationContext-action.xml[,....]
才最终正常