• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I fix this REALLY URGENT

 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im attempting my first servlet, and Im using the combination Applet --> Servlet --> JDBC --> SQL.
Im using Tomcat 4.0.1 as my server and I have placed all files in the ROOT directory. Im getting the following error in my servlet class
java.lang.NoSuchMethodError
at t.Serve.performTask(Serve.java:75)
at t.Serve.doPost(Serve.java:31)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
I have traced the error to the code in bold i.e when Im attempting to connect to SQL
public void performTask(javax.servlet.http
{
try
{
ObjectInputStream in = newObjectInputStream (request.getInputStream());
String s = (String)in.readObject();
info.addPerInfo(s);
}
public void init()
{
info = new InfoGetter();
}
public InfoGetter()
{
String dsn = "jdbc:twtds:sqlserver://CAT/DOG";
try
{
Class.forName("com.thinweb.tds.Driver");
myCon = DriverManager.getConnection(dsn, ..
}
public void addPersInfo(String first)
{
try
{
PreparedStatement statement = myCon.prepareStatement(....
statement.setString(1,first);
statement.executeUpdate();

}
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thought maybe i should include the entire error
thank u all for your time
java.lang.NoSuchMethodError
at t.Serve.performTask(Serve.java:75)
at t.Serve.doPost(Serve.java:31)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:446)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
at java.lang.Thread.run(Thread.java:484)
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18281
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You boldfaced the line referring to the object "info", so I assume that's the offending line.
But you didn't show either the definition of "info" or the definition of the class that "info" belongs to.
Normally I'd expect that "info"s class didn't implement a "void addPerInfo( String s )" method OR that you had initialized "info" with some class other than the one that actual did implement that method.
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created an instance of InfoGetter in my init()
method of my servlet. and in the performTask() method i use info which is an instance of InfoGetter and i then call addPerInfo. I did include a decription of InfoGetter at the bottom of my first post. And within post i have the method addPerInfo. And can u elaborate on "Normally I'd expect that "info"s class didn't implement a "void addPerInfo( String s )" method OR that you had initialized "info" with some class other than the one that actual did implement that method" If u have any further questions please ask I really need to solve this
Thank u all
 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved my problem. I was making my sql connection in a class other than my servlet class
i.e. class InfoGetter. I got rid of that class and
placed my connection in my init() method of my Servlet class. And everything works fine now. For the life of me i cant figure out why
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic