Struts问题排除
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
@Override public String execute() throws Exception { log.info("execute"); return SUCCESS; }
@Override public void validate() { log.info("validate"); } }
部署在 tomcat 下,问题: 警告: Unable to load config class org.apache.struts2.jsf.FacesSetupInterceptor at interceptor jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/strut s2-jsf-plugin-2.1.8.1.jar!/struts-plugin.xml:35:97 probably due to a missing jar, which might be fine if you never plan to use the jsfSetup
解决 删除:struts2-portlet-plugin-2.1.8.1.jar
问题: 严重: Dispatcher initialization failed java.lang.NullPointerException at
org.apache.struts2.osgi.OsgiConfigurationProvider.init(OsgiConfigurat ionProvider.java:70) 解决: 删除:struts2-osgi-plugin-2.1.8.1.jar
问题: 严重: Dispatcher initialization failed java.lang.RuntimeException: java.lang.RuntimeException: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyExcepti on: No mapping found for dependency [type=java.lang.String, name='actionPackages'] in public void org.apache.struts2.config.ClasspathPackageProvider.setActionPackages( java.lang.String). at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBui lder.java:132) 解决: 修改 web.xml: <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filterclass>
src 下新建 com.ghl.HelloWorld.java: package com.ghl;
import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory;
<init-param> <param-name>actionPackages</param-name> <param-value>com.ghl</param-value> </init-param> </filter>
问题: 警告: Could not find action or result There is no Action mapped for namespace / and action name HelloWorld. [unknown location] at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy .java:178) 解决: 把 struts.xml 文件放到 WEB-INF/classes 目录下
interceptor 2010-6-10 14:14:21 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error 严重: Actual exception Could not load class org.apache.struts2.jsf.FacesSetupInterceptor. Perhaps it exists but certain dependencies are not available? interceptor jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/strut s2-jsf-plugin-2.1.8.1.jar!/struts-plugin.xml:35:97 at com.opensymphony.xwork2.ObjectFactory.buildInterceptor(ObjectFactory. java:202)
public class HelloWorld extends ActionSupport{ /** * */ private static final long serialVersionUID = -6452565149473931988L; Logger log = LoggerFactory.getLogger(HelloWorld.class);
在 WEB-INF 下新建 applicationContext.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans>
查看文章 struts 全包导入遇到的问题 2010-06-10 15:27 web.xml 如下: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>SS</display-name>
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener </listener-class> </listener>
<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filterclass> </filter>
</beans>
src 下新建 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="default" namespace="/" extends="struts-default"> <action name="HelloWorld" class="com.ghl.HelloWorld"> <result name="success">/success.jsp</result> </action> </package> <include file="user.xml"></include> </struts>
问题: java.lang.NoSuchMethodException: com.ghl.HelloWorld.index() java.lang.Class.getMethod(Unknown Source)
源自文库
org.apache.struts2.interceptor.validation.AnnotationValidationInterce ptor.getActionMethod(AnnotationValidationInterceptor.java:75) 解决: HelloWorld.java 中追加方法: public String index(){ log.info("index"); return SUCCESS; }
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
解决: 删除:struts2-jsf-plugin-2.1.8.1.jar
问题: 警告: Unable to load config class org.apache.struts2.portlet.interceptor.PortletAwareInterceptor at interceptor jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/strut s2-portlet-plugin-2.1.8.1.jar!/struts-plugin.xml:48:114 probably due to a missing jar, which might be fine if you never plan to use the portletAware interceptor 2010-6-10 14:16:37 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error 严重: Actual exception Could not load class org.apache.struts2.portlet.interceptor.PortletAwareInterceptor. Perhaps it exists but certain dependencies are not available? interceptor jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/strut s2-portlet-plugin-2.1.8.1.jar!/struts-plugin.xml:48:114 at com.opensymphony.xwork2.ObjectFactory.buildInterceptor(ObjectFactory. java:202)
@Override public void validate() { log.info("validate"); } }
部署在 tomcat 下,问题: 警告: Unable to load config class org.apache.struts2.jsf.FacesSetupInterceptor at interceptor jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/strut s2-jsf-plugin-2.1.8.1.jar!/struts-plugin.xml:35:97 probably due to a missing jar, which might be fine if you never plan to use the jsfSetup
解决 删除:struts2-portlet-plugin-2.1.8.1.jar
问题: 严重: Dispatcher initialization failed java.lang.NullPointerException at
org.apache.struts2.osgi.OsgiConfigurationProvider.init(OsgiConfigurat ionProvider.java:70) 解决: 删除:struts2-osgi-plugin-2.1.8.1.jar
问题: 严重: Dispatcher initialization failed java.lang.RuntimeException: java.lang.RuntimeException: com.opensymphony.xwork2.inject.DependencyException: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyExcepti on: No mapping found for dependency [type=java.lang.String, name='actionPackages'] in public void org.apache.struts2.config.ClasspathPackageProvider.setActionPackages( java.lang.String). at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBui lder.java:132) 解决: 修改 web.xml: <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filterclass>
src 下新建 com.ghl.HelloWorld.java: package com.ghl;
import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.util.logging.Logger; import com.opensymphony.xwork2.util.logging.LoggerFactory;
<init-param> <param-name>actionPackages</param-name> <param-value>com.ghl</param-value> </init-param> </filter>
问题: 警告: Could not find action or result There is no Action mapped for namespace / and action name HelloWorld. [unknown location] at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy .java:178) 解决: 把 struts.xml 文件放到 WEB-INF/classes 目录下
interceptor 2010-6-10 14:14:21 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error 严重: Actual exception Could not load class org.apache.struts2.jsf.FacesSetupInterceptor. Perhaps it exists but certain dependencies are not available? interceptor jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/strut s2-jsf-plugin-2.1.8.1.jar!/struts-plugin.xml:35:97 at com.opensymphony.xwork2.ObjectFactory.buildInterceptor(ObjectFactory. java:202)
public class HelloWorld extends ActionSupport{ /** * */ private static final long serialVersionUID = -6452565149473931988L; Logger log = LoggerFactory.getLogger(HelloWorld.class);
在 WEB-INF 下新建 applicationContext.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans>
查看文章 struts 全包导入遇到的问题 2010-06-10 15:27 web.xml 如下: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>SS</display-name>
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener </listener-class> </listener>
<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filterclass> </filter>
</beans>
src 下新建 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="default" namespace="/" extends="struts-default"> <action name="HelloWorld" class="com.ghl.HelloWorld"> <result name="success">/success.jsp</result> </action> </package> <include file="user.xml"></include> </struts>
问题: java.lang.NoSuchMethodException: com.ghl.HelloWorld.index() java.lang.Class.getMethod(Unknown Source)
源自文库
org.apache.struts2.interceptor.validation.AnnotationValidationInterce ptor.getActionMethod(AnnotationValidationInterceptor.java:75) 解决: HelloWorld.java 中追加方法: public String index(){ log.info("index"); return SUCCESS; }
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
解决: 删除:struts2-jsf-plugin-2.1.8.1.jar
问题: 警告: Unable to load config class org.apache.struts2.portlet.interceptor.PortletAwareInterceptor at interceptor jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/strut s2-portlet-plugin-2.1.8.1.jar!/struts-plugin.xml:48:114 probably due to a missing jar, which might be fine if you never plan to use the portletAware interceptor 2010-6-10 14:16:37 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error 严重: Actual exception Could not load class org.apache.struts2.portlet.interceptor.PortletAwareInterceptor. Perhaps it exists but certain dependencies are not available? interceptor jar:file:/D:/ghl/apache-tomcat-6.0.20/wtpwebapps/SS/WEB-INF/lib/strut s2-portlet-plugin-2.1.8.1.jar!/struts-plugin.xml:48:114 at com.opensymphony.xwork2.ObjectFactory.buildInterceptor(ObjectFactory. java:202)