JBoss5.1.0部署SSH2

25 篇文章 0 订阅
12 篇文章 0 订阅

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

  1. war 包放入“ JBOSS 安装目录 /server/default/deploy ”目录,直接启动,报如下错误:
    1. 09 : 24 : 46 , 890  ERROR [JBossContextConfig] XML error parsing: context.xml  
    2. org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new  SAX parser  
    3.         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
    1. <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 5.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd" >     
    2. < jboss-web >     
    3.     < class-loading   java2ClassLoadingCompliance = "true" >   
    4.         < loader-repository >   
    5.             com.example:archiveunique -archive-name  
    6.             < loader-repository-config >   
    7.                 java2ParentDelegation = true   
    8.             </ loader-repository-config >   
    9.         </ loader-repository >   
    10.     </ class-loading >   
    11. </ jboss-web >   

        说明: com.example:archive=unique-archive-name 代表 jar 仓库的对象名 objectName ,其中 ,com.example 可以随意取, unique-archive-name 就用部署包的名字即可,例如 com.example:archive=demo.war ,保证这一串唯一即可。
        详细说明可以通过 google 搜索“ JBoss 类隔离”。
  2. 重启 JBoss ,上述错误不再出现,但又报如下错误:
    1. 14 : 24 : 15 , 406  ERROR [ContextLoader] Context initialization failed  
    2. 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.jar jboss-spring-int-vfs.jar ,拷贝至 Web 应用的 lib 下,修改 web.xml ,加入:
    1. <context-param>  
    2.  <param-name>contextClass</param-name>  
    3.  <param-value>org.jboss.spring.vfs.context.VFSXmlWebApplicationContext</param-value>  
    4. </context-param>  
  3. 重新启动,上述错误不再出现,但报如下错误:
    1. 14 : 42 : 49 , 484  ERROR [ContextLoader] Context initialization failed  
    2. 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  
    3. ............  
    4. 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"/> 。我的 demo spring 配置文件在 classes spring 文件夹下,因此,应该改成: <import resource="classpath:spring/applicationContext-xxx.xml"/>
  4. 重新启动,不再报任何错误,访问首页正确显示,并能登录成功。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值