注:针对的是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 源码如下 :

  1. <span style="font-size:18px;">package com.etshop.struts.convention;
  2. import java.net.MalformedURLException;
  3. import java.net.URL;
  4. import java.util.ArrayList;
  5. import java.util.HashSet;
  6. import java.util.List;
  7. import java.util.Set;
  8. import org.apache.commons.logging.Log;
  9. import org.apache.commons.logging.LogFactory;
  10. import org.apache.struts2.convention.PackageBasedActionConfigBuilder;
  11. import com.opensymphony.xwork2.ObjectFactory;
  12. import com.opensymphony.xwork2.config.Configuration;
  13. import com.opensymphony.xwork2.inject.Container;
  14. import com.opensymphony.xwork2.inject.Inject;
  15. import com.opensymphony.xwork2.util.finder.ClassFinder;
  16. import com.opensymphony.xwork2.util.finder.Test;
  17. /**
  18. *
  19. * 解决在JBoss 下不能找到 Action 问题
  20. *
  21. */
  22. public class MyActionConfigBuilder extends PackageBasedActionConfigBuilder {
  23. private static Log log = LogFactory.getLog(MyActionConfigBuilder.class);
  24. private static final String BASE_FILE = "applicationContext.xml";
  25. private String[] actionPackages;
  26. private String[] packageLocators;
  27. /**
  28. *
  29. * @param configuration
  30. * @param container
  31. * @param objectFactory
  32. * @param redirectToSlash
  33. * @param defaultParentPackage
  34. */
  35. @Inject
  36. public MyActionConfigBuilder(
  37. Configuration configuration,
  38. Container container,
  39. ObjectFactory objectFactory,
  40. @Inject("struts.convention.redirect.to.slash")
  41. String redirectToSlash,
  42. @Inject("struts.convention.default.parent.package")
  43. String defaultParentPackage) {
  44. super( configuration, container, objectFactory, redirectToSlash, defaultParentPackage );
  45. }
  46. /**
  47. *
  48. * @param actionPackages
  49. *            (Optional) An optional list of action packages that this
  50. *            should create
  51. *
  52. * configuration for.
  53. *
  54. */
  55. @Inject(value = "struts.convention.action.packages", required = false)
  56. public void setActionPackages(String actionPackages) {
  57. super.setActionPackages(actionPackages);
  58. if ( !"".equals( actionPackages.trim() ) ) {
  59. this.actionPackages = actionPackages.split( "\\s*[,]\\s*" );
  60. }
  61. }
  62. /**
  63. *
  64. * @param packageLocators
  65. *            (Optional) A list of names used to find action packages.
  66. *
  67. */
  68. @Inject(value = "struts.convention.package.locators", required = false)
  69. public void setPackageLocators(String packageLocators) {
  70. super.setPackageLocators(packageLocators);
  71. this.packageLocators = packageLocators.split("\\s*[,]\\s*");
  72. }
  73. @Override
  74. @SuppressWarnings("unchecked")
  75. protected Set<Class> findActions() {
  76. Set<Class> classes = new HashSet<Class>();
  77. try {
  78. //          ClassFinder finder = new ClassFinder(getClassLoaderForFinder(), buildUrls(), true);
  79. ClassFinder finder = new ClassFinder( getClassLoaderInterface(), buildUrls(), true);
  80. if (actionPackages != null) {
  81. for (String packageName : actionPackages) {
  82. Test<ClassFinder.ClassInfo> test = getPackageFinderTest(packageName);
  83. classes.addAll(finder.findClasses(test));
  84. }
  85. }
  86. // package locators
  87. if (packageLocators != null) {
  88. for (String packageLocator : packageLocators) {
  89. Test<ClassFinder.ClassInfo> test = getPackageLocatorTest(packageLocator);
  90. classes.addAll(finder.findClasses(test));
  91. }
  92. }
  93. } catch (Exception ex) {
  94. if (log.isErrorEnabled()) {
  95. log.error("Unable to scan named packages", ex);
  96. }
  97. }
  98. return classes;
  99. }
  100. private List<URL> buildUrls() throws MalformedURLException {
  101. List<URL> urls = new ArrayList<URL>();
  102. URL classesUrl = getClassLoader().getResource( BASE_FILE );
  103. if (classesUrl == null) {
  104. throw new IllegalStateException(
  105. "File " + BASE_FILE + " was not found. The folder WEB-INF/classes discovery base on file classes/" + BASE_FILE + ".");
  106. }
  107. String baseFilePath = classesUrl.getFile();
  108. URL url = new URL( "file", "", baseFilePath.substring( 0, baseFilePath.indexOf( BASE_FILE ) ) );
  109. if (log.isInfoEnabled()) {
  110. log.info("Struts2 ActionConfigBuilder, classes directory: " + url.getFile());
  111. }
  112. urls.add(url);
  113. return urls;
  114. }
  115. /*private ClassLoader getClassLoader() {
  116. return Thread.currentThread().getContextClassLoader();
  117. }*/
  118. }
  119. </span>

