JBoss5.1.0部署SSH2

环境:JDK1.6+JBoss5.1.0+Struts2.1.8+Spring2.5.6+Hibernate3.3.2

  1. war包放入“JBOSS安装目录/server/default/deploy”目录,直接启动,报如下错误:
    09:24:46,890 ERROR [JBossContextConfig] XML error parsing: context.xml org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser at org.jboss.xb.binding.UnmarshallerFactory$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:100)
    分析可能与JBoss4.2.3版本类似,存在classloader问题,参考JBoss社区资料(http://community.jboss.org/wiki/classloadingconfiguration),设置Web应用加载时使用JBoss统一的classloader。具体操作方法为:在WEB-INF下增加jboss-web.xml
    <!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> com.example:archive= unique-archive-name <loader-repository-config> java2ParentDelegation=true </loader-repository-config> </loader-repository> </class-loading> </jboss-web>
        说明:com.example:archive=unique-archive-name代表jar仓库的对象名objectName ,其中,com.example可以随意取,unique-archive-name 就用部署包的名字即可,例如com.example:archive=demo.war,保证这一串唯一即可。
        详细说明可以通过google搜索“JBoss类隔离”。
  2. 重启JBoss,上述错误不再出现,但又报如下错误:
    14:24:15,406 ERROR [ContextLoader] Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: I/O failure during classpath scanning; nested exception is java.io.FileNotFoundException: C:/JavaPro/jboss-5.1.0.GA/server/default/deploy/demo.war/WEB-INF/lib/demo.jar/com/demo (系统找不到指定的路径。)
    参考https://jira.springframework.org/browse/SPR-5120,下载jboss-as-sprint-int-5.0.0.GA.jarjboss-spring-int-vfs.jar,拷贝至Web应用的lib下,修改web.xml,加入:
    <context-param> <param-name>contextClass</param-name> <param-value>org.jboss.spring.vfs.context.VFSXmlWebApplicationContext</param-value> </context-param>
  3. 重新启动,上述错误不再出现,但报如下错误:
    14:42:49,484 ERROR [ContextLoader] Context initialization failed org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Invalid relative resource location [applicationContext-hibernate.xml] to import bean definitions from Offending resource: FileHandler@21170058[path=demo.war/WEB-INF/classes/spring/applicationContext.xml context=file:/C:/JavaPro/jboss-5.1.0.GA/server/default/deploy/ real=file:/C:/JavaPro/jboss-5.1.0.GA/server/default/deploy/demo.war/WEB-INF/classes/spring/applicationContext.xml]; nested exception is java.io.IOException: Error listing files: C:/JavaPro/jboss-5.1.0.GA/server/default/deploy/demo.war/WEB-INF/classes/spring/applicationContext.xml ............ Caused by: java.io.IOException: Error listing files: C:/JavaPro/jboss-5.1.0.GA/server/default/deploy/demo.war/WEB-INF/classes/spring/applicationContext.xml
    修改spring的配置中类似 <import resource="applicationContext-xxx.xml"/> 的内容,改成<import resource="classpath:applicationContext-xxx.xml"/>。我的demospring配置文件在classesspring文件夹下,因此,应该改成:<import resource="classpath:spring/applicationContext-xxx.xml"/>
  4. 重新启动,不再报任何错误,访问首页正确显示,并能登录成功。


你可能感兴趣的:(spring,exception,jboss,ClassLoader,initialization,archive)