jbmsegundo 3 de out. de 2010
Seu arquivo de configura ção do struts ta nesse lugar que ele procura ?
Seu arquivo de configuração do struts ta nesse lugar que ele procura?
lucas.campos 3 de out. de 2010
EU já arrumei isso, mas continua dando problema:
03 / 10 / 2010 11 : 18 : 23 org . apache . catalina . core . AprLifecycleListener init
INFO : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java . library . path : C : \ Users \ Nathalia \ Documents \ Lucas \ bin ;.; C : \ Windows \ Sun \ Java \ bin ; C : \ Windows \ system32 ; C : \ Windows ; C : / Users / Nathalia / Documents / Lucas / bin / client ; C : / Users / Nathalia / Documents / Lucas / bin ; C : / Users / Nathalia / Documents / Lucas / lib / i386 ; C : \ Windows \ system32 ; C : \ Windows ; C : \ Windows \ System32 \ Wbem ; C : \ Windows \ System32 \ WindowsPowerShell \ v1 .0 \
03 / 10 / 2010 11 : 18 : 23 org . apache . tomcat . util . digester . SetPropertiesRule begin
AVISO : [ SetPropertiesRule ] { Server / Service / Engine / Host / Context } Setting property 'source' to 'org.eclipse.jst.jee.server:ExemploStruts' did not find a matching property .
03 / 10 / 2010 11 : 18 : 24 org . apache . coyote . http11 . Http11Protocol init
INFO : Initializing Coyote HTTP / 1.1 on http - 8080
03 / 10 / 2010 11 : 18 : 24 org . apache . catalina . startup . Catalina load
INFO : Initialization processed in 997 ms
03 / 10 / 2010 11 : 18 : 24 org . apache . catalina . core . StandardService start
INFO : Starting service Catalina
03 / 10 / 2010 11 : 18 : 24 org . apache . catalina . core . StandardEngine start
INFO : Starting Servlet Engine : Apache Tomcat / 6.0.26
03 / 10 / 2010 11 : 18 : 25 org . apache . struts . action . ActionServlet initChain
INFO : Loading chain catalog from jar : file : / C : / Users / Nathalia / workspace / . metadata / . plugins / org . eclipse . wst . server . core / tmp0 / wtpwebapps / ExemploStruts / WEB - INF / lib / struts - core - 1.3.10 . jar ! / org / apache / struts / chain / chain - config . xml
03 / 10 / 2010 11 : 18 : 26 org . apache . coyote . http11 . Http11Protocol start
INFO : Starting Coyote HTTP / 1.1 on http - 8080
03 / 10 / 2010 11 : 18 : 26 org . apache . jk . common . ChannelSocket init
INFO : JK : ajp13 listening on / 0.0.0.0 : 8009
03 / 10 / 2010 11 : 18 : 26 org . apache . jk . server . JkMain start
INFO : Jk running ID = 0 time = 0 / 94 config = null
03 / 10 / 2010 11 : 18 : 26 org . apache . catalina . startup . Catalina start
INFO : Server startup in 2183 ms
03 / 10 / 2010 11 : 18 : 32 org . apache . struts . chain . ComposableRequestProcessor init
INFO : Initializing composable request processor for module prefix ''
03 / 10 / 2010 11 : 18 : 32 org . apache . struts . chain . commands . servlet . CreateAction createAction
INFO : Initialize action of type : java . teste . TesteSimplesAction
03 / 10 / 2010 11 : 18 : 32 org . apache . struts . chain . commands . AbstractExceptionHandler execute
AVISO : Unhandled exception
java . lang . ClassNotFoundException : java . teste . TesteSimplesAction
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1516 )
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1361 )
at org . apache . struts . chain . commands . util . ClassUtils . getApplicationClass ( ClassUtils . java : 54 )
at org . apache . struts . chain . commands . util . ClassUtils . getApplicationInstance ( ClassUtils . java : 71 )
at org . apache . struts . chain . commands . servlet . CreateAction . createAction ( CreateAction . java : 98 )
at org . apache . struts . chain . commands . servlet . CreateAction . getAction ( CreateAction . java : 68 )
at org . apache . struts . chain . commands . AbstractCreateAction . execute ( AbstractCreateAction . java : 91 )
at org . apache . struts . chain . commands . ActionCommandBase . execute ( ActionCommandBase . java : 51 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
at org . apache . commons . chain . generic . LookupCommand . execute ( LookupCommand . java : 305 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
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 : 617 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 290 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 233 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 191 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 127 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 102 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 109 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 298 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 852 )
at org . apache . coyote . http11 . Http11Protocol $ Http11ConnectionHandler . process ( Http11Protocol . java : 588 )
at org . apache . tomcat . util . net . JIoEndpoint $ Worker . run ( JIoEndpoint . java : 489 )
at java . lang . Thread . run ( Unknown Source )
03 / 10 / 2010 11 : 18 : 32 org . apache . struts . chain . commands . ExceptionCatcher postprocess
AVISO : Exception from exceptionCommand 'servlet-exception'
java . lang . ClassNotFoundException : java . teste . TesteSimplesAction
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1516 )
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1361 )
at org . apache . struts . chain . commands . util . ClassUtils . getApplicationClass ( ClassUtils . java : 54 )
at org . apache . struts . chain . commands . util . ClassUtils . getApplicationInstance ( ClassUtils . java : 71 )
at org . apache . struts . chain . commands . servlet . CreateAction . createAction ( CreateAction . java : 98 )
at org . apache . struts . chain . commands . servlet . CreateAction . getAction ( CreateAction . java : 68 )
at org . apache . struts . chain . commands . AbstractCreateAction . execute ( AbstractCreateAction . java : 91 )
at org . apache . struts . chain . commands . ActionCommandBase . execute ( ActionCommandBase . java : 51 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
at org . apache . commons . chain . generic . LookupCommand . execute ( LookupCommand . java : 305 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
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 : 617 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 290 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 233 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 191 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 127 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 102 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 109 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 298 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 852 )
at org . apache . coyote . http11 . Http11Protocol $ Http11ConnectionHandler . process ( Http11Protocol . java : 588 )
at org . apache . tomcat . util . net . JIoEndpoint $ Worker . run ( JIoEndpoint . java : 489 )
at java . lang . Thread . run ( Unknown Source )
03 / 10 / 2010 11 : 18 : 32 org . apache . catalina . core . StandardWrapperValve invoke
GRAVE : Servlet . service () for servlet testeDeStruts threw exception
java . lang . ClassNotFoundException : java . teste . TesteSimplesAction
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1516 )
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1361 )
at org . apache . struts . chain . commands . util . ClassUtils . getApplicationClass ( ClassUtils . java : 54 )
at org . apache . struts . chain . commands . util . ClassUtils . getApplicationInstance ( ClassUtils . java : 71 )
at org . apache . struts . chain . commands . servlet . CreateAction . createAction ( CreateAction . java : 98 )
at org . apache . struts . chain . commands . servlet . CreateAction . getAction ( CreateAction . java : 68 )
at org . apache . struts . chain . commands . AbstractCreateAction . execute ( AbstractCreateAction . java : 91 )
at org . apache . struts . chain . commands . ActionCommandBase . execute ( ActionCommandBase . java : 51 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
at org . apache . commons . chain . generic . LookupCommand . execute ( LookupCommand . java : 305 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
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 : 617 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 290 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 233 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 191 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 127 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 102 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 109 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 298 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 852 )
at org . apache . coyote . http11 . Http11Protocol $ Http11ConnectionHandler . process ( Http11Protocol . java : 588 )
at org . apache . tomcat . util . net . JIoEndpoint $ Worker . run ( JIoEndpoint . java : 489 )
at java . lang . Thread . run ( Unknown Source )
03 / 10 / 2010 11 : 18 : 59 org . apache . struts . chain . commands . servlet . CreateAction createAction
INFO : Initialize action of type : java . teste . TesteSimplesAction
03 / 10 / 2010 11 : 18 : 59 org . apache . struts . chain . commands . AbstractExceptionHandler execute
AVISO : Unhandled exception
java . lang . ClassNotFoundException : java . teste . TesteSimplesAction
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1516 )
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1361 )
at org . apache . struts . chain . commands . util . ClassUtils . getApplicationClass ( ClassUtils . java : 54 )
at org . apache . struts . chain . commands . util . ClassUtils . getApplicationInstance ( ClassUtils . java : 71 )
at org . apache . struts . chain . commands . servlet . CreateAction . createAction ( CreateAction . java : 98 )
at org . apache . struts . chain . commands . servlet . CreateAction . getAction ( CreateAction . java : 68 )
at org . apache . struts . chain . commands . AbstractCreateAction . execute ( AbstractCreateAction . java : 91 )
at org . apache . struts . chain . commands . ActionCommandBase . execute ( ActionCommandBase . java : 51 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
at org . apache . commons . chain . generic . LookupCommand . execute ( LookupCommand . java : 305 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
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 : 617 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 290 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 233 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 191 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 127 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 102 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 109 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 298 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 852 )
at org . apache . coyote . http11 . Http11Protocol $ Http11ConnectionHandler . process ( Http11Protocol . java : 588 )
at org . apache . tomcat . util . net . JIoEndpoint $ Worker . run ( JIoEndpoint . java : 489 )
at java . lang . Thread . run ( Unknown Source )
03 / 10 / 2010 11 : 18 : 59 org . apache . struts . chain . commands . ExceptionCatcher postprocess
AVISO : Exception from exceptionCommand 'servlet-exception'
java . lang . ClassNotFoundException : java . teste . TesteSimplesAction
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1516 )
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1361 )
at org . apache . struts . chain . commands . util . ClassUtils . getApplicationClass ( ClassUtils . java : 54 )
at org . apache . struts . chain . commands . util . ClassUtils . getApplicationInstance ( ClassUtils . java : 71 )
at org . apache . struts . chain . commands . servlet . CreateAction . createAction ( CreateAction . java : 98 )
at org . apache . struts . chain . commands . servlet . CreateAction . getAction ( CreateAction . java : 68 )
at org . apache . struts . chain . commands . AbstractCreateAction . execute ( AbstractCreateAction . java : 91 )
at org . apache . struts . chain . commands . ActionCommandBase . execute ( ActionCommandBase . java : 51 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
at org . apache . commons . chain . generic . LookupCommand . execute ( LookupCommand . java : 305 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
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 : 617 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 290 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 233 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 191 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 127 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 102 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 109 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 298 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 852 )
at org . apache . coyote . http11 . Http11Protocol $ Http11ConnectionHandler . process ( Http11Protocol . java : 588 )
at org . apache . tomcat . util . net . JIoEndpoint $ Worker . run ( JIoEndpoint . java : 489 )
at java . lang . Thread . run ( Unknown Source )
03 / 10 / 2010 11 : 18 : 59 org . apache . catalina . core . StandardWrapperValve invoke
GRAVE : Servlet . service () for servlet testeDeStruts threw exception
java . lang . ClassNotFoundException : java . teste . TesteSimplesAction
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1516 )
at org . apache . catalina . loader . WebappClassLoader . loadClass ( WebappClassLoader . java : 1361 )
at org . apache . struts . chain . commands . util . ClassUtils . getApplicationClass ( ClassUtils . java : 54 )
at org . apache . struts . chain . commands . util . ClassUtils . getApplicationInstance ( ClassUtils . java : 71 )
at org . apache . struts . chain . commands . servlet . CreateAction . createAction ( CreateAction . java : 98 )
at org . apache . struts . chain . commands . servlet . CreateAction . getAction ( CreateAction . java : 68 )
at org . apache . struts . chain . commands . AbstractCreateAction . execute ( AbstractCreateAction . java : 91 )
at org . apache . struts . chain . commands . ActionCommandBase . execute ( ActionCommandBase . java : 51 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
at org . apache . commons . chain . generic . LookupCommand . execute ( LookupCommand . java : 305 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
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 : 617 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 290 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 233 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 191 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 127 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 102 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 109 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 298 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 852 )
at org . apache . coyote . http11 . Http11Protocol $ Http11ConnectionHandler . process ( Http11Protocol . java : 588 )
at org . apache . tomcat . util . net . JIoEndpoint $ Worker . run ( JIoEndpoint . java : 489 )
at java . lang . Thread . run ( Unknown Source )
jbmsegundo 3 de out. de 2010
Não encontrou sua classe . Isso pode ser por vários motivos : Servlet não configurada no arquivo de configuração ; Erro de digitação no arquivo de configuração e por ultimo visibilidade da classe .
[] s
Não encontrou sua classe. Isso pode ser por vários motivos: Servlet não configurada no arquivo de configuração; Erro de digitação no arquivo de configuração e por ultimo visibilidade da classe.
[]s
lucas.campos 3 de out. de 2010
A classe salva por default no build/classes, eu acho, pq nessa pasta tem as classes minhas, não era pra ser lá o lugar???
jbmsegundo 4 de out. de 2010
Você não me entendeu. Olhe se sua servlet tá corretamente configurada e se sua respectiva classe tem visibilidade pública por exemplo. Não to falando depois de compilada.
lucas.campos 4 de out. de 2010
Eu tentei fazer o mesmo programa no pc da minha empresa, deu certo!!
Vlw cara!
jamesfrj 8 de jun. de 2012
Estava estudando a parte do Struts 1.0 na apostila da Caelum versão Versão: 14.5.2. e reparei que nos exercícios de inserção de novo contato, no formulário não consta as informações do campo de Data de Nascimento da tabela / classe Contato, mencionada no início da apostila e nos capítulos anteriores.
Tive problemas ao tentar inserir novos contatos por usar o mesmo Dao dos capítulos anteriores, pois o campo Data de Nascimento estava com valor nulo (não estava recebendo valores do formulário)
Quem tiver o mesmo problema tem duas opções:
Altera o DAO comentando a parte da Data de Nascimento
ou
Cria o campo Data de Nascimento no formulário.
Abraços
jamesfrj 9 de jun. de 2012
Pessoal, agora sou eu que estou com uma dúvida. Quando testo a Action MostraContatoAction aparece aquele erro de NullPointerException. Seguem os arquivos abaixo:
MostraContatoAction
public class MostraContatoAction extends Action {
@Override
public ActionForward execute ( ActionMapping mapping , ActionForm form ,
HttpServletRequest request , HttpServletResponse response )
throws Exception {
MostraContatoForm formulario = ( MostraContatoForm ) form ;
Contato contato = formulario . getContato ();
Contato encontrado = new ContatoDAO (). procura ( contato . getId ());
request . setAttribute ( "contato" , encontrado );
return mapping . findForward ( "ok" );
}
}
MostraContatoForm
public class MostraContatoForm extends ActionForm {
private Contato contato = new Contato ();
public Contato getContato () {
return contato ;
}
}
struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
<struts-config>
<form-beans>
<form-bean name= "ContatoForm" type= "br.com.caelum.struts.form.ContatoForm" ></form-bean>
<form-bean name= "RemoveContatoForm" type= "br.com.caelum.struts.form.RemoveContatoForm" ></form-bean>
</form-beans>
<action-mappings>
<action path= "/alteraContato" type= "br.com.caelum.struts.action.AlteraContatoAction" >
<forward name= "ok" path= "/listaContatos.do" />
</action>
<action path= "/mostraContato" type= "br.com.caelum.struts.action.MostraContatoAction" >
<forward name= "ok" path= "/mostraContato.jsp" />
</action>
<action path= "/mudaIdioma" type= "br.com.caelum.struts.action.MudaIdiomaAction" >
<forward name= "ok" path= "/testa-mensagens.jsp" />
</action>
<action path= "/removeContato" name= "RemoveContatoForm"
type= "br.com.caelum.struts.action.RemoveContatoAction" >
<forward name= "ok" path= "/listaContatos.do" ></forward>
</action>
<action path= "/novoContato" name= "ContatoForm" input= "/novo.jsp"
type= "br.com.caelum.struts.action.AdicionaContatoAction" scope= "request" >
<forward name= "ok" path= "/listaContatos.do" ></forward>
</action>
<action path= "/teste" type= "br.com.caelum.struts.action.TesteSimplesAction" >
<forward name= "ok" path= "/exemplo.jsp" ></forward>
</action>
<action path= "/listaContatos" type= "br.com.caelum.struts.action.ListaContatosAction" >
<forward name= "lista" path= "/lista.jsp" />
<forward name= "vazia" path= "/lista-vazia.jsp" ></forward>
</action>
</action-mappings>
<message-resources parameter= "MessageResources" />
</struts-config>
Erro
09 / 06 / 2012 22 : 35 : 34 org . apache . struts . chain . commands . servlet . CreateAction createAction
INFO : Initialize action of type : br . com . caelum . struts . action . MostraContatoAction
09 / 06 / 2012 22 : 35 : 34 org . apache . struts . chain . commands . AbstractExceptionHandler execute
WARNING : Unhandled exception
java . lang . NullPointerException
at br . com . caelum . struts . action . MostraContatoAction . execute ( MostraContatoAction . java : 23 )
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 : 191 )
at org . apache . commons . chain . generic . LookupCommand . execute ( LookupCommand . java : 305 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
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 : 617 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 290 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 233 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 191 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 127 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 102 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 109 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 293 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 859 )
at org . apache . coyote . http11 . Http11Protocol $ Http11ConnectionHandler . process ( Http11Protocol . java : 602 )
at org . apache . tomcat . util . net . JIoEndpoint $ Worker . run ( JIoEndpoint . java : 489 )
at java . lang . Thread . run ( Thread . java : 619 )
09 / 06 / 2012 22 : 35 : 34 org . apache . struts . chain . commands . ExceptionCatcher postprocess
WARNING : Exception from exceptionCommand ' servlet - exception '
java . lang . NullPointerException
at br . com . caelum . struts . action . MostraContatoAction . execute ( MostraContatoAction . java : 23 )
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 : 191 )
at org . apache . commons . chain . generic . LookupCommand . execute ( LookupCommand . java : 305 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
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 : 617 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 290 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 233 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 191 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 127 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 102 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 109 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 293 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 859 )
at org . apache . coyote . http11 . Http11Protocol $ Http11ConnectionHandler . process ( Http11Protocol . java : 602 )
at org . apache . tomcat . util . net . JIoEndpoint $ Worker . run ( JIoEndpoint . java : 489 )
at java . lang . Thread . run ( Thread . java : 619 )
09 / 06 / 2012 22 : 35 : 34 org . apache . catalina . core . StandardWrapperValve invoke
SEVERE : Servlet . service () for servlet testeDeStruts threw exception
java . lang . NullPointerException
at br . com . caelum . struts . action . MostraContatoAction . execute ( MostraContatoAction . java : 23 )
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 : 191 )
at org . apache . commons . chain . generic . LookupCommand . execute ( LookupCommand . java : 305 )
at org . apache . commons . chain . impl . ChainBase . execute ( ChainBase . java : 191 )
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 : 617 )
at javax . servlet . http . HttpServlet . service ( HttpServlet . java : 717 )
at org . apache . catalina . core . ApplicationFilterChain . internalDoFilter ( ApplicationFilterChain . java : 290 )
at org . apache . catalina . core . ApplicationFilterChain . doFilter ( ApplicationFilterChain . java : 206 )
at org . apache . catalina . core . StandardWrapperValve . invoke ( StandardWrapperValve . java : 233 )
at org . apache . catalina . core . StandardContextValve . invoke ( StandardContextValve . java : 191 )
at org . apache . catalina . core . StandardHostValve . invoke ( StandardHostValve . java : 127 )
at org . apache . catalina . valves . ErrorReportValve . invoke ( ErrorReportValve . java : 102 )
at org . apache . catalina . core . StandardEngineValve . invoke ( StandardEngineValve . java : 109 )
at org . apache . catalina . connector . CoyoteAdapter . service ( CoyoteAdapter . java : 293 )
at org . apache . coyote . http11 . Http11Processor . process ( Http11Processor . java : 859 )
at org . apache . coyote . http11 . Http11Protocol $ Http11ConnectionHandler . process ( Http11Protocol . java : 602 )
at org . apache . tomcat . util . net . JIoEndpoint $ Worker . run ( JIoEndpoint . java : 489 )
at java . lang . Thread . run ( Thread . java : 619 )
Alguma idéia?
jamesfrj 11 de jun. de 2012
Sei que o erro ocorre aqui
java.lang.NullPointerException
br.com.caelum.struts.action.MostraContatoAction.execute(MostraContatoAction.java:23)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
mas não entendo o que deixei de fazer neste método
public class MostraContatoAction extends Action {
@Override
public ActionForward execute ( ActionMapping mapping , ActionForm form ,
HttpServletRequest request , HttpServletResponse response )
throws Exception {
MostraContatoForm formulario = ( MostraContatoForm ) form ;
Contato contato = formulario . getContato ();
Contato encontrado = new ContatoDAO (). procura ( contato . getId ());
request . setAttribute ( "contato" , encontrado );
return mapping . findForward ( "ok" );
}
}
Alguma sugestão?