HTTP Status 500 - Servlet execution threw an exception

4 respostas
P

Quando tento alterar um contato através do id, acontece o seguinte erro:

HTTP Status 500 - Servlet execution threw an exception


type Exception report

message Servlet execution threw an exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception

root cause

java.lang.Error: Unresolved compilation problem:
The method setId(int) in the type Contato is not applicable for the arguments ()

br.com.cefet.projeto.servlet.AlteraContatoServlet.doPost(AlteraContatoServlet.java:38)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.42 logs.


O id na classe Contato é int, e estou passando como argumento um int. Não consegui achar uma solução. Se alguém puder me dar uma ajuda, agradeço.

4 Respostas

romarcio

Você gerou o método setId() na classe Contato?

S

Brother,você tá usando o setId,logo você tem que setar um id ai dentro né!? pelo visto você tá madando executar com ele vazio…

P

@romarcio
Sim, eu gerei.

@Slow17
Isso que é estranho, eu estou setando um int, (id da classe Contato é int). Mas fica com esse erro.

Segue a respectiva parte do código com problema:

Classe Contatos:
private int id;

public void setId(int id) {
	this.id = id;
}
Classe Servlet Alterar Contatos:
int id = Integer.parseInt(req.getParameter("id"));
c.setId(id);
dao.altera(c);

Já tentei passar o id pelo construtor e o erro persiste.

romarcio

Posta sua pagina JSP.

Criado 18 de outubro de 2013
Ultima resposta 21 de out. de 2013
Respostas 4
Participantes 3