This week's book giveaway is in the Cloud forum.
We're giving away four copies of Terraform in Action and have Scott Winkler on-line!
See this thread for details.
Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

javax.servlet.ServletException: Servlet execution threw an exception

 
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am running Tomcat with mod_jk connector for apache - Centos 6x on dedicated server. I am facing the following problem. When I restart the server its working fine but after sometime its throwing again the following exception. Please advise.



Best regards
 
Saloon Keeper
Posts: 24581
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you are obtaining your database connection by brute force from within your web application. Recommended practice is to define a Connection Pool in Tomcat and have your webapp use that pool to get connections.

The fault that you are actually seeing is entirely within Oracle code. Either the driver you are trying to use is defective or you have a problem in your driver environment.

A very likely cause of such a problem would be if you had a copy of a Oracle JDBC driver in both your WAR (WEB-INF/lib) and TOMCAT_HOME/lib directories. Such a setup would be prone to classpath conflicts causing incompatible parts of both drivers to be used at the same time.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:It looks like you are obtaining your database connection by brute force from within your web application. Recommended practice is to define a Connection Pool in Tomcat and have your webapp use that pool to get connections.



Thanks Tim for your favorable reply. I set the classpath of Orai18n.jar and it seems fine now but waiting to check either its throwing this error again or not.

Can you please refer me to any doc as to how can configure connection pooling in Tomcat?

Best regards
 
Tim Holloway
Saloon Keeper
Posts: 24581
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks from the bottom of my heart
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This exception happened again. I checked catalina.out and it says:


Best regards
 
Tim Holloway
Saloon Keeper
Posts: 24581
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure if you mean that you are still getting the original servlet exception or you're just concerned about the warning on shutdown.

If you're running a timer service such as Quartz, it's a good idea to put a ServletContextListener in the webapp that will detect when the app is being terminated and shutdown the timer service explicitly. That should get rid of the leaking timer thread(s).
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your favorable replies

I am not running any timer services and this error appears on my dedicated server. I don't know which servlet is throwing this error. Catalina.out is showing only directory [/medical] but not pointing to the servlet.

Is there anyway to know which servlet class is involved?

Best regards
 
Tim Holloway
Saloon Keeper
Posts: 24581
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Farakh khan wrote:Thanks for your favorable replies

I am not running any timer services and this error appears on my dedicated server. I don't know which servlet is throwing this error. Catalina.out is showing only directory [/medical] but not pointing to the servlet.

Is there anyway to know which servlet class is involved?

Best regards




Not directly. Once spawned, a thread doesn't care what class contained the spawning code, only what class anchors the thread itself.

Your best bet is to locate that class and figure out how it was instantiated. What I normally do is run Tomcat under a debugger, pause the thread of interest, and look at its stacktrace in the debugger.

With a name like "Timer-9", it's possible that the thread itself might have been spawned by a timer sleep function, but use of timer sleep in a servlet is a violation of J2EE specs.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are some classes that are using Thread.sleep(1000); Thread.sleep(250); May I check these classes?

Thanks again
 
Tim Holloway
Saloon Keeper
Posts: 24581
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should. I was just looking at the servlet spec and I can't find the specific forbiddings against meddling with threads and thread resources. Although from a practical point of view, I can tell you that in Tomcat, any resources that a request doesn't let go of before exiting the servlet service() method are likely to wreak havoc with whatever process inherits the thread next.

Timer waits are not a good idea because the idea is that the request/response cycle should process as quickly as possible. Even discounting impatient users, the longer a thread is processing one request, the less time that thread has to process someone else's request, since there's a limit to the number of threads in the processing pool.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I did now is: added System.exit(0); in finally block and waiting to see if the problem occurs again or not?

Best regards
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should never use System.exit in code running in a servlet container. What are you trying to achieve by that?
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to exit after running the thread because if many threads ran then our server display the error in my first post and I have to restart the server manually as by restarting tomcat its not work
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to address the actual problem, which has something to do with the DB driver, as Tim said in his first post. Shutting down the server isn't a solution, and should be entirely unnecessary.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I copy pasted all drivers from $ORACLE_HOME/jdbc/lib to tomcat/lib as well as $ORACLE_HOME/jlib/i18n.jar to tomcat/lib but again faced the problem of my first post. When I seen catalina.out its displays following:


What else I can check to know more about it?

Thanks again
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Leaking a resource isn't great, but it may not even be related to the original problem, and should in any case not be a big issue in a production setting (where restarting web apps should be rare, and where I would advise never to do it, but instead to restart the server).

If this was my problem I would specifically search for that exception; you don't seem to be the first one to whom it happens.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My mind is not working to point out exact problem. The exception displayed in tomcat says i18n problem but catalina.out says thread problem. I tried to search both and nothing found that I not applied to the server. Please help me to point out exact problem that can explored and fixed.

Thanks again
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you could work out the exact problem you wouldn't need to post here I'm talking about the exception message in your first post; searching for that is a good start. You said you searched for that already - what did you find?

The catalina log doesn't mention anything useful - as I said, the message about a leaked resource may have different reasons, and is anyway not the cause of the problem.
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In first view this thread appealed me to the near root cause of my problem https://community.oracle.com/thread/886327?start=0&tstart=0

I applied whatever said in this thread. I mean I downloaded and copy pasted orai18n.jar to tomcat lib and set its classpath as well.

I am here to hear from you or waiting to have any useful link from your end please

Thanks again
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I doubt that a NoSuchMethodError would be caused by a missing jar file. Much more likely is a mismatch of jar files that go with different versions of the JDBC driver (along the lines of posts #10 and #11 in that discussion).
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I copy pasted from my Oracle 11g 2.0.2 directory /u01/app/oracle/product/11.2.0/xe/jdbc/lib/* to tomcat/lib that in my view the accurate versions.

Thanks again
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you made sure that there are no leftover jar files from other versions: not in WEB-INF/lib, not in any of the JRE directories, and not in any of the Tomcat directories?
 
Farakh khan
Ranch Hand
Posts: 851
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Sorry for late reply

=============================================================================================================
Please NOTE: The server is production server and working fine but sometime its throwing exception that I mentioned in my first post. Only solution is to restart the server
=============================================================================================================

Today I again faced this error. What I tried so far is:

1) Downloaded new jar files as per my Oracle version 11.2.0.2.0 from this link: http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html.
2) I downloaded: jdbc6.jar, jdbc6_g.jar, ojdbc6dms.jar, ojdbc6dms_g.jar, ori18n.jar
3) Set the classpath as /u01/app/oracle/product/11.2.0/xe/jlib/orai18n.jar.jar
4) Checked all folders and make sure there is no duplicate jar file
5) I am seeing description with orai18n.jar: NLS classes for use with JDK 1.5, and 1.6. It contains classes for NLS support in Oracle Object and Collection types. This jar file replaces the old nls_charset jar/zip files.

It means its suitable for jdk1.5 or 1.6 whereas I checked my jdk version and found:
# java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

Is that the problem?

Please advise

Thanks in anticipation.
 
reply
    Bookmark Topic Watch Topic
  • New Topic