Olá pessoal,
debugei varias vezes mas não consigo visualizar o erro que está me dando
utilizando Struts.
na linha
LinkedList listaEventos = (LinkedList)s.getAttribute("listaben");
está com null
isso ocorre quando escolho a opção de alteração no jsp listaeventos
e chama AlterarEventosAction(alteraEventos.do)
INFO: Initialize action of type: br.com.wincomp.AlterarEventosAction
java.lang.NullPointerException
at br.com.wincomp.AlterarEventosAction.execute(AlterarEventosAction.java:35)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
–config
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<!-- ================================================ Form Bean Definitions -->
<form-beans>
<form-bean name ="salvarCursoForm" type="br.com.wincomp.SalvarCursoForm" />
<form-bean name ="incluirCursoForm" type="br.com.wincomp.IncluirCursoForm" />
<form-bean name ="incluirEventoForm" type="br.com.wincomp.IncluirEventoForm" />
<form-bean name ="salvarEventoForm" type="br.com.wincomp.SalvarEventoForm" />
</form-beans>
<!-- ========================================= Global Exception Definitions -->
<global-exceptions>
</global-exceptions>
<!-- =========================================== Global Forward Definitions -->
<global-forwards>
<!-- Default forward to "Welcome" action -->
<!-- Demonstrates using index.jsp to forward -->
<forward
name="welcome"
path="/Welcome.do"/>
<forward
name= "failure"
path="/pages/error.jsp"
redirect="false"
/>
</global-forwards>
<!-- =========================================== Action Mapping Definitions -->
<action-mappings>
<action path="/listaCursos"
scope="session"
type="br.com.wincomp.ListaCursosAction"
unknown="false" validate="false">
<forward name = "sucess" path="/pages/listacursos.jsp"/>
</action>
<action path="/listaEventos" scope="session" type="br.com.wincomp.ListaEventosAction"
unknown="false" validate="false">
<forward name = "sucess" path="/pages/listaeventos.jsp"/>
</action>
<action path="/alteraCursos" scope="session" type="br.com.wincomp.AlterarCursosAction"
unknown="false" validate="false">
<forward name = "sucess" path="/pages/alterarcursos.jsp"/>
</action>
<action attribute="salvarCursoForm"
input="/pages/alterarcursos.jsp"
name="salvarCursoForm"
path="/salvarCurso"
scope="session"
type="br.com.wincomp.SalvarCursoAction"
validate="true"
unknown="false" >
<forward
name = "sucess"
path="/pages/listacursos.jsp"
redirect="false"
/>
</action>
<action path="/incluirCurso"
scope="session"
type="br.com.wincomp.IncluirCursoAction"
validate="false"
unknown="false" >
<forward
name = "sucess"
path="/pages/incluircursos.jsp"
redirect="false"
/>
</action>
<action attribute="incluirCursoForm"
input ="/pages/incluircursos.jsp"
name="incluirCursoForm"
path="/incluirNovoCurso"
scope="session"
type="br.com.wincomp.SalvarNovoCursoAction"
validate="false"
unknown="false" >
<forward
name = "sucess"
path="/pages/listacursos.jsp"
redirect="false"
/>
</action>
<action path="/excluirCursos"
scope="session"
parameter="exclui"
type="br.com.wincomp.ExcluirCursoAction"
validate="false"
unknown="false" >
<forward
name = "sucess"
path="/pages/listacursos.jsp"
redirect="false"
/>
</action>
<action path="/listaEventos"
scope="session"
type="br.com.wincomp.ListaEventosAction"
unknown="false" validate="false">
<forward name = "sucess" path="/pages/listaeventos.jsp"/>
</action>
<action path="/excluirEventos"
scope="session"
parameter="exclui"
type="br.com.wincomp.ExcluirEventoAction"
validate="false"
unknown="false" >
<forward
name = "sucess"
path="/pages/listaeventos.jsp"
redirect="false"
/>
</action>
<action path="/incluirEvento"
scope="session"
type="br.com.wincomp.IncluirEventoAction"
validate="false"
unknown="false" >
<forward
name = "sucess"
path="/pages/incluireventos.jsp"
redirect="false"
/>
</action>
<action attribute="incluirEventoForm"
input ="/pages/incluireventos.jsp"
name="incluirEventoForm"
path="/incluirNovoEvento"
scope="session"
type="br.com.wincomp.SalvarNovoEventoAction"
validate="false"
unknown="false" >
<forward
name = "sucess"
path="/pages/listaeventos.jsp"
redirect="false"
/>
</action>
<action path="/alteraEventos" scope="session" type="br.com.wincomp.AlterarEventosAction"
unknown="false" validate="false">
<forward name = "sucess" path="/pages/alterareventos.jsp"/>
</action>
<action attribute="salvarEventoForm"
input="/pages/alterareventos.jsp"
name="salvarEventoForm"
path="/salvarEvento"
scope="session"
type="br.com.wincomp.SalvarEventoAction"
validate="true"
unknown="false" >
<forward
name = "sucess"
path="/pages/listaeventos.jsp"
redirect="false"
/>
</action>
</action-mappings>
<!-- ======================================== Message Resources Definitions -->
<message-resources parameter="MessageResources" />
</struts-config>
–INDEX.JSP
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<html:html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<LINK href="estilo.css" type ="text/css" rel="stylesheet">
<title>Primeiro exemplo do curso de J2EE con Struts</title>
<h2> Index.html</h2>
</head>
<body>
<table border="0">
<tr>
<td>
<html:link page="/listaCursos.do">Lista Curso</html:link>
</td>
</tr>
<tr>
<td>
<html:link page="/listaEventos.do">Lista Evento</html:link>
<td>
</tr>
</table>
</body>
</html:html >
–lista evento
<%@ page import = "br.com.wincomp.*" %>
<%@ page import = "java.util.*" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<logic:notPresent name = "listabean" scope="session">
<logic:redirect forward="error"/>
</logic:notPresent>
<html:html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<LINK href="estilo.css" type ="text/css" rel="stylesheet">
<title>Segundo exemplo do curso de J2EE con Struts</title>
</head>
<body>
<center>
<table border="0">
<tr bgcolor= whitesmoke>
<td width = "30%" >idevento</td>
<td width = "30%" >evento</td>
<td width = "30%" >dataEvento</td>
</tr>
<logic:iterate name="listabean" id="beanevento" type="br.com.wincomp.Eventos" >
<tr><td align="center">
<bean:write name="beanevento" property="idEvento"/>
</td>
<td>
<a > <%=beanevento.getEvento() %></a>
</td>
<td>
<bean:write name="beanevento" property="dataEvento"/>
</td>
<td>
<a >Excluir</a>
</td>
</tr>
</logic:iterate>
<tr bgcolor=white>
<td align="center" colspan=3>
<html:link page="/incluirEvento.do">Incluir Novo Evento</html:link>
</td>
</tr>
</table>
</center>
</body>
</html:html>