Senhores sei que é ridículo apresentar um erro de "java.lang.NullPointerException" e pedir ajuda!
Porem como é meu segundo dia com Struts estou tomando um banho!
Por isso preciso de ajuda!
Estou usando netbeans (Hibernate e Struts 2), to seguindo a apostila da caelum.
Está aparecendo o seguinte erro:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:501)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:432)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.27 logs.
package action;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
import com.opensymphony.xwork2.validator.annotations.Validations;
import dao.TarefaDAO;
import model.Tarefa;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
/* @author Mateus
* Tutorial Apostila Caelum
*/
@Validations(requiredStrings={
@RequiredStringValidator(fieldName="tarefa.descricao", message="Valor obrigatório")
})
public class AdicionaTarefasAction extends ActionSupport{
private Tarefa tarefa;
@Action(value = "adicionaTarefa", results = {
@Result(name = "ok", location = "tarefa-adicionada.jsp"),
@Result(name="input", location="/formulario-tarefas.jsp")
})
public String execute() {
new TarefaDAO().salvar(tarefa);
return "ok";
}
public Tarefa getTarefa() {
return this.tarefa;
}
public void setTarefa(Tarefa tarefa) {
this.tarefa = tarefa;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<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>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>