问题描述
myEclipse 7.5JDK: 1.6tomcat : 6.0拿着参考文档学:lib(commons-logging.jar,freemarker.jar,ognl.jar,struts2-core.jar,xwork.jar)后面又加了:commons-io-2.0.1.jar ,commons-lang-2.5.jarclasses(struts.xml)struts.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><package name="struts2" extends="struts-default"><action name="login" class="org.gxf.demo.LoginAction"><result name="success">/success.jsp</result></action></package></struts>web.xml:<?xml version="1.0" encoding="UTF-8"?><web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"><display-name>Struts2.0</display-name> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping></web-app>login.jsp:<%@ page language="java" contentType="text/html; charset=GBK"%><html><head><title>登录页面</title></head><body><!-- 提交请求参数的表单 --><form action="login.action" method="post"><table align="center"><caption>用户登录</caption><tr><td>用户名:<input type="text" name="username" /></td></tr><tr><td>密 码:<input type="text" name="password" /></td></tr><tr align="center"><td colspan="2"><input type="submit" value="登录" /><input type="reset" value="重填" /></td></tr></table></form></body></html>public class LoginAction {private String username;private String password;public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public String execute() throws Exception{if("hello".equals(getUsername())){return "success";}else{return "fail";}}}error:2011-12-16 15:45:23 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory struts2study2011-12-16 15:45:25 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info信息: Parsing configuration file [struts-default.xml]2011-12-16 15:45:26 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info信息: Parsing configuration file [struts-plugin.xml]2011-12-16 15:45:26 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error严重: Dispatcher initialization failedUnable to load configuration. - bean - jar:file:/D:/apache-tomcat-6.0.24/webapps/struts2study/WEB-INF/lib/struts2-gxp-plugin-2.3.1.jar!/struts-plugin.xml:8:162at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:436)at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:195)at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488)at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041)at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964)at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)at org.apache.catalina.core.StandardService.start(StandardService.java:516)at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)at org.apache.catalina.startup.Catalina.start(Catalina.java:593)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)Caused by: Unable to load bean: type:org.apache.struts2.views.gxp.inject.InjectedObjectContainer class:org.apache.struts2.views.gxp.inject.InjectedObjectContainer - bean - jar:file:/D:/apache-tomcat-6.0.24/webapps/struts2study/WEB-INF/lib/struts2-gxp-plugin-2.3.1.jar!/struts-plugin.xml:8:162at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:235)at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:180)at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)... 30 moreCaused by: java.lang.ClassNotFoundException: org.apache.struts2.views.gxp.inject.InjectedObjectContainerat org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1484)at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1329)at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:157)at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:206)... 33 more2011-12-16 15:45:26 org.apache.catalina.core.StandardContext filterStart严重: Exception starting filter struts2Unable to load configuration. - bean - jar:file:/D:/apache-tomcat-6.0.24/webapps/struts2study/WEB-INF/lib/struts2-gxp-plugin-2.3.1.jar!/struts-plugin.xml:8:162at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:449)at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:195)at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488)at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041)at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964)at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)at org.apache.catalina.core.StandardService.start(StandardService.java:516)at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)at org.apache.catalina.startup.Catalina.start(Catalina.java:593)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)Caused by: Unable to load configuration. - bean - jar:file:/D:/apache-tomcat-6.0.24/webapps/struts2study/WEB-INF/lib/struts2-gxp-plugin-2.3.1.jar!/struts-plugin.xml:8:162at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:436)... 28 moreCaused by: Unable to load bean: type:org.apache.struts2.views.gxp.inject.InjectedObjectContainer class:org.apache.struts2.views.gxp.inject.InjectedObjectContainer - bean - jar:file:/D:/apache-tomcat-6.0.24/webapps/struts2study/WEB-INF/lib/struts2-gxp-plugin-2.3.1.jar!/struts-plugin.xml:8:162at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:235)at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:180)at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)... 30 moreCaused by: java.lang.ClassNotFoundException: org.apache.struts2.views.gxp.inject.InjectedObjectContainerat org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1484)at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1329)at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:157)at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:206)... 33 more2011-12-16 15:45:26 org.apache.catalina.core.StandardContext start严重: Error filterStart2011-12-16 15:45:26 org.apache.catalina.core.StandardContext start严重: Context [/struts2study] startup failed due to previous errors 问题补充:xiaolv 写道
解决方案
Unable to load configuration. - bean - jar:file:/D:/apache-tomcat-6.0.24/webapps/struts2study/WEB-INF/lib/struts2-gxp-plugin-2.3.1.jar!/struts-plugin.xml:8:162 lib库加多了吧,或者没有在tomcat下删除多余的lib库,把tomcat下项目删除重新部署一下。看一下ognl是什么版本,有需要加入这个包javassist-3.7.ga.jar
解决方案二:
谢谢,两位~
解决方案三:
新的错误是什么呢,还报错不一定报的是上一个错误,上一个错误Unable to load configuration. - bean - jar:file:/D:/apache-tomcat-6.0.24/webapps/struts2study/WEB-INF/lib/struts2-gxp-plugin-2.3.1.jar!/struts-plugin.xml:8:162 现在的错误有事什么呢?
解决方案四:
别着急 你重新建一个web看能不能跑起来然后导jar 写struts.xml web.xml 写jsp 看到底哪里的问题!
解决方案五:
struts.xml看着书上手敲的?
解决方案六:
你的包引多了,也会报错的把D:/apache-tomcat-6.0.24/webapps/struts2study/WEB-INF/lib/用不到的包删除掉
解决方案七:
debug能不能跳转到action中?