另注:以上过程都是通过在myEclipse中部署到jboss中的,接下来如果将程序导出为war包直接放到jboss下,启动时会报错,此时应该将war解压,将解压后的目录名后面加上.war,(如etshop.war包,解压后目录为etshop,将目录重命名为etshop.war)然后启动就不会报错了。

[置顶] 将项目从tomcat 迁移到JBoss的更多相关文章

  1. 将项目从tomcat 迁移到JBoss5.0

    http://java-boy.iteye.com/blog/531411从Tomcat升级到JBoss5.1真是一个痛苦的过程,可能遇到很多问题.以下是我碰到的问题,及解决方法. 一.Hiberna ...

  2. tomcat 迁移到weblogic 问题

    问题1: Caused by: java.lang.UnsupportedClassVersionError: com/audaque/datadiscovery/soap/service/impl/ ...

  3. Ionic-wechat项目边开发边学(四):可伸缩输入框,下拉刷新, 置顶删除

    摘要 上一篇文章主要介绍了ion-list的使用, ion-popup的使用, 通过sass自定义样式, localStorage的使用, 自定义指令和服务. 这篇文章实现的功能有消息的置顶与删除, ...

  4. vue 移动端项目切换页面,页面置顶

    之前项目是pc端是使用router的方式实现置顶的 //main.js router.afterEach((to, from, next) => { window.scrollTo(0, 0) ...

  5. IOS 作业项目 TableView两个section中cell置顶功能实现

    点击cell会置顶,其他的下移

  6. Android的SwipeToDismiss第三方开源框架模拟QQ对话列表侧滑删除,置顶,将头像图片圆形化处理。

      <Android SwipeToDismiss:左右滑动删除ListView条目Item> Android的SwipeToDismiss是github上一个第三方开源框架(github ...

  7. QQ好友列表向左滑动出现置顶、删除--第三方开源--SwipeMenuListView

    SwipeMenuListView是在github上的第三方开源项目,该项目在github上的链接地址是:https://github.com/baoyongzhang/SwipeMenuListVi ...

  8. [置顶] 创建GitHub技术博客全攻略

    [置顶] 创建GitHub技术博客全攻略 分类: GitHub2014-07-12 13:10 19710人阅读 评论(21) 收藏 举报 githubio技术博客网站生成 说明: 首先,你需要注册一 ...

  9. WPF实现只打开一个窗口,并且重复打开时已经打开的窗口置顶

    内容来自:https://codereview.stackexchange.com/questions/20871/single-instance-wpf-application 第一步:添加Syst ...

随机推荐

  1. Nagios监控远端的mysql

    工作原理: 利用特定的用户定期访问指定的mysql数据库.当不能访问或连不通时则报警. 1.在生产库上安装nagios插件    安装略    备注:编译完显示一定要有mysql支持,不然没有chec ...

  2. Effective C++:条款27——条款

    条款27:尽量少做转型动作 单一对象可能拥有一个以上的地址!

  3. 仿iOS底部弹出popUpWindow

    上面为弹出来的效果 popUpWindow布局: <?xml version="1.0" encoding="utf-8"?> <Linear ...

  4. PRINCE2七大原则(2)

    PRINCE2七大原则(2) 我们先来回顾一下,PRINCE2七大原则分别是持续的业务验证,经验学习,角色与责任,按阶段管理,例外管理,关注产品,剪裁. 第二个原则:吸取经验教训. PRINCE2要求 ...

  5. javascript事件处理解析

    一.什么是事件!(w3c解释) 事件是可以被 JavaScript 侦测到的行为. JavaScript 使我们有能力创建动态页面.事件是可以被 JavaScript 侦测到的行为. 网页中的每个元素 ...

  6. 山东理工大学第七届ACM校赛-飞花的糖果 分类: 比赛 2015-06-26 10:27 15人阅读 评论(0) 收藏

    飞花的糖果 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 一日,飞花壕大手一挥,买了N个的两两不相同糖果,他想要拿出M个糖果送给他心仪 ...

  7. linux后台开发排错常用工具

    一.前言 二.工具介绍 1.ps 查看进程信息 2.gstack 查看进程堆栈 3.pmap 查看程序分配的内存 4.ldd 查看程序用到的动态链接库 5.strace 用来跟踪和监视程序的每一个系统 ...

  8. Windows2003中IIS配置MVC提示HTTP错误 404-文件或目录未找到

    Windows2003中IIS提示HTTP错误 404-文件或目录未找到 一.开启服务 启动服务“ASP.NET 状态服务”(ASP.NET State Service ),设置成“自动”. 设置完成 ...

  9. 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 ...

  10. mvc api

    ===============================首页===================================================== 扫码 快递公司接口uri: ...