應用使用struts2+spring2.5+hibernat+xfire,在tomcat5.5上能正常運行,移植到jboss時,出現若干問題:
1.啟動時出現異常提示:
org.springframework.context.ApplicationContextException: Custom context class [org.jboss.spring.vfs.context.VFSXmlWebApplicationContext] is not of type [org.springframework.web.context.ConfigurableWebApplicationContext]
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:245)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3910)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4393)
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
spring.jar以及spring-webmvc.jar包放在jboss的default/lib下,注意在應用的WEB-INF/lib下面不能有這兩個包
2.在tomcat下能正常顯示的包含struts2的部分的標簽在頁面上不能正常顯示,有時候在jboss下沒有任何錯誤日志或提示,或是莫名其妙的錯誤,如:
17:02:06,434 ERROR [STDERR] Caused by: tag 'select', field 'list', name 'searchI
ndex[4].defaultValue': The requested list key '#request[#a.name]' could not be r
esolved as a collection/array/map/enumeration/iterator type. Example: people or
苦苦折騰了幾天,以為是程序哪里有問題,后來發現其實非也,主要是編譯的時候,沒有指定編譯的編碼所致,有兩種辦法避免,一種是
在build.xml中的javac中間加上encoding,如下,加上
"<compilerarg line="-encoding GBK "/>"
<javac srcdir="${build.src}" destdir="${buildwar.dest}/WEB-INF/classes" debug="${debug}" optimize="${optimize}">
<compilerarg line="-encoding GBK "/>
<classpath refid="library.classpath" />
</javac>
或是在編譯的時候,指定編碼,在eclipse上,在build.xml點右鍵Run AS,打開配置面板,在common選項卡中的consol encoding中,選
other,使用gbk編碼。
3.在jboss中,程序運行時,中文輸出的是亂碼,解決的方法同2,也是編譯時編碼的問題。呵呵。
4.移值時,有些莫名其妙的問題,可以找找是否是jar包沖突引起的,或是jar的位置的問題,沒有總結,一點點自己慢慢試吧;
例如以下錯誤:
Caused by: java.lang.ClassCastException: org.hibernate.dialect.MySQLDialect cannot be cast to org.hibernate.dialect.Dialect
把應用的lib下的hibernate.jar包去掉就行了,這是和jboss自帶的hibernate包有沖突導致