您的位置:首页 > 编程语言 > Java开发

升级java1.8及ssh版本中碰到的问题(二)

2016-04-07 17:31 239 查看
……接上文

三、org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter cannot be cast to javax.servlet.Servlet。解决方法:改变maven里的servlet-api版本为javax.servlet-api

这个问题我是百度了很久,具体是从哪儿得到的提示现在是实在想不起来了,网上有人是web.xml没配置对的,但这对我来说是不存在的,我升级的项目都是原来运行正常的,除非是升级版本后配置文件本身有更改,否则不应该出错,也不知道是不是后来其他的错误使我想到了这个问题,我在maven仓库里搜索servlet-api时,发现有两个,一个是servlet-api,一个是javax.servlet-api,一开始我就是用的servlet-api,后来百度了一下这两者之间的区别,才发现javax.servlet-api是servlet-api的后续版本,3以前是servlet-api,3以后是javax.servlet-api,我把servlet-api改为javax.servlet-api,这个问题解决了,至于为什么要升级,这个简单了,因为我其他包升级了啊。

四、struts2升级报ActionContextCleanUp<<is deprecated……解决方法:改变web.xml相关配置。

注解掉:

<p style="margin-top: 0px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(70, 70, 70); font-family: simsun; font-size: 14px; background-color: rgb(232, 220, 200);"><filter>
 <wbr> <wbr> <filter-name>struts-cleanup</filter-name>
 <wbr> <wbr> <filter-class>
 <wbr> <wbr> <wbr> org.apache.struts2.dispatcher.ActionContextCleanUp
 <wbr> <wbr> </filter-class>
 <wbr> </filter></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></p><p style="margin-top: 0px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(70, 70, 70); font-family: simsun; font-size: 14px; background-color: rgb(232, 220, 200);">
 <wbr> <filter-mapping>
 <wbr> <wbr> <filter-name>struts-cleanup</filter-name>
 <wbr> <wbr> <url-pattern>/*</url-pattern>
 <wbr> </filter-mapping></wbr></wbr></wbr></wbr></wbr></wbr></p><span style="color: rgb(70, 70, 70); font-family: simsun; font-size: 14px; line-height: 21px; background-color: rgb(232, 220, 200);"></span>
这个完全是参考网上的答复的,见下面这个网页:
http://blog.sina.com.cn/s/blog_690794fd0101fqt7.html
五、Connection is read-only. Queries leading to data modification are not allowed。解决方法:update类的方法前加@Transactional

这个说一下,首先出现问题我是baidu了的,下面这两篇文章类似,代表了网上大多数说法:
http://www.tuicool.com/articles/7NZJvy3 http://blog.sina.com.cn/s/blog_664553710100pdca.html
可看文章都是说事务配置的问题,前面我也说过,更新的项目以前都是运行过,我虽然首先也是去看的配置文件,但总感觉并非一定要从配置文件入手,因为用名称限定@Transactional的readonly属性我总感觉挺奇怪的,而且配置文件里限定了还要在函数名上限定,但我还是做了尝试。我查看exception的cause by,一直找到自己写的一个service里,一看上面果然标注有@Transactional(readOnly = true),然后我将里面非update开头的但是执行有update操作的函数名全改了,但没改配置文件(总感觉原来配置文件也没配那么多东西),然后,还是报错。要改配置文件吗,我这牛性,就是不想改,然后又把所有涉及update的操作上面全都加上@Transactional,就近原则,这样事务处理应该不再按readonly处理了吧,运行,果然OK。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: