Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Unable to run servlet program using Connection Pool in JBoss

 
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai..
I am facing the following error and could not see the output on my browser window the error am facing is:


and my code follows:

my web.xml file is:

my HTML file:

and the below is oracle-ds.xml


I prepared WAR file and deployed in <Jbozz_home>\..\deploy folder.. can anyone please tell me where i did mistake ,could not see the output though this is simple servlet program ...
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver



Where have you placed the Oracle JDBC driver jar? It should be in JBOSS_HOME/server/<servername>/lib folder
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using ojdbc6.jar(for oracle11g).. i have set it global path in CLASSPATH... won't it recognize?please tell me..
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have placed as you said in E:\jboss-5.1.0.GA-jdk6\jboss-5.1.0.GA\server\default\lib\ojdbc6.jar(in <jboss_hpme>\..\<server_name>\lib) even when i run i am facing the below error...

and my table content in oracle db s/w:



 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one.. please sort out where the problem in my code and why am I facing such error?

what should i put for
// in oracle-ds.xml


when i use oracle 11g.. is it Oracle9i or Oracle11g?

 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

18:59:11,859 ERROR [STDERR] java.lang.NullPointerException
18:59:11,870 ERROR [STDERR] at ConnPoolServlet.doGet(ConnPoolServlet.java:44)



The NullPointerException is coming from a class within your application. You'll have to check what object is null and why. As for the other stacktrace in that log, it's just a INFO level logging telling you that you haven't closed the connection that was opened and can lead to a leak.
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jaikiran Pai wrote:

18:59:11,859 ERROR [STDERR] java.lang.NullPointerException
18:59:11,870 ERROR [STDERR] at ConnPoolServlet.doGet(ConnPoolServlet.java:44)



The NullPointerException is coming from a class within your application. You'll have to check what object is null and why. As for the other stacktrace in that log, it's just a INFO level logging telling you that you haven't closed the connection that was opened and can lead to a leak.



Thanks Jaikiran for your reply.. if you please see the below code in my application,here I am returning the Connection object to the connection pool,is this not sufficient.. can you please correct me,,

 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could see the below error :

 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post that entire exception stacktrace. Also note that your code is just eating up the exception in the catch block and can possibly send back a null connection to whoever is calling that method. My guess is that's what is happening right now.
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am thankful to you Jaikiran and sorry for posting this again and again.. let me be clear..

i used System.out.println(-) statements to order to know actually where i am facing error,but could not find even.

1) using JBOSS 5.x,jdk1.6.

2) placed my oracle db software driver related JAR file (ojdbc6.jar for oracle 11g enterprise edition) in :

E:\jboss-5.1.0.GA-jdk6\jboss-5.1.0.GA\server\default\lib\ojdbc6.jar(my PC driver).


3)collected oracle-ds.xml from:
E:\jboss-5.1.0.GA-jdk6\jboss-5.1.0.GA\docs\examples\jca\oracle-ds.xml(my PC drive) and modified according to the oracle db software configuration in my PC

my code follows:
//connPoolServlet.java


=================================================================================================================
now please tell me where my mistake is.. I am once again thankful for your patience and please help me to learn something from my mistake ,so that i don't repeat it again.....Thanks a tonne.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's important to understand the exception stacktrace. Here's what it is:

15:14:16,853 ERROR [STDERR] java.lang.NullPointerException
15:14:16,854 ERROR [STDERR] at ConnPoolServlet.doGet(ConnPoolServlet.java:46)



It says that there's a NullPointerException at line 46 of your ConnPoolServlet. So you should check what line 46 is and then see what objects are possibly null. The code that you posted, I think line 46 is the statement which uses the "pw" variable which hasn't been initialized to a non-null value and that's why you received that NullPointerException.
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent JavaRanch............. yes ,it's my mistake that i didnt notice the initialization of PrintWriter object i just declared pw that's .Thanks a lot Jaikiran.. silly mistake , inever forget such things.. i read as NullPointerException at 46 but didn't notice the pw variable with null value as it's not initialized.
now i could access all table.. thankyou so much.. solved ....
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome!
 
Yeast devil! Back to the oven that baked you! And take this tiny ad too:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!