servlet exception

i m just getting 1 error here regarding the connection to oracle database from my servlet.javax.servlet.ServletException: Servlet execution threw an exceptionmy classpath is set,the ojdbc.jar file is set.what is else is needed?the servlet compiles properly.
[292 byte] By [anya_aaa] at [2007-11-27 3:44:57]
# 1
Is there a stack trace?
xiarcela at 2007-7-12 8:48:38 > top of Java-index,Java Essentials,Java Programming...
# 2
yes there is a stack trace
anya_aaa at 2007-7-12 8:48:38 > top of Java-index,Java Essentials,Java Programming...
# 3
Did you read it?
xiarcela at 2007-7-12 8:48:38 > top of Java-index,Java Essentials,Java Programming...
# 4
how do i read it?and there r so many.which one?it is a .log file so what program should i use to open it?
anya_aaa at 2007-7-12 8:48:38 > top of Java-index,Java Essentials,Java Programming...
# 5

"What should I use to open it"?

windows:wordpad or notepad

linux: kedit, gedit, openoffice, ..

"Which one?"

Is there a specific log file for your webapp? If not, probably the catalina-***.out or stdout***.log file, or else the stderr***.log file..

Usually, there is a date associated to the file as well, pick the most recent.

The java stack trace shows you the origination of the error...and sometimes even more useful information (SQL exception indicating bad user/password... or the like)

xiarcela at 2007-7-12 8:48:38 > top of Java-index,Java Essentials,Java Programming...
# 6

> "What should I use to open it"?

> windows:wordpad or notepad

> linux: kedit, gedit, openoffice, ..

>

>

> "Which one?"

> Is there a specific log file for your webapp? If

> not, probably the catalina-***.out or stdout***.log

> file, or else the stderr***.log file..

>

> Usually, there is a date associated to the file as

> well, pick the most recent.

>

> The java stack trace shows you the origination of the

> error...and sometimes even more useful information

> (SQL exception indicating bad user/password... or the

> like)

Also, PS:

It's likely to be toward the bottom of the file.

xiarcela at 2007-7-12 8:48:38 > top of Java-index,Java Essentials,Java Programming...
# 7
Also, I was assuming Tomcat... which is the limit of my servlet experience.
xiarcela at 2007-7-12 8:48:38 > top of Java-index,Java Essentials,Java Programming...
# 8
ok i have read the recent one it is BIGand it is alien for mewhat should i do?SessionListener: contextDestroyed()ContextListener: contextDestroyed()........java.lang.IllegalStateException: Cannot forward after response has been committed
anya_aaa at 2007-7-12 8:48:38 > top of Java-index,Java Essentials,Java Programming...
# 9

Maybe start by searching the file for text matching the method that tries to contact Oracle?

for example..

public void performMyOracleQueryThingamagigger(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException

{

//....

}

search for "performMyOracleQueryThingamagigger"

xiarcela at 2007-7-12 8:48:38 > top of Java-index,Java Essentials,Java Programming...
# 10

> ok i have read the recent one

> it is BIG

I assume your tomcat is non-production.

1. stop tomcat

2. move the logs directory to logs.old

3. make a new logs directory.

4. restart tomcat.

5. take the LEAST number of steps to duplicate the error

6. Open the log file now (should be shorter)

xiarcela at 2007-7-12 8:48:39 > top of Java-index,Java Essentials,Java Programming...
# 11
is it something to do with this?at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
anya_aaa at 2007-7-12 8:48:39 > top of Java-index,Java Essentials,Java Programming...
# 12
Is there anything beneath that? (or before it?)How many lines is the file now?
xiarcela at 2007-7-12 8:48:39 > top of Java-index,Java Essentials,Java Programming...
# 13

ok this is the whole thing

May 8, 2007 11:03:51 PM org.apache.catalina.core.ApplicationContext log

INFO: ContextListener: contextInitialized()

May 8, 2007 11:03:51 PM org.apache.catalina.core.ApplicationContext log

INFO: SessionListener: contextInitialized()

May 8, 2007 11:04:21 PM org.apache.catalina.core.StandardWrapperValve invoke

SEVERE: Servlet.service() for servlet dress threw exception

javax.servlet.ServletException: Servlet execution threw an exception

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:313)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)

at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)

at java.lang.Thread.run(Unknown Source)

anya_aaa at 2007-7-12 8:48:39 > top of Java-index,Java Essentials,Java Programming...
# 14

When does the exception occur?

Are you doing something on the web page and it going to the database? Does the exception occur when you first start tomcat?

Also, if you are using Oracle, you surely know the name of the method you are calling that is going to need to connect to Oracle. Also--you could search for the word "Oracle" -- I imagine it appears somewhere in the stack trace?

If I may ask, how long have you been writing java code?

xiarcela at 2007-7-12 8:48:39 > top of Java-index,Java Essentials,Java Programming...
# 15

My guess is:

javax.servlet.ServletException: Servlet execution threw an exception

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:313)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

One of your filters isn't configured correctly, or requires an entry in your web.xml or server.xml file that isn't there.

Perhaps you could distill into as short a post as possible.

1. What are you doing, basically.

2. Has tomcat worked prior to this, or are you just setting THAT up?

3. Are you applying some sort of a filter knowingly? If so, which one is that?

xiarcela at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 16

ok from the beginning what i m doing.

i m building an ecommerce site ,it is a 3 tier architecture ,i have passed 2 satges.my shopping cart is working fine. now i m in the last phase of having the oracle as the backend.

i want to display the customer's information on the confirm page.

i added the connectivity code and the sql staments blablah in the servlet which i have created.

i m just having 1 servlet.

now after doing all this.i open my webpage.i add an item(through checbox),enter quantity and click the submit button.

this error comes

javax.servlet.ServletException: Servlet execution threw an exception

now u c nothing is working now.

i know it is with the code of oracle coneectivity and the rest that is making this problem,i have commented that part and then my shopping cart works.

so what should i do?something is wrong with the connection part.....or what?

anya_aaa at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 17
i don't know what filters are.as of webxml i have done the mapping of my servletshould i mention something of oracle, i don't think so coz there is only 1 servlet which holds all the code.
anya_aaa at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 18
If you could post the block of code that is calling the database.ALSO:When you call that method, wrap it in a try:try { myOracleMethod();}catch (Exception e) {e.printStackTrace();}Then you should see something useful.
xiarcela at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 19

i have it in try and catch

it is big code

public class DressServlet extends HttpServlet

{

private String[][] data = new String[100][4];

public void init(ServletConfig fig) throws ServletException

{

super.init(fig);

}

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

{.........................

}

ServletContext context = getServletContext();

RequestDispatcher dispatcher = context.getRequestDispatcher("/empty.htm");

dispatcher.forward(request, response);

try

{

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

Connection conn=DriverManager.getConnection ("jdbc:oracle:thin:@127.0.0.1:1522:XE","system","786313");

String first_name = request.getParameter("firstName");

String last_name = request.getParameter("lasttName");

String address = request.getParameter("address");

String country = request.getParameter("country");

String email = request.getParameter("email");

Statement stmt=conn.createStatement();

if(action.equals("insert"))

{

String queryinsert = "INSERT INTO" + "customer"+ ("cust_id" + "," +"cust_first_name" + "," + "cust_last_name" + "," + "cust_address" + ", " + "cust_country" + "," + "cust_email") +" VALUES"+"('" + "custId"+ "',"

+ "firstname" + "',"

+" lasttname "+ "',"

+ "address "+ "',"

+ "country "+ "',"

+ "email" + "')";

}

else if (action.equals("display"))

{

ResultSet result = stmt.executeQuery("SELECT (cust_first_name,cust_last_name,cust_address,cust_country,cust_email) FROMcustomer WHERE (cust_first_name = first_name AND cust_last_name = last_name)");

result.close();

}

stmt.close();

conn.close();

}

catch(Exception e)

{

System.out.println("error"+e);

e.printStackTrace(System.out);

}

String temp="";

Cookie cookie2= new Cookie("address", temp);

cookie2.setMaxAge(24*60*60);

response.addCookie(cookie2);

ServletContext context2 = getServletContext();

RequestDispatcher dispatcher2 = context2.getRequestDispatcher("/confirmpage.jsp");

dispatcher2.forward(request, response);

}

public void chip(String cookieValue)

{.............................

}}

this is practically my whole servlet

anya_aaa at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 20
And when you stop tomcat, remove the logs directory, recreate it, and restart it..Do you get anything?Or on restart is it blowing up?
xiarcela at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 21
Can I at this point ask why you register the JDBC driver by hand, and why you do it every time there's a request? You know that merely loading the class once will have exactly the same effect.....
georgemca at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 22
Good catch. I am fried just getting her (?) to the posting of code stage.
xiarcela at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 23

> Good catch. I am fried just getting her (?) to the

> posting of code stage.

And then there's the usual suspects:

"Don't use instance variables in a servlet."

"Use PreparedStatement instead of that mess of quotes and commas."

"Close your connection in a finally block."

DrClapa at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 24
well i m not using java netBeans.we just have to use html/Xml ,, servlets and oracle.and in our books the code for the oracle part is given that way.
anya_aaa at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 25
i don't mind posting my code i need my site to get running
anya_aaa at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 26
ahhh that is fine,it is just 2 sql statements.i have closed all my brackets properly, otherwise it would have given me error while compiling.
anya_aaa at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 27
ok i m tired,i have been working on this project whole day.i ll be back tomorrow.meantime plz somebody find the error in the program.tell me WHAT to do
anya_aaa at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 28

> ok i m tired,i have been working on this project

> whole day.i ll be back tomorrow.meantime plz somebody

> find the error in the program.

> tell me WHAT to do

You seem to be under the mistaken impression that people here are your personal servants who are here to fix your code for you.

It doesn't work that way. People are here to help you find and fix your problem, and to help you understand what you did wrong so you can leran from your mistake, not to do your work for you.

jverda at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 29

of course i know that

i wrote my last msg coz yesterday i have been working on my project from 11:00 am till midnight ,and i was dead tired.i started getting problems in the evening and then only i came online.

plz don't write such things when u don't know exactly what the other person is doing.

when did i act like every1 are servants of mine?

i m just trying to get my errors cleared up

anya_aaa at 2007-7-21 20:55:03 > top of Java-index,Java Essentials,Java Programming...
# 30
> when did i act like every1 are servants of> mine?When you said you were going away and asked--practically demanded--that others fix your problem.
jverda at 2007-7-21 20:55:08 > top of Java-index,Java Essentials,Java Programming...
# 31
> tell me WHAT to doToday..Have you tried the suggestions made in previous posts (not initializing the driver multiple times, the finally {} block, etc?Dave
xiarcela at 2007-7-21 20:55:08 > top of Java-index,Java Essentials,Java Programming...
# 32
This thread makes me weep.[url #" style="display: block; background-image: url(' http://vcard.homer-simpson.de/images/homer/pic18.jpg'); width: 343px; height: 398px] [/url]
DrLaszloJamfa at 2007-7-21 20:55:08 > top of Java-index,Java Essentials,Java Programming...
# 33
I feel as though I tried...
xiarcela at 2007-7-21 20:55:08 > top of Java-index,Java Essentials,Java Programming...
# 34
well this thread is dead for now,i havn't even resumed my work yet.
anya_aaa at 2007-7-21 20:55:08 > top of Java-index,Java Essentials,Java Programming...
# 35
well i m sorry if i sounded demanding,some ppl were spending hrs with me,so i thought that if i vanish suddenly they ll think maybe my problem is solved.
anya_aaa at 2007-7-21 20:55:08 > top of Java-index,Java Essentials,Java Programming...
# 36
of course whatever i get the suggestions here i try them .
anya_aaa at 2007-7-21 20:55:08 > top of Java-index,Java Essentials,Java Programming...
# 37
hey u were a gr8 help...thxi learnt abt log files
anya_aaa at 2007-7-21 20:55:08 > top of Java-index,Java Essentials,Java Programming...
# 38
> hey u were a gr8 help...thx> i learnt abt log filesyou're welcome.At least we learned log files :-)
xiarcela at 2007-7-21 20:55:08 > top of Java-index,Java Essentials,Java Programming...