[置顶] 将项目从tomcat 迁移到JBoss
注:针对的是jboss5.0,其它版本没有测试过 ,主要参考了:http://www.diybl.com/course/3_program/java/javajs/20100719/460908.html,在些表示感谢
将项目从tomcat 迁移到JBoss,一般情况下会出现很多问题,下面是相关问题的记录及解决方法。
1. (1)首先要新增两个jar包:jboss-as-sprint-int-5.0.0.GA.jar 和 jboss-spring-int-vfs.jar
(2)然后在web.xml 文件中加上以下配置
<context-param>
<param-name>contextClass</param-name>
<param-value>
org.jboss.spring.vfs.context.VFSXmlWebApplicationContext
</param-value>
</context-param>
2. 在web.xml 文件中,如果spring 相关文件是按以下方式配置的:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext*.xml
</param-value>
</context-param>
则要改为如下形式:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext.xml,
classpath:applicationContext-compass.xml,
classpath:applicationContext-security.xml
</param-value>
</context-param>
3. 如果在其它的spring 配置文件(如applicationContext.xml等文件)中引用了xml 文件,如下
<import resource="quartz.xml"/>
则要将改为如下引入方式:
<import resource="classpath:quartz.xml"/>
4.启动时如果报类似如下错误,则将jboss common/lib 中 hibernate-validator.jar 删掉
Caused by: org.hibernate.AnnotationException: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:353)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1134)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:673)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 144 more
Caused by: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getDeclaredConstructor(Class.java:1985)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:343)
... 149 more
5.经过上4个步骤后,启动一般不会报错了,但在访问程序时,可能会报类似以下错误:
Stacktraces
java.lang.NoSuchMethodException: com.opensymphony.xwork2.ActionSupport.login()
java.lang.Class.getMethod(Class.java:1605)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.getActionMethod(AnnotationValidationInterceptor.java:75)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:47)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:169)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Thread.java:619)
(注,根据你具体访问的url,报的错可能不是com.opensymphony.xwork2.ActionSupport.login() 方法以,而是其它方法)
这个错误解决方法如下 (这样解决只是权宜之计,如果哪位有更好的解决办法,请告之下):
在classpath 路径下增加一个struts-plugin.xml 文件,内容如下 :
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<bean name="myActionConfigBuilder" type="org.apache.struts2.convention.ActionConfigBuilder"
class="com.etshop.struts.convention.MyActionConfigBuilder"/>
<constant name="struts.convention.actionConfigBuilder" value="myActionConfigBuilder"/>
</struts>
MActionConfigBuilder 源码如下 :
- <span style="font-size:18px;">package com.etshop.struts.convention;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.ArrayList;
- import java.util.HashSet;
- import java.util.List;
- import java.util.Set;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import org.apache.struts2.convention.PackageBasedActionConfigBuilder;
- import com.opensymphony.xwork2.ObjectFactory;
- import com.opensymphony.xwork2.config.Configuration;
- import com.opensymphony.xwork2.inject.Container;
- import com.opensymphony.xwork2.inject.Inject;
- import com.opensymphony.xwork2.util.finder.ClassFinder;
- import com.opensymphony.xwork2.util.finder.Test;
- /**
- *
- * 解决在JBoss 下不能找到 Action 问题
- *
- */
- public class MyActionConfigBuilder extends PackageBasedActionConfigBuilder {
- private static Log log = LogFactory.getLog(MyActionConfigBuilder.class);
- private static final String BASE_FILE = "applicationContext.xml";
- private String[] actionPackages;
- private String[] packageLocators;
- /**
- *
- * @param configuration
- * @param container
- * @param objectFactory
- * @param redirectToSlash
- * @param defaultParentPackage
- */
- @Inject
- public MyActionConfigBuilder(
- Configuration configuration,
- Container container,
- ObjectFactory objectFactory,
- @Inject("struts.convention.redirect.to.slash")
- String redirectToSlash,
- @Inject("struts.convention.default.parent.package")
- String defaultParentPackage) {
- super( configuration, container, objectFactory, redirectToSlash, defaultParentPackage );
- }
- /**
- *
- * @param actionPackages
- * (Optional) An optional list of action packages that this
- * should create
- *
- * configuration for.
- *
- */
- @Inject(value = "struts.convention.action.packages", required = false)
- public void setActionPackages(String actionPackages) {
- super.setActionPackages(actionPackages);
- if ( !"".equals( actionPackages.trim() ) ) {
- this.actionPackages = actionPackages.split( "\\s*[,]\\s*" );
- }
- }
- /**
- *
- * @param packageLocators
- * (Optional) A list of names used to find action packages.
- *
- */
- @Inject(value = "struts.convention.package.locators", required = false)
- public void setPackageLocators(String packageLocators) {
- super.setPackageLocators(packageLocators);
- this.packageLocators = packageLocators.split("\\s*[,]\\s*");
- }
- @Override
- @SuppressWarnings("unchecked")
- protected Set<Class> findActions() {
- Set<Class> classes = new HashSet<Class>();
- try {
- // ClassFinder finder = new ClassFinder(getClassLoaderForFinder(), buildUrls(), true);
- ClassFinder finder = new ClassFinder( getClassLoaderInterface(), buildUrls(), true);
- if (actionPackages != null) {
- for (String packageName : actionPackages) {
- Test<ClassFinder.ClassInfo> test = getPackageFinderTest(packageName);
- classes.addAll(finder.findClasses(test));
- }
- }
- // package locators
- if (packageLocators != null) {
- for (String packageLocator : packageLocators) {
- Test<ClassFinder.ClassInfo> test = getPackageLocatorTest(packageLocator);
- classes.addAll(finder.findClasses(test));
- }
- }
- } catch (Exception ex) {
- if (log.isErrorEnabled()) {
- log.error("Unable to scan named packages", ex);
- }
- }
- return classes;
- }
- private List<URL> buildUrls() throws MalformedURLException {
- List<URL> urls = new ArrayList<URL>();
- URL classesUrl = getClassLoader().getResource( BASE_FILE );
- if (classesUrl == null) {
- throw new IllegalStateException(
- "File " + BASE_FILE + " was not found. The folder WEB-INF/classes discovery base on file classes/" + BASE_FILE + ".");
- }
- String baseFilePath = classesUrl.getFile();
- URL url = new URL( "file", "", baseFilePath.substring( 0, baseFilePath.indexOf( BASE_FILE ) ) );
- if (log.isInfoEnabled()) {
- log.info("Struts2 ActionConfigBuilder, classes directory: " + url.getFile());
- }
- urls.add(url);
- return urls;
- }
- /*private ClassLoader getClassLoader() {
- return Thread.currentThread().getContextClassLoader();
- }*/
- }
- </span>
另注:以上过程都是通过在myEclipse中部署到jboss中的,接下来如果将程序导出为war包直接放到jboss下,启动时会报错,此时应该将war解压,将解压后的目录名后面加上.war,(如etshop.war包,解压后目录为etshop,将目录重命名为etshop.war)然后启动就不会报错了。
[置顶] 将项目从tomcat 迁移到JBoss的更多相关文章
- 将项目从tomcat 迁移到JBoss5.0
http://java-boy.iteye.com/blog/531411从Tomcat升级到JBoss5.1真是一个痛苦的过程,可能遇到很多问题.以下是我碰到的问题,及解决方法. 一.Hiberna ...
- tomcat 迁移到weblogic 问题
问题1: Caused by: java.lang.UnsupportedClassVersionError: com/audaque/datadiscovery/soap/service/impl/ ...
- Ionic-wechat项目边开发边学(四):可伸缩输入框,下拉刷新, 置顶删除
摘要 上一篇文章主要介绍了ion-list的使用, ion-popup的使用, 通过sass自定义样式, localStorage的使用, 自定义指令和服务. 这篇文章实现的功能有消息的置顶与删除, ...
- vue 移动端项目切换页面,页面置顶
之前项目是pc端是使用router的方式实现置顶的 //main.js router.afterEach((to, from, next) => { window.scrollTo(0, 0) ...
- IOS 作业项目 TableView两个section中cell置顶功能实现
点击cell会置顶,其他的下移
- Android的SwipeToDismiss第三方开源框架模拟QQ对话列表侧滑删除,置顶,将头像图片圆形化处理。
<Android SwipeToDismiss:左右滑动删除ListView条目Item> Android的SwipeToDismiss是github上一个第三方开源框架(github ...
- QQ好友列表向左滑动出现置顶、删除--第三方开源--SwipeMenuListView
SwipeMenuListView是在github上的第三方开源项目,该项目在github上的链接地址是:https://github.com/baoyongzhang/SwipeMenuListVi ...
- [置顶] 创建GitHub技术博客全攻略
[置顶] 创建GitHub技术博客全攻略 分类: GitHub2014-07-12 13:10 19710人阅读 评论(21) 收藏 举报 githubio技术博客网站生成 说明: 首先,你需要注册一 ...
- WPF实现只打开一个窗口,并且重复打开时已经打开的窗口置顶
内容来自:https://codereview.stackexchange.com/questions/20871/single-instance-wpf-application 第一步:添加Syst ...
随机推荐
- Nagios监控远端的mysql
工作原理: 利用特定的用户定期访问指定的mysql数据库.当不能访问或连不通时则报警. 1.在生产库上安装nagios插件 安装略 备注:编译完显示一定要有mysql支持,不然没有chec ...
- Effective C++:条款27——条款
条款27:尽量少做转型动作 单一对象可能拥有一个以上的地址!
- 仿iOS底部弹出popUpWindow
上面为弹出来的效果 popUpWindow布局: <?xml version="1.0" encoding="utf-8"?> <Linear ...
- PRINCE2七大原则(2)
PRINCE2七大原则(2) 我们先来回顾一下,PRINCE2七大原则分别是持续的业务验证,经验学习,角色与责任,按阶段管理,例外管理,关注产品,剪裁. 第二个原则:吸取经验教训. PRINCE2要求 ...
- javascript事件处理解析
一.什么是事件!(w3c解释) 事件是可以被 JavaScript 侦测到的行为. JavaScript 使我们有能力创建动态页面.事件是可以被 JavaScript 侦测到的行为. 网页中的每个元素 ...
- 山东理工大学第七届ACM校赛-飞花的糖果 分类: 比赛 2015-06-26 10:27 15人阅读 评论(0) 收藏
飞花的糖果 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 一日,飞花壕大手一挥,买了N个的两两不相同糖果,他想要拿出M个糖果送给他心仪 ...
- linux后台开发排错常用工具
一.前言 二.工具介绍 1.ps 查看进程信息 2.gstack 查看进程堆栈 3.pmap 查看程序分配的内存 4.ldd 查看程序用到的动态链接库 5.strace 用来跟踪和监视程序的每一个系统 ...
- Windows2003中IIS配置MVC提示HTTP错误 404-文件或目录未找到
Windows2003中IIS提示HTTP错误 404-文件或目录未找到 一.开启服务 启动服务“ASP.NET 状态服务”(ASP.NET State Service ),设置成“自动”. 设置完成 ...
- 2016-2017 CT S03E05: Codeforces Trainings Season 3 Episode 5 (2016 Stanford Local Programming Contest, Extended) B
链接:http://codeforces.com/gym/101116 学弟做的,以后再补 #include <iostream> #include <stdio.h> #in ...
- mvc api
===============================首页===================================================== 扫码 快递公司接口uri: ...