[置顶] 将项目从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 ...
随机推荐
- Oracle:Authid Current_User使用
由于用户拥有的role权限在存储过程是不可用的.遇到这种情况,我们一般需要显示授权,如grant create table to user;但这种方法太麻烦,有时候可能需要进行非常多的授权才能执行存储 ...
- XCode5 真机调试及发布应用
一.XCODE 真机测试 Xcode5已经很智能,只需生成一个开发证书,安装后,插入设备会自动添加,注意,当Mac系统升级后,证书需要重新生成. 证书生成步骤: 1.生成 CertificateSig ...
- [Ogre][地形][原创]基于OgreTerrain的地形实现
需要用到的外部图片资源: 在ogre调用时需要多用到的几个外部dll: OgreTerrain_d.dll 需要添加头文件 #include "Ogre\Ogre.h"#inclu ...
- 修改tomcat的logo
每页的<head> 里添加 <link rel="icon" href="favicon.gif" /> 图片名称必须是favi ...
- Bean的生命周期
Bean的生命周期 原文:http://997004049-qq-com.iteye.com/blog/1729793 任何一个事物都有自己的生命周期,生命的开始.生命中.生命结束.大家最熟悉的应该是 ...
- [美]莫提默 J. 艾德勒《如何阅读一本书》
我最近在阅读一本书,这本书的书名叫<如何阅读一本书>(商务出版社,2015),顾名思义. 作者认为,阅读是一件跟写书一样复杂的活动,而许多人并不会阅读. 看过后,你可能会有“我真没 ...
- Linux 系统裁剪
一.前言 Linux操作系统至1991.10.5号诞生以来,就源其开源性和自由性得到了很多技术大牛的青睐,每个Linux爱好者都为其贡献了自己的一份力,不管是在Linux内核还是开源软件等方面,都为 ...
- Web文件的ContentType类型收集
".*"="application/octet-stream"".001"="application/x-001"&qu ...
- Cacti中文版在Centos上的安装
最近老有人问Cacti中文版在哪下载啊怎么安装啊,我在这里一遍给大家讲解了:Cacti中文版在Centos上的安装 1.基本安装 cacti是运作在apache+php+mysql+net-snmp工 ...
- 我的android学习经历17
tomcat的下载安装 1.下载tomcat 在百度中输入tomcat可以直接出现他的英文官网 http://tomcat.apache.org/ 进去以后选择与你的java版本相匹配的tomcat ...