背景:java
用學生特價買了阿里雲的服務器一年,爲了練手,開始把畢業設計項目部署到該服務器上去。web
項目使用的技術:Struts2apache
服務器上用tomcat啓動該項目。tomcat
問題:服務器
在樓主本地啓動tomcat成功,tomcat能成功訪問,項目地址也能成功訪問。app
在服務器上啓動tomcat成功,tomcat能成功訪問,可是項目地址訪問報錯。因而查看服務器上tomcat目錄下/logs/catalina.out,發現報錯以下:webapp
1 ERROR Dispatcher Dispatcher initialization failed 2 Unable to load configuration. - bean - jar:file:/root/tomcat123/apache-tomcat-8.0.15/webapps/study/WEB-INF/lib/struts2-core-2.5.20.jar!/struts-default.xml:131:154 3 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) 4 at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:957) 5 at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:463) 6 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:496) 7 at org.apache.struts2.dispatcher.InitOperations.initDispatcher(InitOperations.java:73) 8 at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:61) 9 at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279) 10 at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260) 11 at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105) 12 at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4615) 13 at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5222) 14 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 15 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) 16 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) 17 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714) 18 at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:917) 19 at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1701) 20 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 21 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 22 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 23 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 24 at java.lang.Thread.run(Thread.java:748) 25 Caused by: Unable to load bean: type:com.opensymphony.xwork2.TextProviderFactory class:com.opensymphony.xwork2.StrutsTextProviderFactory - bean - jar:file:/root/tomcat123/apache-tomcat-8.0.15/webapps/study/WEB-INF/lib/struts2-core-2.5.20.jar!/struts-default.xml:131:154 26 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245) 27 at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:98) 28 at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234) 29 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67) 30 ... 21 more 31 Caused by: java.lang.IncompatibleClassChangeError: Implementing class 32 at java.lang.ClassLoader.defineClass1(Native Method) 33 at java.lang.ClassLoader.defineClass(ClassLoader.java:763) 34 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) 35 at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2452) 36 at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:854) 37 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1264) 38 at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1147) 39 at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:144) 40 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:216) 41 ... 24 more
網上處處搜索"Dispatcher initialization failed",然而沒有解決,又搜索"Unable to load configuration",仍是沒有解決。
因而想着本身再認真看一遍錯誤日誌,感受關鍵點在於"struts-default.xml:131:154"
趕忙打開該文件,截圖以下:ide
而後又網上找資料,有人說是包重複的問題,我只能本身檢查了,第131行,class="com.opensymphony.xwork2.StrutsTextProviderFactory",因而趕忙查看我引入的包中該class是否存在,而後發現問題:Struts2-core中有這個class,xwork-core中也有該class。阿里雲
查詢了一下,Struts2-core是基於xwork-core開發的。spa
個人解決方案:
刪除項目中引入的的xwork-core(能夠在刪除前備份一下,萬一不行呢)
重啓tomcat後,項目能正常訪問。
ps:至於本地啓動爲何沒報錯,我也不知,,,估計是環境的問題了