应用使用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包有冲突导致

只有注册用户登录后才能发表评论。


网站导航: