wood burning stoves 2.0*
The moose likes JBoss/WildFly and the fly likes Unable to run servlet program using Connection Pool in JBoss Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Unable to run servlet program using Connection Pool in JBoss" Watch "Unable to run servlet program using Connection Pool in JBoss" New topic
Author

Unable to run servlet program using Connection Pool in JBoss

Swetha Bhagavathula
Ranch Hand

Joined: Jan 04, 2011
Posts: 112

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 ...

SCJP5
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9947
    
161

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


[My Blog] [JavaRanch Journal]
Swetha Bhagavathula
Ranch Hand

Joined: Jan 04, 2011
Posts: 112


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

Joined: Jan 04, 2011
Posts: 112

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

Joined: Jan 04, 2011
Posts: 112

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
Marshal

Joined: Jul 20, 2005
Posts: 9947
    
161

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

Joined: Jan 04, 2011
Posts: 112

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

Joined: Jan 04, 2011
Posts: 112

I could see the below error :

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9947
    
161

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

Joined: Jan 04, 2011
Posts: 112

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
Marshal

Joined: Jul 20, 2005
Posts: 9947
    
161

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

Joined: Jan 04, 2011
Posts: 112

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
Marshal

Joined: Jul 20, 2005
Posts: 9947
    
161

You're welcome!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to run servlet program using Connection Pool in JBoss
 
Similar Threads
error to login page
Problem in using date in WHERE clause in SELECT query in Servlet.
Jboss 5.0 not able to connect to databse
Need help in JSP/Servlets
javax.servlet.ServletException: PWC1381: Error allocating a servlet instance