You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Claudio Veas <cm...@yahoo.com.ar> on 2005/12/14 05:23:47 UTC

inserting data (A weird problem)

Hello, Im trying to insert data in my mysql server with a JSP and a Bean
with an example I found in the internet, Im very new to all this but this
error I get its really strange. 
I created a table contacto (contact) in the mysql server, 
create table contacto (numero int,
                                       nombre varchar (20),
                                       apellido varchar(20),
                                       Telefono int,
                                        Email varchar(50)
)
I made the bean acording to the example and I made a form so I can Input the
data and the job of the bean would be to save this info in the database. But
the problem is that I got an Error 
 
 
javax.servlet.ServletException: DB.contacto.setapellido(Ljava/lang/String;)V
	org.apache.jasper.runtime.PageContextImpl
doHandlePageException(PageContextImpl.java:848)
	org.apache.jasper.runtime.PageContextImpl
handlePageException(PageContextImpl.java:781)
	org.apache.jsp.colors.insertar_jsp._jspService(org.apache.jsp.colors
insertar_jsp:85)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
java:322)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

causa raíz 
java.lang.NoSuchMethodError: DB.contacto.setapellido(Ljava/lang/String;)V
	org.apache.jsp.colors.insertar_jsp._jspService(org.apache.jsp.colors
insertar_jsp:59)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
java:322)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

so I decided to take out all the logic of the "apellido" field in the 
database and I took it out of the form and from the JSP file and guess what
it 
Worked so I put all the "apellido" stuffs back with extra care of no making
any mistakes 
this time, Idouble checked it with the other fields because hey they work
but guess what
the error showed up again and I dont really know what the problem is, all I
know its something related
to the get statement. 
Hope You can Help me
Thanks on Advance
Claudio Veas
Please Excuse my english 

RE: inserting data (A weird problem)

Posted by Richard Mixon <rn...@qwest.net>.
Claudio,

I'm sorry but I have a bit of trouble following your explanation (I just do
not know your object model/domain well enough to follow the explanation).

But I'm still wondering if this is not a problem of ill-formed JavaBeans.
Are you aware of the rules for naming JavaBeans classes and their
properties/mutators (getters and setters)? In summary:
 - your instance variables should all start with lowercase letters (e.g.
"apellido");
 - the getter and setter should be getApellido() and setApellido(String
apellido) respectively.
Look at Sun's Java site (or other good Java reference) for the JavaBean
naming standards.

The rule on instance variables starting with lower case letters is more of a
convention. What really matters is that if you have methods getApellido and
setApellido then in your JSP code you can simply refer to "apellido" most
frameworks will translate this into a call to getApellido.

If this does not provide some insight into the problem, you need to provide
a bit more detail of a simplified version of your object model - something
like a simple character/line drawing or indented class outline with instance
variables. Then your description of what is happening might make a bit more
sense to some of us and you might get a better answer.

Hope this helps - Richard

-----Original Message-----
From: Claudio Martn Veas [mailto:cmveas@yahoo.com.ar] 
Sent: Wednesday, December 14, 2005 5:50 AM
To: Tomcat Users List
Subject: Re: inserting data (A weird problem)


 Hello all, and thanks for writing about my problem, I found the solution
but Im note very confortable because I dont understand the reason why it
fails. 
When this error started to show several times even if I tried the same thing
a lot of times I started to think about the reason of all this erros so Í
thought that maybe (since Im very new to all this) beans had a limit in the
porperties or set methods so that was the reason that when ever I delete all
the "apellido"
logic all worked fine but I decided to try another example so I took out
another of the properties I believe it was mail and I let the "apellido"
logic stay, but the error didnt leave. After hours of thinking a (lets say
stupid idea) came into my mind (oh I forgot to tell you that Itried to
replace "apellido" with "algo" but the logic was the same and I did this to
see if the naming of the propertie/method had anything to d with this) I
thought, hey maybe beans arent supposed to have properties / methods
starting with an "a" so I tried without the "apellido" logic to make work
the example but I replace "Numero" with "aNumero" in all the places just
like with the other example, and the error showed up so I decided to put
"Numero" back and I put all the "apellido" logic again but in english this
time "Lastname" AND IT WORKED so Im parcially happyu about the fact that I
made it work but I dont like not knowing what is the problem, i dont like
the idea of taking something for granted as if it were some kind of magic
"Tomcat and beans with properties starting with 'a' dont match" "why not?"
"because they dont"
jaja so if you find out why this is a problem just let me know Thanks for
all you attention Thanks on Advance Claudio Veas


	


	
		
___________________________________________________________
1GB gratis, Antivirus y Antispam
Correo Yahoo!, el mejor correo web del mundo http://correo.yahoo.com.ar 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: inserting data (A weird problem)

Posted by Claudio Martn Veas <cm...@yahoo.com.ar>.
 Hello all, and thanks for writing about my problem, I
found the solution but Im note very confortable
because I dont understand the reason why it fails. 
When this error started to show several times even if
I tried the same thing a lot of times I started to
think about the reason of all this erros so Í thought
that maybe (since Im very new to all this) beans had a
limit in the porperties or set methods so that was the
reason that when ever I delete all the "apellido"
logic all worked fine but I decided to try another
example so I took out another of the properties I
believe it was mail and I let the "apellido" logic
stay, but the error didnt leave. After hours of
thinking a (lets say stupid idea) came into my mind
(oh I forgot to tell you that Itried to replace
"apellido" with "algo" but the logic was the same and
I did this to see if the naming of the
propertie/method had anything to d with this) I
thought, hey maybe beans arent supposed to have
properties / methods starting with an "a" so I tried
without the "apellido" logic to make work the example
but I replace "Numero" with "aNumero" in all the
places just like with the other example, and the error
showed up so I decided to put "Numero" back and I put
all the "apellido" logic again but in english this
time "Lastname" AND IT WORKED so Im parcially happyu
about the fact that I made it work but I dont like not
knowing what is the problem, i dont like the idea of
taking something for granted as if it were some kind
of magic "Tomcat and beans with properties starting
with 'a' dont match" "why not?" "because they dont"
jaja so if you find out why this is a problem just let
me know 
Thanks for all you attention 
Thanks on Advance 
Claudio Veas


	


	
		
___________________________________________________________ 
1GB gratis, Antivirus y Antispam 
Correo Yahoo!, el mejor correo web del mundo 
http://correo.yahoo.com.ar 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: inserting data (A weird problem)

Posted by Jon Wingfield <jo...@mkodo.com>.
Looking at the attached jsp I can see it does
cto.setapellido(request.getParameter("apellido"));
which is correct for the supplied bean code.

As the NoSuchMethodError is occuring at runtime rather than at jsp 
compile time I would say you have probably changed the bean code since 
the jsp was last compiled.
Have a look in the tomcat logs for jsp compilation errors.
Make sure the compiled class of the bean is correct version of the code.
And, if worst comes to worst, try deleting tomcat's work directory to 
clear out any stale jsp class files.

Jon Wingfield wrote:
> This is how I read the error: There is no method with the signature
> 
> void setapellido(String[] values)
> 
> which (given your code sample) there isn't.
> 
> Is the insertar.jsp doing something like
> contacto.setapellido(request.getParameterValues("name"));
> 
> instead of
> 
> contacto.setapellido(request.getParameter("name"));
> 
> HTH,
> 
> Jon
> 
> Claudio Veas wrote:
> 
>>
>> Hello, Im trying to insert data in my mysql server with a JSP and a 
>> Bean with an example I found in the internet, Im very new to all this 
>> but this error I get its really strange.
>> I created a table contacto (contact) in the mysql server,
>> create table contacto (numero int,
>>                                        nombre varchar (20),
>>                                        apellido varchar(20),
>>                                        Telefono int,
>>                                         Email varchar(50)
>> )
>> I made the bean acording to the example and I made a form so I can 
>> Input the data and the job of the bean would be to save this info in 
>> the database. But the problem is that I got an Error
>>  
>>  
>>
>> javax.servlet.ServletException: 
>> DB.contacto.setapellido(Ljava/lang/String;)V
>>     org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848) 
>>
>>     org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781) 
>>
>>     org.apache.jsp.colors.insertar_jsp._jspService(org.apache.jsp.colors.insertar_jsp:85) 
>>
>>     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) 
>>
>>     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) 
>>
>>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>
>> *causa raíz*
>>
>> java.lang.NoSuchMethodError: DB.contacto.setapellido(Ljava/lang/String;)V
>>     org.apache.jsp.colors.insertar_jsp._jspService(org.apache.jsp.colors.insertar_jsp:59) 
>>
>>     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) 
>>
>>     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) 
>>
>>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>
>> so I decided to take out all the logic of the "apellido" field in the
>> database and I took it out of the form and from the JSP file and guess 
>> what it
>> Worked so I put all the "apellido" stuffs back with extra care of no 
>> making any mistakes
>> this time, Idouble checked it with the other fields because hey they 
>> work but guess what
>>
>> the error showed up again and I dont really know what the problem is, 
>> all I know its something related
>>
>> to the get statement.
>> Hope You can Help me
>>
>> Thanks on Advance
>>
>> Claudio Veas
>>
>> Please Excuse my english
>>        
>>
>> Add FUN to your email - CLICK HERE! 
>> <http://www.incredimail.com/index.asp?id=96769>
>>
>>
>> ------------------------------------------------------------------------
>>
>> package DB;
>>
>> import java.sql.*;
>> import java.io.*;
>>
>> public class contacto {
>>
>>    private String dbURL = 
>> "jdbc:mysql://localhost:3306/test?user=jonas&password=jonas";
>>    private String dbDriver = "com.mysql.jdbc.Driver";
>>    private Connection dbCon;
>>       String Numero =null;
>>    String Nombre = null;
>>     String apellido =null;
>>    String Telefono = null;
>>    String Email = null;
>>  
>>    public contacto() {
>>       super();
>>    }
>>
>>    public String getNumero() {
>>        return this.Numero;
>>    }
>>    public String getNombre() {
>>        return this.Nombre;
>>    }
>>    public String getapellido(){
>>        return this.apellido;
>>        }
>>    public String getTelefono() {
>>        return this.Telefono;
>>    }
>> public String getEmail() {
>>        return this.Email;
>>    }
>>             
>>    public void setNumero(String Numero) {
>>        this.Numero = Numero;
>>    }
>>
>>    public void setNombre(String Nombre) {
>>        this.Nombre = Nombre;
>>
>>    }
>>
>> public void setapellido(String apellido) {
>>        this.apellido = apellido;
>>
>>    }
>>
>>     public void setTelefono(String Telefono) {
>>        this.Telefono = Telefono;
>>    }
>>     public void setEmail(String Email) {
>>        this.Email = Email;
>>    }
>>
>>    public void doInsert() throws ClassNotFoundException, SQLException {
>>       Class.forName(dbDriver);
>>       dbCon = DriverManager.getConnection(dbURL);
>>       Statement s = dbCon.createStatement();
>>       String sql = "INSERT INTO contactos values (" + this.Numero;
>>       sql = sql + ", '" + this.Nombre;
>>       sql = sql + "', " + this.Telefono + ", '" + this.Email;
>>       sql = sql + "')";
>>       int insertResult = s.executeUpdate(sql);
>>       dbCon.close();
>>    }
>>     }
>>
>>
>> ------------------------------------------------------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: inserting data (A weird problem)

Posted by Jon Wingfield <jo...@mkodo.com>.
This is how I read the error: There is no method with the signature

void setapellido(String[] values)

which (given your code sample) there isn't.

Is the insertar.jsp doing something like
contacto.setapellido(request.getParameterValues("name"));

instead of

contacto.setapellido(request.getParameter("name"));

HTH,

Jon

