esse exercício não deu certo.
esse exercício não deu certo.
Qual o erro? Compartilha o código e ou Exception.
erro 404
IndexAction.java
package br.com.caelum.tarefas.action;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
public class IndexAction {
@Action(value="indice",results={
@Result(location="indice.jsp", name="ok") })
public String execute() {
System.out.println("Executando a lógica com Struts2");
return "ok";
}
}
web.xml
<web-app>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.
StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
indice.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>Hello World Strut 2</h1>
</body>
</html>
pasta lib asm-3.3.jar asm-commons-3.3.jar commons-fileupload-1.3.jar commons-io-2.2.jar commons-lang-2.4.jar commons-lang3-3.1.jar commons-logging-1.1.3.jar freemarker-2.3.19.jar javassist-3.11.0.GA.jar ognl-3.0.6.jar struts2-convention-plugin-2.3.16.jar struts2-core-2.3.16.jar xwork-core-2.3.16.jar
Mas além do "erro 404" há mais um direto no Eclipse, posta ele aí. Ela tem mais detalhes do problema.
Jan 06, 2014 12:32:37 PM org.apache.catalina.core.AprLifecycleListener init Informações: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-7-oracle/jre/lib/i386/server:/usr/lib/jvm/java-7-oracle/jre/lib/i386:/usr/lib/jvm/java-7-oracle/jre/../lib/i386:/usr/lib/jvm/java-7-oracle/jre/lib/i386/client:/usr/lib/jvm/java-7-oracle/jre/lib/i386::/usr/java/packages/lib/i386:/lib:/usr/lib Jan 06, 2014 12:32:37 PM org.apache.tomcat.util.digester.SetPropertiesRule begin Advertência: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:struts-tarefas' did not find a matching property. Jan 06, 2014 12:32:37 PM org.apache.coyote.AbstractProtocol init Informações: Initializing ProtocolHandler ["http-bio-8080"] Jan 06, 2014 12:32:37 PM org.apache.coyote.AbstractProtocol init Informações: Initializing ProtocolHandler ["ajp-bio-8009"] Jan 06, 2014 12:32:37 PM org.apache.catalina.startup.Catalina load Informações: Initialization processed in 1033 ms Jan 06, 2014 12:32:37 PM org.apache.catalina.core.StandardService startInternal Informações: Starting service Catalina Jan 06, 2014 12:32:37 PM org.apache.catalina.core.StandardEngine startInternal Informações: Starting Servlet Engine: Apache Tomcat/7.0.42 Jan 06, 2014 12:32:39 PM org.apache.catalina.core.StandardContext filterStart Grave: Exception starting filter struts2 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter. StrutsPrepareAndExecuteFilter at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:527) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:509) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:137) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260) at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:107) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744)
Jan 06, 2014 12:32:39 PM org.apache.catalina.core.StandardContext startInternal Grave: Error filterStart Jan 06, 2014 12:32:39 PM org.apache.catalina.core.StandardContext startInternal Grave: Context [/struts-tarefas] startup failed due to previous errors Jan 06, 2014 12:32:39 PM org.apache.coyote.AbstractProtocol start Informações: Starting ProtocolHandler ["http-bio-8080"] Jan 06, 2014 12:32:39 PM org.apache.coyote.AbstractProtocol start Informações: Starting ProtocolHandler ["ajp-bio-8009"] Jan 06, 2014 12:32:39 PM org.apache.catalina.startup.Catalina start Informações: Server startup in 1496 ms
Oi,
me parece que vc está com um problema no seu classpath:
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
Todos os JARS estão dentro da pasta WEB-INF/lib?
abs
Sim todos estão,
asm-3.3.jar
asm-commons-3.3.jar
commons-fileupload-1.3.jar
commons-io-2.2.jar
commons-lang-2.4.jar
commons-lang3-3.1.jar
commons-logging-1.1.3.jar
freemarker-2.3.19.jar
javassist-3.11.0.GA.jar
ognl-3.0.6.jar
struts2-convention-plugin-2.3.16.jar
struts2-core-2.3.16.jar
xwork-core-2.3.16.jar
ninguém tem esse projeto zipado o os jars desse projeto em um repositorio
Resolvi
mudei o web.xml para " org.apache.struts2.dispatcher.FilterDispatcher " dai para com o 404.
Ótimo Ellyson e obrigado por compartilhar a solução!