This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
problem in web application with connection pooling
Cathy Valdez
Greenhorn
Joined: Oct 22, 2003
Posts: 23
posted
0
Web Application with Connection Pooling problem Below are software installed in my PC: Windows98 Tomcat v. 4.1.27 J2SE/JDK v. 1.3.1 MySQL Server v. 4.0.17 MySQL Connector/J v. 3.0.10
Below is the content of AUTOEXEC.BAT:
From MySQL Server, I've created the database wordgames with tables (word, wordcategory & wordhint) under it. Below is the deployment descriptor (web.xml)and is located in the deployment path, c:\Tomcat\webapps\database\WEB-INF:
Java files below are located at the development path, c:\ServletDevel\database\sl314\domain: ScrambleGameService.java Word.java WordCategory.java WordCategoryDAO.java WordCategoryService.java WordDAO.java Files above were compiled successful and class files of each is copied in the deployment path, c:\Tomcat\webapps\database\WEB-INF\classes\sl314\domain NamingService.java is located at the development path, c:\ServletDevel\database\sl314\util: NamingService.java is compiled successful and its class file is copied in the deployment path, c:\Tomcat\webapps\database\WEB-INF\classes\sl314\util Java files below are located at the development path, c:\ServletDevel\database\sl314\web: InitializeConnectionPool.java ScrambleGameServlet.java Files above were compiled successful and class files of each is copied in the deployment path, c:\Tomcat\webapps\database\WEB-INF\classes\sl314\web When I entered the URL, http://localhost:8080/database/ for the message form in the Address field, the page for the URL, http://localhost:8080/database/index.html is displayed, looks like below: Duke's Arcade Select from one of the following games:
Word Scramble Word Guess
Then I selected the Word Scramble link, but errors below is displayed:
Below are the corresponding lines of the root cause of errors above: 1.) sl314.domain.WordCategoryDAO.selectAllCategories(WordCategoryDAO.java:38) Below is the code of line 38: connection = connectionPool.getConnectionNoWait(); 2.) sl314.domain.WordCategoryService.getCategories(WordCategoryService.java:16) Below is the code of line 16: return wordCatDataAccess.selectAllCategories(); 3.) sl314.web.ScrambleGameServlet.showCategories(ScrambleGameServlet.java:43) Below is the code of line 43: List categoryList = wordCatSvc.getCategories(); 4.) sl314.web.ScrambleGameServlet.doGet(ScrambleGameServlet.java:29) Below is the code of line 29:
showCategories(request, response); I'm new to connection pooling, are these errors have something to do with connection pooling? JAR file, conn_pool.jar is located at the deployment path: C:\Tomcat\webapps\database\WEB-INF\lib Can anybody there please help? I really need to make run this web application. Do you think the contents of autoexec.bat and web.xml above are okay? Cathy Valdez [ February 25, 2004: Message edited by: Cathy Valdez ]
Sorry it took me so lomg to get back to you. If anyone else wants to join in, this thread is related to the one here, which contains much more source code.
This means the connectionPool variable is null. It gets instantiated like this:
so it looks like the NamingService is returning null. The ConnectionPool gets initailised in InitializeConnectionPool like this:
Are you sure the ConnectionPool is being initialised? ie is the above code getting called, and is it working OK or does it return an error? If it returns an error, nothing will be written to the NamingService and life will go on. If this is a critical error, it may be better to allow an Exception to propogate so that your application stops. You can hardly continue, can you? Maybe (for now) cange it like this and see how it behaves:
...and see what happens. You may want to create your own checked Exception and throw that instead.
Cathy Valdez
Greenhorn
Joined: Oct 22, 2003
Posts: 23
posted
0
David O' Meara, I did your suggestions, but when I tried to compile InitializeConnectionPool.java , errors below were displayed:
Even ScrambleGameServlet.java when compiled, errors below occured:
Thank you for your time reading and making suggestions in my Post Ads. Cathy Valdez [ February 26, 2004: Message edited by: Cathy Valdez ]
Are you still compiling from the c:\ServletDevel\database\sl314\web directory and then copying them to the c:\Tomcat\webapps\database\WEB-INF\classes\sl314\web directory? Have you changed your classpath since last time? This is just a little bit wierd - InitializeConnectionPool can apparently see ServletContextListener but not ServletContextEvent. They are both from Servlets2.3, so you should be able to see both or neither. From the command line, try running these: javap javax.servlet.ServletContextListener javap javax.servlet.ServletContextEvent They should both return data, or your classpath is broken.
Cathy Valdez
Greenhorn
Joined: Oct 22, 2003
Posts: 23
posted
0
David O' Meara, Yes, I am still compiling from the c:\ServletDevel\database\sl314\web directory and then copying them to the c:\Tomcat\webapps\database\WEB-INF\classes\sl314\web directory. Below is the content of AUTOEXEC.BAT