Claudio Veas wrote:
> 
> Hello, Im trying to insert data in my mysql server with a JSP and a Bean 
> with an example I found in the internet, Im very new to all this but 
> this error I get its really strange.
> I created a table contacto (contact) in the mysql server,
> create table contacto (numero int,
>                                        nombre varchar (20),
>                                        apellido varchar(20),
>                                        Telefono int,
>                                         Email varchar(50)
> )
> I made the bean acording to the example and I made a form so I can Input 
> the data and the job of the bean would be to save this info in the 
> database. But the problem is that I got an Error
>  
>  
> 
> javax.servlet.ServletException: DB.contacto.setapellido(Ljava/lang/String;)V
> 	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
> 	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
> 	org.apache.jsp.colors.insertar_jsp._jspService(org.apache.jsp.colors.insertar_jsp:85)
> 	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> 	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
> 	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
> 	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> 
> *causa raíz*
> 
> java.lang.NoSuchMethodError: DB.contacto.setapellido(Ljava/lang/String;)V
> 	org.apache.jsp.colors.insertar_jsp._jspService(org.apache.jsp.colors.insertar_jsp:59)
> 	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> 	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
> 	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
> 	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> 
> so I decided to take out all the logic of the "apellido" field in the 
> 
> database and I took it out of the form and from the JSP file and guess what it 
> 
> Worked so I put all the "apellido" stuffs back with extra care of no making any mistakes 
> 
> this time, Idouble checked it with the other fields because hey they work but guess what
> 
> the error showed up again and I dont really know what the problem is, all I know its something related
> 
> to the get statement. 
> 
> Hope You can Help me
> 
> Thanks on Advance
> 
> Claudio Veas
> 
> Please Excuse my english 
> 
> 		
> 
> Add FUN to your email - CLICK HERE! 
> <http://www.incredimail.com/index.asp?id=96769>
> 
> 
> ------------------------------------------------------------------------
> 
> package DB;
> 
> import java.sql.*;
> import java.io.*;
> 
> public class contacto {
> 
>    private String dbURL = "jdbc:mysql://localhost:3306/test?user=jonas&password=jonas";
>    private String dbDriver = "com.mysql.jdbc.Driver";
>    private Connection dbCon;
>    
>    String Numero =null;
>    String Nombre = null;
>     String apellido =null;
>    String Telefono = null;
>    String Email = null;
>   
> 
>    public contacto() {
>       super();
>    }
> 
>    public String getNumero() {
>        return this.Numero;
>    }
>    public String getNombre() {
>        return this.Nombre;
>    }
>    public String getapellido(){
>    	return this.apellido;
>    	}
>    public String getTelefono() {
>        return this.Telefono;
>    }
> public String getEmail() {
>        return this.Email;
>    }
>    
>    
>    	
>    public void setNumero(String Numero) {
>        this.Numero = Numero;
>    }
> 
>    public void setNombre(String Nombre) {
>        this.Nombre = Nombre;
> 
>    }
> 
> public void setapellido(String apellido) {
>        this.apellido = apellido;
> 
>    }
> 
>     public void setTelefono(String Telefono) {
>        this.Telefono = Telefono;
>    }
> 	public void setEmail(String Email) {
>        this.Email = Email;
>    }
> 
>    public void doInsert() throws ClassNotFoundException, SQLException {
>       Class.forName(dbDriver);
>       dbCon = DriverManager.getConnection(dbURL);
>       Statement s = dbCon.createStatement();
>       String sql = "INSERT INTO contactos values (" + this.Numero;
>       sql = sql + ", '" + this.Nombre;
>       sql = sql + "', " + this.Telefono + ", '" + this.Email;
>       sql = sql + "')";
>       int insertResult = s.executeUpdate(sql);
>       dbCon.close();
>    }
>     
> }
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: inserting data (A weird problem)

Posted by Richard Mixon <rn...@qwest.net>.
If DB.contacto is a regular JavaBean, then maybe the method call should be
"setApellido(...)", instead of "setapellido(...)"?
 
 HTH - Richard

  _____  

From: Claudio Veas [mailto:cmveas@yahoo.com.ar] 
Sent: Tuesday, December 13, 2005 9:24 PM
To: Tomcat Users List
Subject: inserting data (A weird problem)



Hello, Im trying to insert data in my mysql server with a JSP and a Bean
with an example I found in the internet, Im very new to all this but this
error I get its really strange. 
I created a table contacto (contact) in the mysql server, 
create table contacto (numero int,
                                       nombre varchar (20),
                                       apellido varchar(20),
                                       Telefono int,
                                        Email varchar(50)
)
I made the bean acording to the example and I made a form so I can Input the
data and the job of the bean would be to save this info in the database. But
the problem is that I got an Error 
 
 
javax.servlet.ServletException: DB.contacto.setapellido(Ljava/lang/String;)V

	
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextI
mpl.java:848)

	
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:781)

	
org.apache.jsp.colors.insertar_jsp._jspService(org.apache.jsp.colors.inserta
r_jsp:85)

	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

	
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
22)

	
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)

	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

causa raíz 

java.lang.NoSuchMethodError: DB.contacto.setapellido(Ljava/lang/String;)V

	
org.apache.jsp.colors.insertar_jsp._jspService(org.apache.jsp.colors.inserta
r_jsp:59)

	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

	
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
22)

	
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)

	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)

	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
so I decided to take out all the logic of the "apellido" field in the 
database and I took it out of the form and from the JSP file and guess what
it 
Worked so I put all the "apellido" stuffs back with extra care of no making
any mistakes 
this time, Idouble checked it with the other fields because hey they work
but guess what
the error showed up again and I dont really know what the problem is, all I
know its something related
to the get statement. 
Hope You can Help me
Thanks on Advance
Claudio Veas
Please Excuse my english 

			
 <http://www.incredimail.com/index.asp?id=96769> Add FUN to your email -
CLICK HERE!