SSH包冲突

1.在搭建SSH开发平台的时候,由MyEclipse自动导入的包存在一些冲突,主要有

(1) asm.jarasm-2.2.3.jar

asm-2.2.3spring所依赖,而asm.jarhibernate依赖的,应该删除asm-2.2.3.jar这个包

(2). commons-logging-1.0.4.jarcommons-logging-api-1.1.jar

这两个包中commons-logging-1.0.4.jarspringhibernate以及struts都要用的包,但是struts2.1以上的版本还需要commons-logging-api-1.1.jar,其实这两个包几乎一样,commons-logging-api-1.1.jar版本较新而已。

(3)异常

严重: Exception starting filter struts2
java.lang.NullPointerException
    at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:203)
   ...

可能的原因是spring的默认配置文件applicationContext.xml改了名,或者没有放在classpath的根路径下面,并且没有在web.xml文件中配置spring的监听器,解决办法在web.xml中添加

<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>

(4)异常

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]

 

可能的原因是虽然配置了spring的监听器,但是没有在web.xml中配置contextConfigLocation来指定spring配置文件列表及相应的具体路径。解决的办法是在web.xml文件中添加,例如:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/csdn-spring*.xml</param-value>
</context-param>

 

(5)异常

org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection

可能的原因是缺少相应的JDBC驱动包,请把驱动包拷贝到/WEB-INF/lib下面,或者是数据源的配置有问题,例如用户名、者密码或者URL错误。

(6)异常

javax.servlet.ServletException: Error applying decorator: null

 org.apache.struts2.sitemesh.FreeMarkerPageFilter.applyDecorator(FreeMarkerPageFilter.java:164)

 org.apache.struts2.sitemesh.TemplatePageFilter.applyDecorator(TemplatePageFilter.java:116)

 com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:62)

 org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)

 org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)

 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)


Struts2sitemesh插件struts2-sitemesh-plugin-2.1.6的一个BUG,FreeMarkerPageFiltergetLocale方法没有对invocation添加非空判断造成的,解决办法是解压包,然后找到org.apache.struts2.sitemesh.FreeMarkerPageFilter这个类,

view plaincopy to clipboardprint?

1.        protected Locale getLocale(ActionInvocation invocation, Configuration configuration) {      

2.                if (invocation.getAction() instanceof LocaleProvider) {      

3.                    return ((LocaleProvider) invocation.getAction()).getLocale();      

4.                 } else {      

5.                    return configuration.getLocale();      

6.                 }      

7.        }     

修改为:

view plaincopy to clipboardprint?

1.        protected Locale getLocale(ActionInvocation invocation, Configuration configuration) {      

2.            if (invocation != null && invocation.getAction() instanceof LocaleProvider) {      

3.                return ((LocaleProvider) invocation.getAction()).getLocale();      

4.             } else {      

5.                return configuration.getLocale();      

6.             }      

7.        }      

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值