生活随笔
收集整理的這篇文章主要介紹了
JBoss5.1.0部署SSH2
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
環境:JDK1.6+JBoss5.1.0+Struts2.1.8+Spring2.5.6+Hibernate3.3.2
將 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 類隔離”。 重啟 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.jar 和 jboss-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>?? 重新啟動,上述錯誤不再出現,但報如下錯誤:
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"/> 。我的 demo 中 spring 配置文件在 classes 的 spring 文件夾下,因此,應該改成: <import resource="classpath:spring/applicationContext-xxx.xml"/> 重新啟動,不再報任何錯誤,訪問首頁正確顯示,并能登錄成功。
總結
以上是生活随笔為你收集整理的JBoss5.1.0部署SSH2的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。