atwoodj
asked on
jsp site crashing - need help understanding catalina.out
We have a JSP site that is crashing a lot and we cannot figure out why. I'd like some help understanding some entries in our catalina.out file so I can try to help solve the problem.
Two etnries in the log file I need explained. I am not a java programmer and am new to JSP so I'd appreciate clear, thorough explanations.
One.
+++
Mar 20, 2007 9:11:08 AM org.apache.tomcat.util.thr eads.Threa dPool$Cont rolRunnabl e run
SEVERE: Caught exception (java.lang.OutOfMemoryErro r: unable to create new native thread) executing org.apache.jk.common.Socke tAcceptor@ dab859, terminating thread
emilie007emilie007
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor29]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor28]
emilie007emilie007
+++
The "emilie007emilie007" bit comes from a login page. These were the last entries in the log before the site crashed. What do these entries tell me?
Two.
We get a lot of the following entries in the log and I don't know why. Can anyone explain what they mean?
+++++
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor26]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor27]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor28 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor29 from __JVM_DefineClass__]
+++++
If there is additional information you need, please let me know. Remember I'm very green here! Thanks so much.
Two etnries in the log file I need explained. I am not a java programmer and am new to JSP so I'd appreciate clear, thorough explanations.
One.
+++
Mar 20, 2007 9:11:08 AM org.apache.tomcat.util.thr
SEVERE: Caught exception (java.lang.OutOfMemoryErro
emilie007emilie007
[Unloading class sun.reflect.GeneratedConst
[Unloading class sun.reflect.GeneratedConst
emilie007emilie007
+++
The "emilie007emilie007" bit comes from a login page. These were the last entries in the log before the site crashed. What do these entries tell me?
Two.
We get a lot of the following entries in the log and I don't know why. Can anyone explain what they mean?
+++++
[Unloading class sun.reflect.GeneratedConst
[Unloading class sun.reflect.GeneratedConst
[Loaded sun.reflect.GeneratedConst
[Loaded sun.reflect.GeneratedConst
+++++
If there is additional information you need, please let me know. Remember I'm very green here! Thanks so much.
ASKER
@Kuldeepchaturvedi...
I'm agree that it is probably a bleeding application that is causing our problem. We are on a shared server and had our JVM heap size doubled but we are still getting the error.
The application is a bit complicated. It's an online stock market and investing simulation for students. It's been developed over the past year by a couple of different java programmers (which may have helped cause a problem in communication).
Students login, create their own company, and answer questions to an array of teacher-selected assignments about their business. Then they each have a portfolio of cash that they can invest in other companies. The share price of each company is affected by the trading that happens. Teachers manage the assignments, news announcements, rules, etc.
We've just had a group of 40 students start using the program. it's one of our first 'large' groups to simultaneously login. They are in the process of answering questions to the assignments. Yesterday in a 90 minute period we had to restart Tomcat 6 times. Not fun!
I think it started when we had them all login to the application.
Is there any way for me to tell what part of the application and coding might be bleeding and/or not releasing resources as they should?
I'm upping the point value on this because it's a lot deeper than I originally thought and might take a while for us to sort out.
I can post any coding necessary.
Here's a more complete excerpt from the log file if it helps.
+++++korea1396korea1396
korea1396korea1396
[Loaded org.apache.jsp.student.cla ss_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.student.Environments from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Enviro nments.cla ss]
[Loaded vss.student.CurrentNewsTag from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Curren tNewsTag.c lass]
[Loaded java.sql.SQLWarning from /usr/local/jdk1.5.0_06/jre /lib/rt.ja r]
[Loaded com.mysql.jdbc.Messages from file:/home2/dluebbe/public _html/WEB- INF/lib/my sql_jdbc.j ar]
[Loaded vss.student.Guidelines from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Guidel ines.class ]
[Loaded org.apache.jsp.student.ban k_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.student.ShowSymbols from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/ShowSy mbols.clas s]
[Loaded vss.student.PriceBean from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/PriceB ean.class]
[Loaded java.math.MutableBigIntege r from /usr/local/jdk1.5.0_06/jre /lib/rt.ja r]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor11 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor12 from __JVM_DefineClass__]
peter2peter2
peter2peter2
[Loaded sun.reflect.GeneratedConst ructorAcce ssor13 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor14 from __JVM_DefineClass__]
[Loaded org.apache.jsp.teacher.vie w_005fansw er_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.teacher.TagViewAssignm entsList from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/teac her/TagVie wAssignmen tsList.cla ss]
[Loaded vss.student.QuestionAnswer Bean from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Questi onAnswerBe an.class]
[Loaded vss.student.TradeServlet from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/TradeS ervlet.cla ss]
[Loaded org.apache.jsp.student.por tfolio_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.student.StudentShareTa g from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Studen tShareTag. class]
[Loaded vss.student.ShareBean from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/ShareB ean.class]
[Loaded vss.student.LoanDepositTag from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/LoanDe positTag.c lass]
[Loaded org.apache.jsp.student.mar ket_005fin fo_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.student.StudentMarketI nfoBean from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Studen tMarketInf oBean.clas s]
[Loaded vss.SharePriceBean from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/Shar ePriceBean .class]
[Loaded java.text.NumberFormat$Fie ld from /usr/local/jdk1.5.0_06/jre /lib/rt.ja r]
daisy2daisy2
[Loaded org.apache.jsp.student.con firmTrade_ jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.student.ConfirmTradeSe rvlet from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Confir mTradeServ let.class]
[Loaded org.apache.jsp.student.cre ate_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor14]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor13]
[Loaded org.apache.jsp.student.que stion_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.student.ClassAssignmen tsList from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/ClassA ssignments List.class ]
[Loaded org.apache.jsp.student.Ass ignmentDet ail_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.student.AssignTitleTag from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Assign TitleTag.c lass]
[Loaded vss.student.AssignmentDeta ilTag from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Assign mentDetail Tag.class]
[Loaded vss.student.QuestionBean from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Questi onBean.cla ss]
[Loaded vss.student.AnswerAssignme nt from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Answer Assignment .class]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor15 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor16 from __JVM_DefineClass__]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor15]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor16]
[Loaded sun.net.ConnectionResetExc eption from /usr/local/jdk1.5.0_06/jre /lib/rt.ja r]
lisa2148lisa2148
[Loaded sun.reflect.GeneratedConst ructorAcce ssor17 from __JVM_DefineClass__]
[Loaded org.apache.jsp.student.vie w_005fansw er_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.student.ViewAssignment sList from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/ViewAs signmentsL ist.class]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor18 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor19 from __JVM_DefineClass__]
SamKane1992SamKane1992
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor19]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor18]
emilie007emilie007
emilie007emilie007
[Loaded sun.reflect.GeneratedConst ructorAcce ssor20 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor21 from __JVM_DefineClass__]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor20]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor21]
Sushi5000Sushi5000
[Loaded org.apache.jsp.demo.Demo.d emo_005ffr ameset_005 fwelcome_j sp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded org.apache.jsp.Frames.topN avFrame2_0 05fwithSty le_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded org.apache.jsp.student.res earch_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.student.ResearchTag from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Resear chTag.clas s]
[Loaded vss.student.CancelTradeSer vlet from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/Cancel TradeServl et.class]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor22 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor23 from __JVM_DefineClass__]
SamKane1992SamKane1992
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor22]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor23]
[Loaded vss.student.LoanDepositBea n from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/LoanDe positBean. class]
[Loaded org.apache.jsp.alogin_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.admin.AdminCheck from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/admi n/AdminChe ck.class]
[Loaded org.apache.jsp.admin.permi t_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.admin.TeachersTag from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/admi n/Teachers Tag.class]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor24 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor25 from __JVM_DefineClass__]
[Loaded vss.admin.RunningListTag from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/admi n/RunningL istTag.cla ss]
[Loaded vss.admin.FinishedListTag from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/admi n/Finished ListTag.cl ass]
korea1396korea1396
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor24]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor25]
[Loaded org.apache.jsp.demo.Tutori al.tutoria l_005ffram eset_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded org.apache.jsp.demo.Demo.s tandards_j sp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded org.apache.jsp.learn.conta ct_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor26 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor27 from __JVM_DefineClass__]
[Loaded org.apache.jsp.student.Stu dentInfoB_ jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded org.apache.jsp.student.Iss ueConfirm_ jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor26]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor27]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor28 from __JVM_DefineClass__]
[Loaded sun.reflect.GeneratedConst ructorAcce ssor29 from __JVM_DefineClass__]
Sushi5000Sushi5000
evilfamily1evilfamily1
[Loaded org.apache.jsp.student.mar ket_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded vss.student.SShowDates from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/SShowD ates.class ]
[Loaded vss.student.ShowPrices from file:/home2/dluebbe/public _html/WEB- INF/classe s/vss/stud ent/ShowPr ices.class ]
[Loaded org.apache.jsp.advertising _jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
[Loaded org.apache.jsp.demo.Demo.f aqs_jsp from file:/usr/local/jakarta-dl uebbe/jaka rta-tomcat -5.5.7/wor k/Catalina /studentst ockmarket. com/_/]
Pisang57Pisang57
Pisang57Pisang57
ryud51587ryud51587
haenaS2haenaS2
haenaS2haenaS2
Mar 20, 2007 9:11:08 AM org.apache.tomcat.util.thr eads.Threa dPool$Cont rolRunnabl e run
SEVERE: Caught exception (java.lang.OutOfMemoryErro r: unable to create new native thread) executing org.apache.jk.common.Socke tAcceptor@ dab859, terminating thread
emilie007emilie007
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor29]
[Unloading class sun.reflect.GeneratedConst ructorAcce ssor28]
emilie007emilie007
I'm agree that it is probably a bleeding application that is causing our problem. We are on a shared server and had our JVM heap size doubled but we are still getting the error.
The application is a bit complicated. It's an online stock market and investing simulation for students. It's been developed over the past year by a couple of different java programmers (which may have helped cause a problem in communication).
Students login, create their own company, and answer questions to an array of teacher-selected assignments about their business. Then they each have a portfolio of cash that they can invest in other companies. The share price of each company is affected by the trading that happens. Teachers manage the assignments, news announcements, rules, etc.
We've just had a group of 40 students start using the program. it's one of our first 'large' groups to simultaneously login. They are in the process of answering questions to the assignments. Yesterday in a 90 minute period we had to restart Tomcat 6 times. Not fun!
I think it started when we had them all login to the application.
Is there any way for me to tell what part of the application and coding might be bleeding and/or not releasing resources as they should?
I'm upping the point value on this because it's a lot deeper than I originally thought and might take a while for us to sort out.
I can post any coding necessary.
Here's a more complete excerpt from the log file if it helps.
+++++korea1396korea1396
korea1396korea1396
[Loaded org.apache.jsp.student.cla
[Loaded vss.student.Environments from file:/home2/dluebbe/public
[Loaded vss.student.CurrentNewsTag
[Loaded java.sql.SQLWarning from /usr/local/jdk1.5.0_06/jre
[Loaded com.mysql.jdbc.Messages from file:/home2/dluebbe/public
[Loaded vss.student.Guidelines from file:/home2/dluebbe/public
[Loaded org.apache.jsp.student.ban
[Loaded vss.student.ShowSymbols from file:/home2/dluebbe/public
[Loaded vss.student.PriceBean from file:/home2/dluebbe/public
[Loaded java.math.MutableBigIntege
[Loaded sun.reflect.GeneratedConst
[Loaded sun.reflect.GeneratedConst
peter2peter2
peter2peter2
[Loaded sun.reflect.GeneratedConst
[Loaded sun.reflect.GeneratedConst
[Loaded org.apache.jsp.teacher.vie
[Loaded vss.teacher.TagViewAssignm
[Loaded vss.student.QuestionAnswer
[Loaded vss.student.TradeServlet from file:/home2/dluebbe/public
[Loaded org.apache.jsp.student.por
[Loaded vss.student.StudentShareTa
[Loaded vss.student.ShareBean from file:/home2/dluebbe/public
[Loaded vss.student.LoanDepositTag
[Loaded org.apache.jsp.student.mar
[Loaded vss.student.StudentMarketI
[Loaded vss.SharePriceBean from file:/home2/dluebbe/public
[Loaded java.text.NumberFormat$Fie
daisy2daisy2
[Loaded org.apache.jsp.student.con
[Loaded vss.student.ConfirmTradeSe
[Loaded org.apache.jsp.student.cre
[Unloading class sun.reflect.GeneratedConst
[Unloading class sun.reflect.GeneratedConst
[Loaded org.apache.jsp.student.que
[Loaded vss.student.ClassAssignmen
[Loaded org.apache.jsp.student.Ass
[Loaded vss.student.AssignTitleTag
[Loaded vss.student.AssignmentDeta
[Loaded vss.student.QuestionBean from file:/home2/dluebbe/public
[Loaded vss.student.AnswerAssignme
[Loaded sun.reflect.GeneratedConst
[Loaded sun.reflect.GeneratedConst
[Unloading class sun.reflect.GeneratedConst
[Unloading class sun.reflect.GeneratedConst
[Loaded sun.net.ConnectionResetExc
lisa2148lisa2148
[Loaded sun.reflect.GeneratedConst
[Loaded org.apache.jsp.student.vie
[Loaded vss.student.ViewAssignment
[Loaded sun.reflect.GeneratedConst
[Loaded sun.reflect.GeneratedConst
SamKane1992SamKane1992
[Unloading class sun.reflect.GeneratedConst
[Unloading class sun.reflect.GeneratedConst
emilie007emilie007
emilie007emilie007
[Loaded sun.reflect.GeneratedConst
[Loaded sun.reflect.GeneratedConst
[Unloading class sun.reflect.GeneratedConst
[Unloading class sun.reflect.GeneratedConst
Sushi5000Sushi5000
[Loaded org.apache.jsp.demo.Demo.d
[Loaded org.apache.jsp.Frames.topN
[Loaded org.apache.jsp.student.res
[Loaded vss.student.ResearchTag from file:/home2/dluebbe/public
[Loaded vss.student.CancelTradeSer
[Loaded sun.reflect.GeneratedConst
[Loaded sun.reflect.GeneratedConst
SamKane1992SamKane1992
[Unloading class sun.reflect.GeneratedConst
[Unloading class sun.reflect.GeneratedConst
[Loaded vss.student.LoanDepositBea
[Loaded org.apache.jsp.alogin_jsp from file:/usr/local/jakarta-dl
[Loaded vss.admin.AdminCheck from file:/home2/dluebbe/public
[Loaded org.apache.jsp.admin.permi
[Loaded vss.admin.TeachersTag from file:/home2/dluebbe/public
[Loaded sun.reflect.GeneratedConst
[Loaded sun.reflect.GeneratedConst
[Loaded vss.admin.RunningListTag from file:/home2/dluebbe/public
[Loaded vss.admin.FinishedListTag from file:/home2/dluebbe/public
korea1396korea1396
[Unloading class sun.reflect.GeneratedConst
[Unloading class sun.reflect.GeneratedConst
[Loaded org.apache.jsp.demo.Tutori
[Loaded org.apache.jsp.demo.Demo.s
[Loaded org.apache.jsp.learn.conta
[Loaded sun.reflect.GeneratedConst
[Loaded sun.reflect.GeneratedConst
[Loaded org.apache.jsp.student.Stu
[Loaded org.apache.jsp.student.Iss
[Unloading class sun.reflect.GeneratedConst
[Unloading class sun.reflect.GeneratedConst
[Loaded sun.reflect.GeneratedConst
[Loaded sun.reflect.GeneratedConst
Sushi5000Sushi5000
evilfamily1evilfamily1
[Loaded org.apache.jsp.student.mar
[Loaded vss.student.SShowDates from file:/home2/dluebbe/public
[Loaded vss.student.ShowPrices from file:/home2/dluebbe/public
[Loaded org.apache.jsp.advertising
[Loaded org.apache.jsp.demo.Demo.f
Pisang57Pisang57
Pisang57Pisang57
ryud51587ryud51587
haenaS2haenaS2
haenaS2haenaS2
Mar 20, 2007 9:11:08 AM org.apache.tomcat.util.thr
SEVERE: Caught exception (java.lang.OutOfMemoryErro
emilie007emilie007
[Unloading class sun.reflect.GeneratedConst
[Unloading class sun.reflect.GeneratedConst
emilie007emilie007
Wow thats going to be a pretty complex application in my opinion.. By going thru the exception trace, I think its a case of bleeding some where. Also there is a fair chance of sessions getting out of hand.... Can you confirm how the sessions are being used in your app? I mean how much of data is being put in the session by each user..
as far as checking for memory leaks are concern, there are some profiler ( like jprofiler) who can check it out for you but they are costly softwares..
Also can you test the app with less number of users? say 5-8 and see how the app holds up..
Also check how the database access is being managed? is it using connection pools? are the connections being released after every operation? this is the most common problem of the systems when it comes to slow performance and heavy memory uses
check these things and let me know if you find any thing
as far as checking for memory leaks are concern, there are some profiler ( like jprofiler) who can check it out for you but they are costly softwares..
Also can you test the app with less number of users? say 5-8 and see how the app holds up..
Also check how the database access is being managed? is it using connection pools? are the connections being released after every operation? this is the most common problem of the systems when it comes to slow performance and heavy memory uses
check these things and let me know if you find any thing
ASKER
Our site just crashed as the kids started to login. That leads me to believe it's something with the login procedure.
Does any of the following code look like it could be causing problems?
package vss;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.text.SimpleDateFormat ;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
import vss.student.StudentBean;
import vss.ConnectionFactory.Conn ectionFact ory;
import java.sql.Connection;
public class StudentLoginB extends HttpServlet {
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
request.setAttribute("opti on", "forward");
HttpSession session = request.getSession();
String username = request.getParameter("user name");
String password = request.getParameter("pass word");
String class_id = null;
String pass = null;
String high_pass = null;
Connection conn = ConnectionFactory.getConn( );
String query =
"select password, high_password, class_id from student where username='" + username + "'";
try {
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(query);
if (rset.next()) {
pass = rset.getString(1);
high_pass = rset.getString(2);
class_id = rset.getString(3);
if (!pass.equalsIgnoreCase(pa ssword) &&
!high_pass.equalsIgnoreCas e(password )) {
session.setAttribute("Erro rMsg",
"I'm sorry, that is not a valid password.");
query = null;
}else {
query = "select s.id, s.name, s.class_id, s.company_name, s.symbol, s.cash, s.deposit" +
", s.dcheck, s.lcheck, s.confirm, s.username, s.email" +
", c.class_name, c.status, c.start_time, c.end_time" +
" from student s, class c where s.class_id=" +
Integer.parseInt(class_id) + " and s.username='" + username +
"' and c.id=" + Integer.parseInt(class_id) ;
}
} else {
session.setAttribute("Erro rMsg",
"I'm sorry, that is not a valid user name.");
query = null;
}
if (query != null) {
Enumeration enume = session.getAttributeNames( );
while (enume.hasMoreElements()) {
String attrNm = (String) enume.nextElement();
if (! (attrNm.equals("country") || attrNm.equals("state") ||
attrNm.equals("city"))) {
session.removeAttribute(at trNm);
}
}
rset = stmt.executeQuery(query);
rset.next();
StudentBean student = new StudentBean();
student.setId(rset.getInt( "id"));
String name = rset.getString("name");
int space = name.indexOf(' ');
String tmpname = name.substring(space + 1) + " " +
name.substring(0, space);
student.setName(tmpname);
student.setPassword(pass);
student.setHigh_password(h igh_pass);
student.setClass_id(rset.g etInt("cla ss_id"));
student.setCompany_name(rs et.getStri ng("compan y_name"));
student.setSymbol(rset.get String("sy mbol"));
student.setCash(rset.getDo uble("cash "));
//student.setDeposit(rset. getDouble( "deposit") );
student.setClass_name(rset .getString ("class_na me"));
student.setClassStatus(rse t.getInt(" status"));
student.setDcheck("" + rset.getString("dcheck"));
student.setLcheck("" + rset.getString("lcheck"));
student.setConfirm(rset.ge tInt("conf irm"));
if(rset.getString("usernam e")==null ||
"null".equalsIgnoreCase(rs et.getStri ng("userna me"))){
student.setUsername("");
}else{
student.setUsername("" + rset.getString("username") );
}
System.out.println(rset.ge tString("u sername") + student.getUsername());
if(rset.getString("email") ==null
|| "null".equalsIgnoreCase(rs et.getStri ng("email" ))){
student.setEmail("");
}else{
student.setEmail("" + rset.getString("email"));
}
String start_date = null;
String end_date = null;
if (rset.getDate("start_time" ) != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM- dd");
start_date = sdf.format(rset.getDate("s tart_time" ));
}
if (rset.getDate("end_time") != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM- dd");
end_date = sdf.format(rset.getDate("e nd_time")) ;
}
student.setGameStartTime(s tart_date) ;
student.setGameEndTime(end _date);
session.setAttribute("type ", "1");
session.setAttribute("user Bean", student);
if(pass.equalsIgnoreCase(" stock"))
response.sendRedirect("stu dent/Stude ntInfoB.js p");
else
response.sendRedirect("stu dent/class .jsp");
} else {
response.sendRedirect("log ins.jsp");
}
} catch (SQLException sqle) {
session.setAttribute("noen ddate", "noenddate");
response.sendRedirect("log ins.jsp");
} finally {
ConnectionFactory.closeCon n(conn);
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
doGet(request, response);
}
}
Does any of the following code look like it could be causing problems?
package vss;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.text.SimpleDateFormat
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
import vss.student.StudentBean;
import vss.ConnectionFactory.Conn
import java.sql.Connection;
public class StudentLoginB extends HttpServlet {
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
request.setAttribute("opti
HttpSession session = request.getSession();
String username = request.getParameter("user
String password = request.getParameter("pass
String class_id = null;
String pass = null;
String high_pass = null;
Connection conn = ConnectionFactory.getConn(
String query =
"select password, high_password, class_id from student where username='" + username + "'";
try {
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(query);
if (rset.next()) {
pass = rset.getString(1);
high_pass = rset.getString(2);
class_id = rset.getString(3);
if (!pass.equalsIgnoreCase(pa
!high_pass.equalsIgnoreCas
session.setAttribute("Erro
"I'm sorry, that is not a valid password.");
query = null;
}else {
query = "select s.id, s.name, s.class_id, s.company_name, s.symbol, s.cash, s.deposit" +
", s.dcheck, s.lcheck, s.confirm, s.username, s.email" +
", c.class_name, c.status, c.start_time, c.end_time" +
" from student s, class c where s.class_id=" +
Integer.parseInt(class_id)
"' and c.id=" + Integer.parseInt(class_id)
}
} else {
session.setAttribute("Erro
"I'm sorry, that is not a valid user name.");
query = null;
}
if (query != null) {
Enumeration enume = session.getAttributeNames(
while (enume.hasMoreElements()) {
String attrNm = (String) enume.nextElement();
if (! (attrNm.equals("country") || attrNm.equals("state") ||
attrNm.equals("city"))) {
session.removeAttribute(at
}
}
rset = stmt.executeQuery(query);
rset.next();
StudentBean student = new StudentBean();
student.setId(rset.getInt(
String name = rset.getString("name");
int space = name.indexOf(' ');
String tmpname = name.substring(space + 1) + " " +
name.substring(0, space);
student.setName(tmpname);
student.setPassword(pass);
student.setHigh_password(h
student.setClass_id(rset.g
student.setCompany_name(rs
student.setSymbol(rset.get
student.setCash(rset.getDo
//student.setDeposit(rset.
student.setClass_name(rset
student.setClassStatus(rse
student.setDcheck("" + rset.getString("dcheck"));
student.setLcheck("" + rset.getString("lcheck"));
student.setConfirm(rset.ge
if(rset.getString("usernam
"null".equalsIgnoreCase(rs
student.setUsername("");
}else{
student.setUsername("" + rset.getString("username")
}
System.out.println(rset.ge
if(rset.getString("email")
|| "null".equalsIgnoreCase(rs
student.setEmail("");
}else{
student.setEmail("" + rset.getString("email"));
}
String start_date = null;
String end_date = null;
if (rset.getDate("start_time"
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-
start_date = sdf.format(rset.getDate("s
}
if (rset.getDate("end_time") != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-
end_date = sdf.format(rset.getDate("e
}
student.setGameStartTime(s
student.setGameEndTime(end
session.setAttribute("type
session.setAttribute("user
if(pass.equalsIgnoreCase("
response.sendRedirect("stu
else
response.sendRedirect("stu
} else {
response.sendRedirect("log
}
} catch (SQLException sqle) {
session.setAttribute("noen
response.sendRedirect("log
} finally {
ConnectionFactory.closeCon
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
doGet(request, response);
}
}
This code looks harmless to me.. only trobule that it could have created was not to close the database connection which it is closing in Finally block..
can you post code for class.jsp and student InfoB.jsp?
can you post code for class.jsp and student InfoB.jsp?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@Kuldeepchaturvedi
I will post the code for the class.jsp page along with the code for the three .java files that are called when this page is loaded.
Just to help you all understand. This class.jsp page is the main page that each student lands on after logging in. They also return to this page several times while logged in. Which may relate to something that mayankeagle has mentioned and the use of session.setAttribute. I notice in the code for that session.setAttribute is used at least three times each time the class.jsp page is loaded.
Here's my question @mayankeagle: Each time that class.jsp is loaded, is a new object created for each instance of a session.setAttribute call? So even if the same student refreshes the class.jsp page multiple objects are created as session variables that would keep piling up?
I'll post the code in four separate instances.
1. class.jsp
2. CurrentNewsTag.java
3. Environments.java
4. Guidelines.java
I will post the code for the class.jsp page along with the code for the three .java files that are called when this page is loaded.
Just to help you all understand. This class.jsp page is the main page that each student lands on after logging in. They also return to this page several times while logged in. Which may relate to something that mayankeagle has mentioned and the use of session.setAttribute. I notice in the code for that session.setAttribute is used at least three times each time the class.jsp page is loaded.
Here's my question @mayankeagle: Each time that class.jsp is loaded, is a new object created for each instance of a session.setAttribute call? So even if the same student refreshes the class.jsp page multiple objects are created as session variables that would keep piling up?
I'll post the code in four separate instances.
1. class.jsp
2. CurrentNewsTag.java
3. Environments.java
4. Guidelines.java
ASKER
Here's the code for class.jsp:
<%@ taglib prefix="student" uri="/WEB-INF/taglib.tld" %>
<html>
<head>
<script type="text/javascript" language="JavaScript">
<!-- Copyright 2002 Bontrager Connection, LLC
function getCalendarDate()
{
var months = new Array(13);
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";
var now = new Date();
var monthnumber = now.getMonth();
var monthname = months[monthnumber];
var monthday = now.getDate();
var year = now.getYear();
if(year < 2000) { year = year + 1900; }
var dateString = monthname +
' ' +
monthday +
', ' +
year;
return dateString;
} // function getCalendarDate()
function getClockTime()
{
var now = new Date();
var hour = now.getHours();
var minute = now.getMinutes();
var ap = "AM";
if (hour > 11) { ap = "PM"; }
if (hour > 12) { hour = hour - 12; }
if (hour == 0) { hour = 12; }
if (hour < 10) { hour = "0" + hour; }
if (minute < 10) { minute = "0" + minute; }
var timeString = hour +
':' +
minute +
" " +
ap;
return timeString;
} // function getClockTime()
//-->
</script>
<title>Simulation Homepage</title>
<link href="../css/MainStyle.css " rel="stylesheet" type="text/css">
<link href="../css/topNavStyle.c ss" rel="stylesheet" type="text/css">
</head>
<body>
<%@ include file="../Frames/topNavFram e2.jsp" %>
<!-- Include head and menu -->
<%
String value = (String)request.getParamet er("pageId ");
if(value != null){
pageContext.setAttribute(" pageId", value);
}
%>
<!-- Content -->
<% vss.student.StudentBean student = (vss.student.StudentBean)s ession.get Attribute( "userBean" );
pageContext.setAttribute(" class_id", ""+student.getClass_id());
%>
<div class="pageHeader">
<%=student.getName()%> :: <%=student.getClass_name() %><br>
<script type="text/javascript" language="JavaScript">
<!--
var calendarDate = getCalendarDate();
var clockTime = getClockTime();
document.write(calendarDat e);
document.write(" :: ");
document.write(clockTime);
//-->
</script><br>
Trading starts on <%=student.getGameStartTim e() %><br>
Trading ends on <%=student.getGameEndTime( ) %>
</div>
<div class="pageTitle">
<h1><%=student.getClass_na me()%> simHome </h1>
<h2>Welcome to the simulation homepage for your class. </h2>
</div>
<div id="mainBodyText"> Read through the Environment and Rules & Guidelines sections. Also, regularly check the Bulletin Board for any announcements that may influence your business or investing strategies. </div>
<table width="96%"border="0" align="center" cellpadding="5" cellspacing="0" class="tableBorder">
<tr>
<td width="25%" valign="top">
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<th>Environment</th>
</tr>
<tr><td valign="top">
<student:Environments>
</student:Environments>
</td>
</tr>
</table>
</td>
<td width=75% rowspan=2 valign="top">
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<th>Bulletin Board</th>
</tr>
<tr>
<td valign="top">
<student:CurrentNewsTag>
</student:CurrentNewsTag>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign=top>
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<th>Rules & Guidelines</th>
</tr>
<tr>
<td valign="top" class="noBorderCell">
<student:Guidelines>
</student:Guidelines>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p> </p>
</body>
</html>
<%@ taglib prefix="student" uri="/WEB-INF/taglib.tld" %>
<html>
<head>
<script type="text/javascript" language="JavaScript">
<!-- Copyright 2002 Bontrager Connection, LLC
function getCalendarDate()
{
var months = new Array(13);
months[0] = "January";
months[1] = "February";
months[2] = "March";
months[3] = "April";
months[4] = "May";
months[5] = "June";
months[6] = "July";
months[7] = "August";
months[8] = "September";
months[9] = "October";
months[10] = "November";
months[11] = "December";
var now = new Date();
var monthnumber = now.getMonth();
var monthname = months[monthnumber];
var monthday = now.getDate();
var year = now.getYear();
if(year < 2000) { year = year + 1900; }
var dateString = monthname +
' ' +
monthday +
', ' +
year;
return dateString;
} // function getCalendarDate()
function getClockTime()
{
var now = new Date();
var hour = now.getHours();
var minute = now.getMinutes();
var ap = "AM";
if (hour > 11) { ap = "PM"; }
if (hour > 12) { hour = hour - 12; }
if (hour == 0) { hour = 12; }
if (hour < 10) { hour = "0" + hour; }
if (minute < 10) { minute = "0" + minute; }
var timeString = hour +
':' +
minute +
" " +
ap;
return timeString;
} // function getClockTime()
//-->
</script>
<title>Simulation Homepage</title>
<link href="../css/MainStyle.css
<link href="../css/topNavStyle.c
</head>
<body>
<%@ include file="../Frames/topNavFram
<!-- Include head and menu -->
<%
String value = (String)request.getParamet
if(value != null){
pageContext.setAttribute("
}
%>
<!-- Content -->
<% vss.student.StudentBean student = (vss.student.StudentBean)s
pageContext.setAttribute("
%>
<div class="pageHeader">
<%=student.getName()%> :: <%=student.getClass_name()
<script type="text/javascript" language="JavaScript">
<!--
var calendarDate = getCalendarDate();
var clockTime = getClockTime();
document.write(calendarDat
document.write(" :: ");
document.write(clockTime);
//-->
</script><br>
Trading starts on <%=student.getGameStartTim
Trading ends on <%=student.getGameEndTime(
</div>
<div class="pageTitle">
<h1><%=student.getClass_na
<h2>Welcome to the simulation homepage for your class. </h2>
</div>
<div id="mainBodyText"> Read through the Environment and Rules & Guidelines sections. Also, regularly check the Bulletin Board for any announcements that may influence your business or investing strategies. </div>
<table width="96%"border="0" align="center" cellpadding="5" cellspacing="0" class="tableBorder">
<tr>
<td width="25%" valign="top">
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<th>Environment</th>
</tr>
<tr><td valign="top">
<student:Environments>
</student:Environments>
</td>
</tr>
</table>
</td>
<td width=75% rowspan=2 valign="top">
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<th>Bulletin Board</th>
</tr>
<tr>
<td valign="top">
<student:CurrentNewsTag>
</student:CurrentNewsTag>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign=top>
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
<th>Rules & Guidelines</th>
</tr>
<tr>
<td valign="top" class="noBorderCell">
<student:Guidelines>
</student:Guidelines>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p> </p>
</body>
</html>
ASKER
CurrentNewsTag.java
package vss.student;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.* ;
import java.util.ArrayList;
import java.sql.*;
import vss.ConnectionFactory.*;
import java.io.IOException;
import vss.TextFormat;
public class CurrentNewsTag
extends TagSupport {
private int count;
private String stime = null;
private String sdate = null;
private String content = null;
public int doStartTag() {
Connection conn = ConnectionFactory.getConn( );
try {
String sid = "" + pageContext.getAttribute(" class_id") ;
int id = Integer.parseInt(sid);
String query =
"select time, time, content from bulletinboard where class_id=" +
id + " order by id desc";
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(query);
if (rset.next()) {
Time time = rset.getTime(1);
stime = time.toString();
Date date = rset.getDate(2);
sdate = date.toString();
content = rset.getString(3);
}
}
catch (Exception e) {
System.err.println("vss.st udent.Curr entNewsTag .doStartTa g()");
System.err.println(e);
}
finally {
ConnectionFactory.closeCon n(conn);
}
return EVAL_BODY_INCLUDE;
}
public int doAfterBody() throws JspException {
try {
if (sdate == null) {
pageContext.getOut().print ln("There is no news now!");
}
else {
TextFormat.out(pageContext .getOut(), content);
}
}
catch (Exception ioe) {
System.err.println("vss.st udent.Curr entNewsTag .doAfterBo dy()");
System.err.println(ioe);
}
return SKIP_BODY;
}
}
package vss.student;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*
import java.util.ArrayList;
import java.sql.*;
import vss.ConnectionFactory.*;
import java.io.IOException;
import vss.TextFormat;
public class CurrentNewsTag
extends TagSupport {
private int count;
private String stime = null;
private String sdate = null;
private String content = null;
public int doStartTag() {
Connection conn = ConnectionFactory.getConn(
try {
String sid = "" + pageContext.getAttribute("
int id = Integer.parseInt(sid);
String query =
"select time, time, content from bulletinboard where class_id=" +
id + " order by id desc";
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(query);
if (rset.next()) {
Time time = rset.getTime(1);
stime = time.toString();
Date date = rset.getDate(2);
sdate = date.toString();
content = rset.getString(3);
}
}
catch (Exception e) {
System.err.println("vss.st
System.err.println(e);
}
finally {
ConnectionFactory.closeCon
}
return EVAL_BODY_INCLUDE;
}
public int doAfterBody() throws JspException {
try {
if (sdate == null) {
pageContext.getOut().print
}
else {
TextFormat.out(pageContext
}
}
catch (Exception ioe) {
System.err.println("vss.st
System.err.println(ioe);
}
return SKIP_BODY;
}
}
ASKER
Environments.java
package vss.student;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.* ;
import java.util.*;
import java.sql.*;
import vss.ConnectionFactory.*;
import java.io.IOException;
import javax.servlet.http.HttpSes sion;
import vss.TextFormat;
public class Environments
extends TagSupport {
private StudentBean object;
private String environment = null;
public int doStartTag() {
object = (StudentBean) pageContext.getSession().g etAttribut e("userBea n");
String query = "select environment from class where id=" +
object.getClass_id();
Connection conn = ConnectionFactory.getConn( );
try {
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(query);
rset.next();
environment = rset.getString(1);
}
catch (SQLException sqle) {
System.err.println("vss.st udent.Envi ronments.d oStartTag( )");
System.err.println(sqle);
}
finally {
ConnectionFactory.closeCon n(conn);
}
return EVAL_BODY_INCLUDE;
}
public int doAfterBody() throws JspException {
try {
boolean flag = false;
if (environment == null) {
pageContext.getOut().print ln(
"The Environment has not been set!");
}
else if (environment.length() > 300) {
//pageContext.getOut().pri ntln(envir onment.sub string(0, 300) + "...");
TextFormat.out(pageContext .getOut(),
environment.substring(0, 300) + "...");
flag = true;
}
else {
TextFormat.out(pageContext .getOut(), environment);
//pageContext.getOut().pri ntln(envir onment);
}
HttpSession session = pageContext.getSession();
session.setAttribute("SEnv ", environment);
if (flag) {
pageContext.getOut().print ln("<div class=\'readMore\'>");
pageContext.getOut().print ln(
"<a href=\"./fullDesc.jsp\" target=\"_blank\">Read full description...</a>");
pageContext.getOut().print ln("</div> ");
}
}
catch (Exception e) {
System.err.println("vss.st udent.Envi ronments.d oAfterBody ()");
System.err.println(e);
}
return SKIP_BODY;
}
}
package vss.student;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*
import java.util.*;
import java.sql.*;
import vss.ConnectionFactory.*;
import java.io.IOException;
import javax.servlet.http.HttpSes
import vss.TextFormat;
public class Environments
extends TagSupport {
private StudentBean object;
private String environment = null;
public int doStartTag() {
object = (StudentBean) pageContext.getSession().g
String query = "select environment from class where id=" +
object.getClass_id();
Connection conn = ConnectionFactory.getConn(
try {
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(query);
rset.next();
environment = rset.getString(1);
}
catch (SQLException sqle) {
System.err.println("vss.st
System.err.println(sqle);
}
finally {
ConnectionFactory.closeCon
}
return EVAL_BODY_INCLUDE;
}
public int doAfterBody() throws JspException {
try {
boolean flag = false;
if (environment == null) {
pageContext.getOut().print
"The Environment has not been set!");
}
else if (environment.length() > 300) {
//pageContext.getOut().pri
TextFormat.out(pageContext
environment.substring(0, 300) + "...");
flag = true;
}
else {
TextFormat.out(pageContext
//pageContext.getOut().pri
}
HttpSession session = pageContext.getSession();
session.setAttribute("SEnv
if (flag) {
pageContext.getOut().print
pageContext.getOut().print
"<a href=\"./fullDesc.jsp\" target=\"_blank\">Read full description...</a>");
pageContext.getOut().print
}
}
catch (Exception e) {
System.err.println("vss.st
System.err.println(e);
}
return SKIP_BODY;
}
}
ASKER
Guidelines.java
package vss.student;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.* ;
import java.util.*;
import java.sql.*;
import vss.ConnectionFactory.*;
import java.io.IOException;
import javax.servlet.http.HttpSes sion;
import vss.TextFormat;
public class Guidelines
extends TagSupport {
private StudentBean object;
private String guideline = null;
public int doStartTag() {
object = (StudentBean) pageContext.getSession().g etAttribut e("userBea n");
String query = "select guideline from class where id=" +
object.getClass_id();
Connection conn = ConnectionFactory.getConn( );
try {
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(query);
rset.next();
guideline = rset.getString(1);
}
catch (SQLException sqle) {
System.err.println("vss.st udent.Guid elines.doS tartTag()" );
System.err.println(sqle);
}
finally {
ConnectionFactory.closeCon n(conn);
}
return EVAL_BODY_INCLUDE;
}
public int doAfterBody() throws JspException {
try {
/*boolean flag = false;
if (guideline == null) {
pageContext.getOut().print ln("No Guidelines Now!");
}
else if (guideline.length() > 300) {
//pageContext.getOut().pri ntln(guide line.subst ring(0, 300) + "...");
TextFormat.out(pageContext .getOut(),
guideline.substring(0, 300) + "...");
flag = true;
}
else {
TextFormat.out(pageContext .getOut(), guideline);
//pageContext.getOut().pri ntln(guide line);
}
pageContext.getOut().print ln("</b></ font></td> </tr>");
*/
//if (flag) {
String rules = "1. Each participant will be given $10,000 to invest. Each participant can invest in companies, invest in a Certificate of Deposit (CD) from the bank, take out a loan from the bank, or do nothing at all.\n<br><br>2. No participant will be able to make more than...";
TextFormat.out(pageContext .getOut(), rules);
HttpSession session = pageContext.getSession();
session.setAttribute("SGui ", guideline);
pageContext.getOut().print ln("<div class=\'readMore\'>");
pageContext.getOut().print ln(
"<a href=\"./fullDesc.jsp\" target=\"_blank\">Read full description...</a>");
pageContext.getOut().print ln("</div> ");
//}
}
catch (Exception e) {
System.err.println("vss.st udent.Guid elines.doA fterBody() ");
System.err.println(e);
}
return SKIP_BODY;
}
}
package vss.student;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*
import java.util.*;
import java.sql.*;
import vss.ConnectionFactory.*;
import java.io.IOException;
import javax.servlet.http.HttpSes
import vss.TextFormat;
public class Guidelines
extends TagSupport {
private StudentBean object;
private String guideline = null;
public int doStartTag() {
object = (StudentBean) pageContext.getSession().g
String query = "select guideline from class where id=" +
object.getClass_id();
Connection conn = ConnectionFactory.getConn(
try {
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(query);
rset.next();
guideline = rset.getString(1);
}
catch (SQLException sqle) {
System.err.println("vss.st
System.err.println(sqle);
}
finally {
ConnectionFactory.closeCon
}
return EVAL_BODY_INCLUDE;
}
public int doAfterBody() throws JspException {
try {
/*boolean flag = false;
if (guideline == null) {
pageContext.getOut().print
}
else if (guideline.length() > 300) {
//pageContext.getOut().pri
TextFormat.out(pageContext
guideline.substring(0, 300) + "...");
flag = true;
}
else {
TextFormat.out(pageContext
//pageContext.getOut().pri
}
pageContext.getOut().print
*/
//if (flag) {
String rules = "1. Each participant will be given $10,000 to invest. Each participant can invest in companies, invest in a Certificate of Deposit (CD) from the bank, take out a loan from the bank, or do nothing at all.\n<br><br>2. No participant will be able to make more than...";
TextFormat.out(pageContext
HttpSession session = pageContext.getSession();
session.setAttribute("SGui
pageContext.getOut().print
pageContext.getOut().print
"<a href=\"./fullDesc.jsp\" target=\"_blank\">Read full description...</a>");
pageContext.getOut().print
//}
}
catch (Exception e) {
System.err.println("vss.st
System.err.println(e);
}
return SKIP_BODY;
}
}
>> Each time that class.jsp is loaded, is a new object created for each instance of a session.setAttribute call?
Yes
Yes
ASKER
@mayankeagle
...so would that mean that all of these session objects are being created and not destroyed and that this would then cause the server to slow down as more and more of these objects are created?
Additionally, would using request.setAttribute () instead of session.setAttribute achieve the same result for the user when they load the class.jsp page? ...but the objects would be destroyed immediately after being served and not pile up?
[Sorry, but I'm very new to this and I have to try to explain this to my programmer, who doesn't speak English as his first language. I have to make sure I fully understand what's going on.]
...so would that mean that all of these session objects are being created and not destroyed and that this would then cause the server to slow down as more and more of these objects are created?
Additionally, would using request.setAttribute () instead of session.setAttribute achieve the same result for the user when they load the class.jsp page? ...but the objects would be destroyed immediately after being served and not pile up?
[Sorry, but I'm very new to this and I have to try to explain this to my programmer, who doesn't speak English as his first language. I have to make sure I fully understand what's going on.]
>> so would that mean that all of these session objects are being created and not destroyed
Yes they remain in the session as long as the user is logged on.
>> that this would then cause the server to slow down as more and more of these objects are created?
Yes because of higher memory usage.
>> would using request.setAttribute () instead of session.setAttribute achieve the same result for the user when they load the class.jsp page
Yes.
>> but the objects would be destroyed immediately after being served and not pile up?
Yes again. Your understanding is correct. The objects will be garbage collected when the request object is garbage collected.
Yes they remain in the session as long as the user is logged on.
>> that this would then cause the server to slow down as more and more of these objects are created?
Yes because of higher memory usage.
>> would using request.setAttribute () instead of session.setAttribute achieve the same result for the user when they load the class.jsp page
Yes.
>> but the objects would be destroyed immediately after being served and not pile up?
Yes again. Your understanding is correct. The objects will be garbage collected when the request object is garbage collected.
>>Each time that class.jsp is loaded, is a new object created for each instance of a session.setAttribute call?
>>Yes
when you are getting a object from session.. there no new object getting created. It returns ONLY the reference of the object stored in the session ( unless its a primitive type object, i.e. string, interger etc)..
StudentClass is not getting created over & over again in class jsp.. its just getting the reference from session again & again which is trivial in memory uses terms..
However all your tags are connecting to the database and then disconnecting again...
This will lead to a slow performance.. ( in class.jsp the code ends up connecting & disconnecting three times)...
I am not sure how your connectionFactory is implemented but after looking at this code I am fairly certain that there is something fishy going on inside this factory..
Rest of the code looks fairly straightforward & in my opinion is not likely to cause a memory leak anywhere..
oh by the way.. Its one of the worst practice to define methods in a jsp file..(getCalenderDate)!!
>>Yes
when you are getting a object from session.. there no new object getting created. It returns ONLY the reference of the object stored in the session ( unless its a primitive type object, i.e. string, interger etc)..
StudentClass is not getting created over & over again in class jsp.. its just getting the reference from session again & again which is trivial in memory uses terms..
However all your tags are connecting to the database and then disconnecting again...
This will lead to a slow performance.. ( in class.jsp the code ends up connecting & disconnecting three times)...
I am not sure how your connectionFactory is implemented but after looking at this code I am fairly certain that there is something fishy going on inside this factory..
Rest of the code looks fairly straightforward & in my opinion is not likely to cause a memory leak anywhere..
oh by the way.. Its one of the worst practice to define methods in a jsp file..(getCalenderDate)!!
>> when you are getting a object from session.. there no new object getting created. It returns ONLY the reference of the object stored in the session
>> its just getting the reference from session again & again
If that code for retrieving the information from the database again if the JSP is hit twice, it is effectively getting it again from the DB and not from the session - depends on whether the application uses this caching from the session or not. atwoodj?
>> which is trivial in memory uses terms..
If many users are logged on and this approach is being followed for many pages, then all session objects will grow with unrequired data....
>> its just getting the reference from session again & again
If that code for retrieving the information from the database again if the JSP is hit twice, it is effectively getting it again from the DB and not from the session - depends on whether the application uses this caching from the session or not. atwoodj?
>> which is trivial in memory uses terms..
If many users are logged on and this approach is being followed for many pages, then all session objects will grow with unrequired data....
>>If that code for retrieving the information from the database again if the JSP is hit twice, it is effectively getting it again from the DB and not from the session - depends on whether the application uses this caching from the session or not. atwoodj?
the studentClass is getting created once in Login procedure and then stored in the session...
If the control is not going back to the login servlet then there is no database access thats happening for student bean..
Yes there are database access on the tags which will slow down the system and I agree with you on that point.. as far as the studentbean is concern..
Given that the control does not return to the login procedure.. its not getting the values from the database again.
the studentClass is getting created once in Login procedure and then stored in the session...
If the control is not going back to the login servlet then there is no database access thats happening for student bean..
Yes there are database access on the tags which will slow down the system and I agree with you on that point.. as far as the studentbean is concern..
Given that the control does not return to the login procedure.. its not getting the values from the database again.
>> the studentClass is getting created once in Login procedure and then stored in the session...
If all of the student bean's data is required throughout the rest of the application and is being correctly accessed from the session, its fine. My comment was a general, more towards whether this is being followed for retrieving request-specific data through out the application or not.
If all of the student bean's data is required throughout the rest of the application and is being correctly accessed from the session, its fine. My comment was a general, more towards whether this is being followed for retrieving request-specific data through out the application or not.
ASKER
I will paste the code for connectionFactory below.
@Kuldeepchaturvedi.
You note that there are three connections to the DB being made for each time class.jsp loads. What would be a more efficient way of requesting this information?
@both.
Is it still better to use request.setAttribute than session.setAttribute?
Here's the connectionFactory code:
package vss.ConnectionFactory;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class ConnectionFactory {
static String drivers = "com.microsoft.jdbc.sqlser ver.SQLSer verDriver" ;
static String connString =
"jdbc:microsoft:sqlserver: //localhos t:1433;Use r=XX;Passw ord=XX;Dat abaseName= vss";
static String user_name = "XX";
static String password = "XX";
public static void setConnection(String drivers, String connString,
String user_name, String password) throws
Exception {
Connection conn = null;
try {
Class.forName(drivers);
conn = DriverManager.getConnectio n(connStri ng, user_name, password);
ConnectionFactory.drivers = drivers;
ConnectionFactory.connStri ng = connString;
ConnectionFactory.user_nam e = user_name;
ConnectionFactory.password = password;
}
catch (Exception e) {
throw new Exception();
}
finally {
if (conn != null) {
try {
conn.close();
}
catch (Exception e) {}
}
}
}
public static Connection getConn() {
try {
Class.forName(drivers);
Connection conn = DriverManager.getConnectio n(connStri ng, user_name,
password);
return conn;
}
catch (Exception e) {
System.err.println(
"Database Error: Call admin to set database information");
}
return null;
}
public static void closeConn(Connection conn) {
try {
conn.close();
}
catch (Exception e) {
System.err.println("Databa se Error: Cann't stop database connection");
}
}
public static void main(String[] args) throws Exception {
String id = "4";
Class.forName("com.mysql.j dbc.Driver ");
Connection conn = DriverManager.getConnectio n("jdbc:my sql:///vss ", "XX", "XX");
PreparedStatement pstmt = conn.prepareStatement(
"insert into prices(class_id, student_id, date, price) values(?, ?, ?, ?)");
pstmt.setInt(1, 1);
pstmt.setInt(2, 1);
pstmt.setDate(3, new java.sql.Date(new java.util.Date().getTime() ));
pstmt.setDouble(4, 1.01);
pstmt.executeUpdate();
}
}
@Kuldeepchaturvedi.
You note that there are three connections to the DB being made for each time class.jsp loads. What would be a more efficient way of requesting this information?
@both.
Is it still better to use request.setAttribute than session.setAttribute?
Here's the connectionFactory code:
package vss.ConnectionFactory;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class ConnectionFactory {
static String drivers = "com.microsoft.jdbc.sqlser
static String connString =
"jdbc:microsoft:sqlserver:
static String user_name = "XX";
static String password = "XX";
public static void setConnection(String drivers, String connString,
String user_name, String password) throws
Exception {
Connection conn = null;
try {
Class.forName(drivers);
conn = DriverManager.getConnectio
ConnectionFactory.drivers = drivers;
ConnectionFactory.connStri
ConnectionFactory.user_nam
ConnectionFactory.password
}
catch (Exception e) {
throw new Exception();
}
finally {
if (conn != null) {
try {
conn.close();
}
catch (Exception e) {}
}
}
}
public static Connection getConn() {
try {
Class.forName(drivers);
Connection conn = DriverManager.getConnectio
password);
return conn;
}
catch (Exception e) {
System.err.println(
"Database Error: Call admin to set database information");
}
return null;
}
public static void closeConn(Connection conn) {
try {
conn.close();
}
catch (Exception e) {
System.err.println("Databa
}
}
public static void main(String[] args) throws Exception {
String id = "4";
Class.forName("com.mysql.j
Connection conn = DriverManager.getConnectio
PreparedStatement pstmt = conn.prepareStatement(
"insert into prices(class_id, student_id, date, price) values(?, ?, ?, ?)");
pstmt.setInt(1, 1);
pstmt.setInt(2, 1);
pstmt.setDate(3, new java.sql.Date(new java.util.Date().getTime()
pstmt.setDouble(4, 1.01);
pstmt.executeUpdate();
}
}
>> Is it still better to use request.setAttribute than session.setAttribute?
If the data has to be accessed across multiple pages - use session, and then retrieve it from the session using getAttribute () otherwise store it in the request (if it is per page data)
If the data has to be accessed across multiple pages - use session, and then retrieve it from the session using getAttribute () otherwise store it in the request (if it is per page data)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BTW why is the connection opened in 3 methods - setConnection (), getConn () as well as main () ? And why is there a main () in a JSP application ;-)
>>why is there a main () in a JSP application ;-)
most probably the developer was testing the bean and went lazy in deleting it...:-)
most probably the developer was testing the bean and went lazy in deleting it...:-)
ASKER
@mayan
Thanks for that. I will review our java code to ensure we are using the appropriate coding.
@kuldeep
I'm not sure how to use connection pooling. Can you point me in the right direction?
@mayan again...
I'm not sure why 3 different methods are being used. I didn't code this. We had two guys working on this before I was brought onboard. I think this was a learning experience for them. They are no longer with us and I'm trying to sort this out.
...I don't see where you are referring to a "main ()"? Please help. What can be safely removed?
Thanks for that. I will review our java code to ensure we are using the appropriate coding.
@kuldeep
I'm not sure how to use connection pooling. Can you point me in the right direction?
@mayan again...
I'm not sure why 3 different methods are being used. I didn't code this. We had two guys working on this before I was brought onboard. I think this was a learning experience for them. They are no longer with us and I'm trying to sort this out.
...I don't see where you are referring to a "main ()"? Please help. What can be safely removed?
Thought so, it looks more like a test for the DB connection but it doesn't even test the ConnectionFactory properly if it opens the connection on its own instead of using getConn () etc ;-)
>> What can be safely removed?
I think you can comment out and later remove the main (). Is your application calling getConn () or the other method?
I think you can comment out and later remove the main (). Is your application calling getConn () or the other method?
>>I don't see where you are referring to a "main ()"? Please help. What can be safely removed?
both main and setconnection can safely removed. System is not using them..
As far as connection pooling goes... refer to the link below..
http://www.onjava.com/pub/a/onjava/2006/04/19/database-connection-pooling-with-tomcat.html
if you still have questions then let me know..
I suggest that you leave your connectionPool class and the getConnection method in place..
just change how the connection is obtained.
It will save a lot of trouble of changing code everywhere in the system..
both main and setconnection can safely removed. System is not using them..
As far as connection pooling goes... refer to the link below..
http://www.onjava.com/pub/a/onjava/2006/04/19/database-connection-pooling-with-tomcat.html
if you still have questions then let me know..
I suggest that you leave your connectionPool class and the getConnection method in place..
just change how the connection is obtained.
It will save a lot of trouble of changing code everywhere in the system..
>> catch (Exception e) {
>> throw new Exception();
>> }
To preserve the stack trace details and original exception information, you might wanna make it:
catch (Exception e) {
throw e ;
}
or just remove it altogether and let the try block remain with only a finally.
>> throw new Exception();
>> }
To preserve the stack trace details and original exception information, you might wanna make it:
catch (Exception e) {
throw e ;
}
or just remove it altogether and let the try block remain with only a finally.
One more thing.. the link that I provided does go a little elaborate in defining the DBListener etc.. you really do not need all of it...
just plain Database pool with a JNDI naming...
here is a little simpler version of the same thing
http://www.crazysquirrel.com/computing/java/connection-pooling.jspx
just plain Database pool with a JNDI naming...
here is a little simpler version of the same thing
http://www.crazysquirrel.com/computing/java/connection-pooling.jspx
ASKER
Thanks to both of you for the information. It's been helpful. I need to digest it a bit and have a chat with my programmer. I'll be back in touch shortly.
Sure
ASKER
Hey...we've done some work but a slight problem I just wanted to ask about.
In our server.xml file we have the code pasted below. My programmer did this but I was wondering what username and password should be included here. Should it be a MySQL user that we've used in the old ConnectionFactory file?
We are getting closer to an answer. Thanks for your help and patience.
<Host name="studentstockmarket.c om" appBase="/home2/dluebbe/pu blic_html" >
<Alias>www.studentstockmarket.com</Alias>
<Alias>simceo.org</Alias>
<Alias>www.simceo.org</Alias>
<Context path="" reloadable="true" docBase="/home2/dluebbe/pu blic_html" debug="1">
<Resource name="jdbc/simceo" auth="Container" type="javax.sql.DataSource "
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="" driverClassName="com.mysql .jdbc.Driv er"
url="jdbc:mysql:///vss?aut oReconnect =true"/>
</Context>
<Context path="/manager" reloadable="true" docBase="/usr/local/jakart a-dluebbe/ tomcat/ser ver/webapp s/manager" privileged="true" antiResourceLocking="false " antiJARLocking="false"/>
</Host>
In our server.xml file we have the code pasted below. My programmer did this but I was wondering what username and password should be included here. Should it be a MySQL user that we've used in the old ConnectionFactory file?
We are getting closer to an answer. Thanks for your help and patience.
<Host name="studentstockmarket.c
<Alias>www.studentstockmarket.com</Alias>
<Alias>simceo.org</Alias>
<Alias>www.simceo.org</Alias>
<Context path="" reloadable="true" docBase="/home2/dluebbe/pu
<Resource name="jdbc/simceo" auth="Container" type="javax.sql.DataSource
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="" driverClassName="com.mysql
url="jdbc:mysql:///vss?aut
</Context>
<Context path="/manager" reloadable="true" docBase="/usr/local/jakart
</Host>
ASKER
PS. Our catalina.out logged the following:
Database Error: Call admin to set database information
Database Error: Cann't stop database connection
[Loaded clime.messadmin.model.Erro rData from file:/home2/dluebbe/public _html/WEB- INF/lib/Me ssAdmin-Co re-4.0.jar ]
Mar 26, 2007 10:29:41 PM org.apache.catalina.core.S tandardWra pperValve invoke
SEVERE: Servlet.service() for servlet StudentLoginB threw exception
java.lang.NullPointerExcep tion
at vss.StudentLoginB.doGet(St udentLogin B.java:31)
at vss.StudentLoginB.doPost(S tudentLogi nB.java:13 2)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 709)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:252 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at clime.messadmin.filter.Mes sAdminFilt er.doFilte r(MessAdmi nFilter.ja va:104)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:202 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at org.apache.catalina.core.S tandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:214)
at org.apache.catalina.core.S tandardCon textValve. invoke(Sta ndardConte xtValve.ja va:178)
at org.apache.catalina.core.S tandardHos tValve.inv oke(Standa rdHostValv e.java:126 )
at org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:105 )
at org.apache.catalina.core.S tandardEng ineValve.i nvoke(Stan dardEngine Valve.java :107)
at org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:148)
at org.apache.jk.server.JkCoy oteHandler .invoke(Jk CoyoteHand ler.java:3 06)
at org.apache.jk.common.Handl erRequest. invoke(Han dlerReques t.java:385 )
at org.apache.jk.common.Chann elSocket.i nvoke(Chan nelSocket. java:745)
at org.apache.jk.common.Chann elSocket.p rocessConn ection(Cha nnelSocket .java:675)
at org.apache.jk.common.Socke tConnectio n.runIt(Ch annelSocke t.java:868 )
at org.apache.tomcat.util.thr eads.Threa dPool$Cont rolRunnabl e.run(Thre adPool.jav a:684)
at java.lang.Thread.run(Threa d.java:595 )
Database Error: Call admin to set database information
Database Error: Cann't stop database connection
[Loaded clime.messadmin.model.Erro
Mar 26, 2007 10:29:41 PM org.apache.catalina.core.S
SEVERE: Servlet.service() for servlet StudentLoginB threw exception
java.lang.NullPointerExcep
at vss.StudentLoginB.doGet(St
at vss.StudentLoginB.doPost(S
at javax.servlet.http.HttpSer
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at clime.messadmin.filter.Mes
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.jk.server.JkCoy
at org.apache.jk.common.Handl
at org.apache.jk.common.Chann
at org.apache.jk.common.Chann
at org.apache.jk.common.Socke
at org.apache.tomcat.util.thr
at java.lang.Thread.run(Threa
Yes they should be your Database user id & password.
>>Database Error: Call admin to set database information
Database Error: Cann't stop database connection
Have you changed the code in your connection factory to use the connection pool?
Database Error: Cann't stop database connection
Have you changed the code in your connection factory to use the connection pool?
>> My programmer did this but I was wondering what username and password should be included here.
Yes you should put them there so that you can change them without modifying the source code in subsequent runs if the database credentials change. If it is in the connection factory class, then it is hard coded in the source code and will need to be re-compiled everytime it changes.
Yes you should put them there so that you can change them without modifying the source code in subsequent runs if the database credentials change. If it is in the connection factory class, then it is hard coded in the source code and will need to be re-compiled everytime it changes.
ASKER
I think so...here's the new connection factory...is it ok?
package vss.ConnectionFactory;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import javax.sql.DataSource;
import javax.naming.Context;
import javax.naming.InitialContex t;
import javax.naming.NamingExcepti on;
/**
*
* <p>Title: ConnectionFactory</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author zhaofeng
* @version 1.1
*/
public class ConnectionFactory {
private static DataSource ds=null;
static{
Context ctx;
try {
ctx = new InitialContext();
ds = (DataSource)ctx.lookup("ja va:comp/en v/jdbc/sim ceo");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Connection getConn(){
try {
if(ds==null)
throw new Exception("datasource is null");
return ds.getConnection();
} catch (Exception e) {
System.err.println(
"Database Error: Call admin to set database information");
}
return null;
}
public static void closeConn(Connection conn) {
try {
conn.close();
} catch (Exception e) {
System.err.println("Databa se Error: Cann't stop database connection");
}
}
}
package vss.ConnectionFactory;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import javax.sql.DataSource;
import javax.naming.Context;
import javax.naming.InitialContex
import javax.naming.NamingExcepti
/**
*
* <p>Title: ConnectionFactory</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author zhaofeng
* @version 1.1
*/
public class ConnectionFactory {
private static DataSource ds=null;
static{
Context ctx;
try {
ctx = new InitialContext();
ds = (DataSource)ctx.lookup("ja
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Connection getConn(){
try {
if(ds==null)
throw new Exception("datasource is null");
return ds.getConnection();
} catch (Exception e) {
System.err.println(
"Database Error: Call admin to set database information");
}
return null;
}
public static void closeConn(Connection conn) {
try {
conn.close();
} catch (Exception e) {
System.err.println("Databa
}
}
}
>> My programmer did this but I was wondering what username and password should be included here.
Yes you should put them there so that you can change them without modifying the source code in subsequent runs if the database credentials change. If it is in the connection factory class, then it is hard coded in the source code and will need to be re-compiled everytime it changes.
Yes you should put them there so that you can change them without modifying the source code in subsequent runs if the database credentials change. If it is in the connection factory class, then it is hard coded in the source code and will need to be re-compiled everytime it changes.
Try printing the stack trace of the actual exception in the catch block so that you know what caused it.
catch ( Exception e )
{
e.printStackTrace () ;
}
Sorry about the double post last time.
catch ( Exception e )
{
e.printStackTrace () ;
}
Sorry about the double post last time.
ASKER
Ok...thanks. I've changed the username and password and I'll have the programmer fix the catch block.
My programmer asked me to put mysql_jdbc.jar in the \tomcat\common\lib directory. We currently have it in our WEB-INF\lib directory. Do I need to move it and delete it from the WEB-INF directory, or leave it in both places?
My programmer asked me to put mysql_jdbc.jar in the \tomcat\common\lib directory. We currently have it in our WEB-INF\lib directory. Do I need to move it and delete it from the WEB-INF directory, or leave it in both places?
Looks like this method is blowing up..
public static Connection getConn(){
try {
if(ds==null)
throw new Exception("datasource is null");
return ds.getConnection();
} catch (Exception e) {
System.err.println(
"Database Error: Call admin to set database information");
}
return null;
}
change it to ..
public static Connection getConn(){
try {
if(ds==null)
throw new Exception("datasource is null");
return (Connection)ds.getConnecti on();
} catch (Exception e) {
System.err.println(
"Database Error: Call admin to set database information");
e.printStackTrace();
}
return null;
}
Mostprobaly it will still bomb.. but we will know why..:-)
public static Connection getConn(){
try {
if(ds==null)
throw new Exception("datasource is null");
return ds.getConnection();
} catch (Exception e) {
System.err.println(
"Database Error: Call admin to set database information");
}
return null;
}
change it to ..
public static Connection getConn(){
try {
if(ds==null)
throw new Exception("datasource is null");
return (Connection)ds.getConnecti
} catch (Exception e) {
System.err.println(
"Database Error: Call admin to set database information");
e.printStackTrace();
}
return null;
}
Mostprobaly it will still bomb.. but we will know why..:-)
>>
My programmer asked me to put mysql_jdbc.jar in the \tomcat\common\lib directory. We currently have it in our WEB-INF\lib directory. Do I need to move it and delete it from the WEB-INF directory, or leave it in both places?
put it in Tomcat's lib directory...
after you place it there. then you need to stop and start tomcat.. & also you can delete it from web-inf/lib
My programmer asked me to put mysql_jdbc.jar in the \tomcat\common\lib directory. We currently have it in our WEB-INF\lib directory. Do I need to move it and delete it from the WEB-INF directory, or leave it in both places?
put it in Tomcat's lib directory...
after you place it there. then you need to stop and start tomcat.. & also you can delete it from web-inf/lib
If it is in common\lib, all web apps can use it. If it is in WEB-INF\lib, only that project/ web app can use it.
ASKER
I made the changes to the password and username, reuploaded everything and stop/start the server. Still no luck. I wasn't able to make the changes to the catch block yet. We've just had a group of students start playing the simulation so I can't make any changes for a couple of hours. Until then can I review the connection pool code with you and the steps I followed?
1. I stopped tomcat.
2. I uploaded mysql_jdbc.jar to the /tomcat/common/lib/ directory
3. I deleted mysql_jdbc.jar from the WEB-INF/lib/ directory.
4. I replaced the server.xml file in the /conf/ directory
5. I replaced the web.xml file in the WEB-INF directory
6. I replaced ConnectionFactory.class in the ConnectionFactory directory
7. I restarted the server.
Is this the proper protocol?
I've already posted the new ConnectionFactory.java code and will make the catch block changes.
Our server.xml file was changed to have the proper username and password.
In our web.xml file the following code was added:
<resource-ref>
<description>
Resource reference to a factory for java.sql.Connection
instances that may be used for talking to a particular
database that is configured in the server.xml file.
</description>
<res-ref-name>
jdbc/simceo
</res-ref-name>
<res-type>
javax.sql.DataSource
</res-type>
<res-auth>
Container
</res-auth>
</resource-ref>
However, I notice we still have this block of code in the web.xml file. Is it necessary?
<context-param>
<param-name>ConnectString< /param-nam e>
<param-value>jdbc:microsof t:sqlserve r://localh ost:1433;U ser=XX;Pas sword=XX;D atabaseNam e=vss</par am-value>
</context-param>
Suggestions?
Thanks so much!
1. I stopped tomcat.
2. I uploaded mysql_jdbc.jar to the /tomcat/common/lib/ directory
3. I deleted mysql_jdbc.jar from the WEB-INF/lib/ directory.
4. I replaced the server.xml file in the /conf/ directory
5. I replaced the web.xml file in the WEB-INF directory
6. I replaced ConnectionFactory.class in the ConnectionFactory directory
7. I restarted the server.
Is this the proper protocol?
I've already posted the new ConnectionFactory.java code and will make the catch block changes.
Our server.xml file was changed to have the proper username and password.
In our web.xml file the following code was added:
<resource-ref>
<description>
Resource reference to a factory for java.sql.Connection
instances that may be used for talking to a particular
database that is configured in the server.xml file.
</description>
<res-ref-name>
jdbc/simceo
</res-ref-name>
<res-type>
javax.sql.DataSource
</res-type>
<res-auth>
Container
</res-auth>
</resource-ref>
However, I notice we still have this block of code in the web.xml file. Is it necessary?
<context-param>
<param-name>ConnectString<
<param-value>jdbc:microsof
</context-param>
Suggestions?
Thanks so much!
yes these are the correct steps..
If you are using tomcat 5 or above then you can make your context files as separate xml files instead of sticking them in the web.xml which is lot more cleaner way of doing it.
If you are using tomcat 5 or above then you can make your context files as separate xml files instead of sticking them in the web.xml which is lot more cleaner way of doing it.
ASKER
Ok. we changed the catch block and here's the output. What does it mean?! I see that there was a problem using 'root' as the username and no password. I changed the username and pwd to what we used to use in our connectionfactory. Same error. Ideas?
++++++
org.apache.tomcat.dbcp.dbc p.SQLNeste dException : Cannot create PoolableConnectionFactory (Server connection failure during transaction. Due to underlying exception: 'java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)'.
** BEGIN NESTED EXCEPTION **
java.sql.SQLException
MESSAGE: Access denied for user 'root'@'localhost' (using password: NO)
STACKTRACE:
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
at com.mysql.jdbc.MysqlIO.che ckErrorPac ket(MysqlI O.java:292 1)
at com.mysql.jdbc.MysqlIO.che ckErrorPac ket(MysqlI O.java:770 )
at com.mysql.jdbc.MysqlIO.sec ureAuth411 (MysqlIO.j ava:3641)
at com.mysql.jdbc.MysqlIO.doH andshake(M ysqlIO.jav a:1175)
at com.mysql.jdbc.Connection. createNewI O(Connecti on.java:26 69)
at com.mysql.jdbc.Connection. <init>(Con nection.ja va:1474)
at com.mysql.jdbc.NonRegister ingDriver. connect(No nRegisteri ngDriver.j ava:264)
at org.apache.tomcat.dbcp.dbc p.DriverCo nnectionFa ctory.crea teConnecti on(DriverC onnectionF actory.jav a:37)
at org.apache.tomcat.dbcp.dbc p.Poolable Connection Factory.ma keObject(P oolableCon nectionFac tory.java: 290)
at org.apache.tomcat.dbcp.dbc p.BasicDat aSource.va lidateConn ectionFact ory(BasicD ataSource. java:877)
at org.apache.tomcat.dbcp.dbc p.BasicDat aSource.cr eateDataSo urce(Basic DataSource .java:851)
at org.apache.tomcat.dbcp.dbc p.BasicDat aSource.ge tConnectio n(BasicDat aSource.ja va:540)
at vss.ConnectionFactory.Conn ectionFact ory.getCon n(Connecti onFactory. java:41)
at vss.StudentLoginB.doGet(St udentLogin B.java:27)
at vss.StudentLoginB.doPost(S tudentLogi nB.java:13 2)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 709)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:252 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at clime.messadmin.filter.Mes sAdminFilt er.doFilte r(MessAdmi nFilter.ja va:104)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:202 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at org.apache.catalina.core.S tandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:214)
at org.apache.catalina.core.S tandardCon textValve. invoke(Sta ndardConte xtValve.ja va:178)
at org.apache.catalina.core.S tandardHos tValve.inv oke(Standa rdHostValv e.java:126 )
at org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:105 )
at org.apache.catalina.core.S tandardEng ineValve.i nvoke(Stan dardEngine Valve.java :107)
at org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:148)
at org.apache.jk.server.JkCoy oteHandler .invoke(Jk CoyoteHand ler.java:3 06)
at org.apache.jk.common.Handl erRequest. invoke(Han dlerReques t.java:385 )
at org.apache.jk.common.Chann elSocket.i nvoke(Chan nelSocket. java:745)
at org.apache.jk.common.Chann elSocket.p rocessConn ection(Cha nnelSocket .java:675)
at org.apache.jk.common.Socke tConnectio n.runIt(Ch annelSocke t.java:868 )
at org.apache.tomcat.util.thr eads.Threa dPool$Cont rolRunnabl e.run(Thre adPool.jav a:684)
at java.lang.Thread.run(Threa d.java:595 )
** END NESTED EXCEPTION **
Attempted reconnect 3 times. Giving up.)
at org.apache.tomcat.dbcp.dbc p.BasicDat aSource.cr eateDataSo urce(Basic DataSource .java:855)
at org.apache.tomcat.dbcp.dbc p.BasicDat aSource.ge tConnectio n(BasicDat aSource.ja va:540)
at vss.ConnectionFactory.Conn ectionFact ory.getCon n(Connecti onFactory. java:41)
at vss.StudentLoginB.doGet(St udentLogin B.java:27)
at vss.StudentLoginB.doPost(S tudentLogi nB.java:13 2)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 709)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:252 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at clime.messadmin.filter.Mes sAdminFilt er.doFilte r(MessAdmi nFilter.ja va:104)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:202 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at org.apache.catalina.core.S tandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:214)
at org.apache.catalina.core.S tandardCon textValve. invoke(Sta ndardConte xtValve.ja va:178)
at org.apache.catalina.core.S tandardHos tValve.inv oke(Standa rdHostValv e.java:126 )
at org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:105 )
at org.apache.catalina.core.S tandardEng ineValve.i nvoke(Stan dardEngine Valve.java :107)
at org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:148)
at org.apache.jk.server.JkCoy oteHandler .invoke(Jk CoyoteHand ler.java:3 06)
at org.apache.jk.common.Handl erRequest. invoke(Han dlerReques t.java:385 )
at org.apache.jk.common.Chann elSocket.i nvoke(Chan nelSocket. java:745)
at org.apache.jk.common.Chann elSocket.p rocessConn ection(Cha nnelSocket .java:675)
at org.apache.jk.common.Socke tConnectio n.runIt(Ch annelSocke t.java:868 )
at org.apache.tomcat.util.thr eads.Threa dPool$Cont rolRunnabl e.run(Thre adPool.jav a:684)
at java.lang.Thread.run(Threa d.java:595 )
Caused by: java.sql.SQLException: Server connection failure during transaction. Due to underlying exception: 'java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)'.
** BEGIN NESTED EXCEPTION **
java.sql.SQLException
MESSAGE: Access denied for user 'root'@'localhost' (using password: NO)
STACKTRACE:
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
at com.mysql.jdbc.MysqlIO.che ckErrorPac ket(MysqlI O.java:292 1)
at com.mysql.jdbc.MysqlIO.che ckErrorPac ket(MysqlI O.java:770 )
at com.mysql.jdbc.MysqlIO.sec ureAuth411 (MysqlIO.j ava:3641)
at com.mysql.jdbc.MysqlIO.doH andshake(M ysqlIO.jav a:1175)
at com.mysql.jdbc.Connection. createNewI O(Connecti on.java:26 69)
at com.mysql.jdbc.Connection. <init>(Con nection.ja va:1474)
at com.mysql.jdbc.NonRegister ingDriver. connect(No nRegisteri ngDriver.j ava:264)
at org.apache.tomcat.dbcp.dbc p.DriverCo nnectionFa ctory.crea teConnecti on(DriverC onnectionF actory.jav a:37)
at org.apache.tomcat.dbcp.dbc p.Poolable Connection Factory.ma keObject(P oolableCon nectionFac tory.java: 290)
at org.apache.tomcat.dbcp.dbc p.BasicDat aSource.va lidateConn ectionFact ory(BasicD ataSource. java:877)
at org.apache.tomcat.dbcp.dbc p.BasicDat aSource.cr eateDataSo urce(Basic DataSource .java:851)
at org.apache.tomcat.dbcp.dbc p.BasicDat aSource.ge tConnectio n(BasicDat aSource.ja va:540)
at vss.ConnectionFactory.Conn ectionFact ory.getCon n(Connecti onFactory. java:41)
at vss.StudentLoginB.doGet(St udentLogin B.java:27)
at vss.StudentLoginB.doPost(S tudentLogi nB.java:13 2)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 709)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:252 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at clime.messadmin.filter.Mes sAdminFilt er.doFilte r(MessAdmi nFilter.ja va:104)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:202 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at org.apache.catalina.core.S tandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:214)
at org.apache.catalina.core.S tandardCon textValve. invoke(Sta ndardConte xtValve.ja va:178)
at org.apache.catalina.core.S tandardHos tValve.inv oke(Standa rdHostValv e.java:126 )
at org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:105 )
at org.apache.catalina.core.S tandardEng ineValve.i nvoke(Stan dardEngine Valve.java :107)
at org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:148)
at org.apache.jk.server.JkCoy oteHandler .invoke(Jk CoyoteHand ler.java:3 06)
at org.apache.jk.common.Handl erRequest. invoke(Han dlerReques t.java:385 )
at org.apache.jk.common.Chann elSocket.i nvoke(Chan nelSocket. java:745)
at org.apache.jk.common.Chann elSocket.p rocessConn ection(Cha nnelSocket .java:675)
at org.apache.jk.common.Socke tConnectio n.runIt(Ch annelSocke t.java:868 )
at org.apache.tomcat.util.thr eads.Threa dPool$Cont rolRunnabl e.run(Thre adPool.jav a:684)
at java.lang.Thread.run(Threa d.java:595 )
** END NESTED EXCEPTION **
Attempted reconnect 3 times. Giving up.
at com.mysql.jdbc.Connection. createNewI O(Connecti on.java:27 34)
at com.mysql.jdbc.Connection. <init>(Con nection.ja va:1474)
at com.mysql.jdbc.NonRegister ingDriver. connect(No nRegisteri ngDriver.j ava:264)
at org.apache.tomcat.dbcp.dbc p.DriverCo nnectionFa ctory.crea teConnecti on(DriverC onnectionF actory.jav a:37)
at org.apache.tomcat.dbcp.dbc p.Poolable Connection Factory.ma keObject(P oolableCon nectionFac tory.java: 290)
at org.apache.tomcat.dbcp.dbc p.BasicDat aSource.va lidateConn ectionFact ory(BasicD ataSource. java:877)
at org.apache.tomcat.dbcp.dbc p.BasicDat aSource.cr eateDataSo urce(Basic DataSource .java:851)
... 24 more
Database Error: Call admin to set database information
java.lang.NullPointerExcep tion
at vss.ConnectionFactory.Conn ectionFact ory.closeC onn(Connec tionFactor y.java:52)
at vss.StudentLoginB.doGet(St udentLogin B.java:125 )
at vss.StudentLoginB.doPost(S tudentLogi nB.java:13 2)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 709)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:252 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at clime.messadmin.filter.Mes sAdminFilt er.doFilte r(MessAdmi nFilter.ja va:104)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:202 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at org.apache.catalina.core.S tandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:214)
at org.apache.catalina.core.S tandardCon textValve. invoke(Sta ndardConte xtValve.ja va:178)
at org.apache.catalina.core.S tandardHos tValve.inv oke(Standa rdHostValv e.java:126 )
at org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:105 )
at org.apache.catalina.core.S tandardEng ineValve.i nvoke(Stan dardEngine Valve.java :107)
at org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:148)
at org.apache.jk.server.JkCoy oteHandler .invoke(Jk CoyoteHand ler.java:3 06)
at org.apache.jk.common.Handl erRequest. invoke(Han dlerReques t.java:385 )
at org.apache.jk.common.Chann elSocket.i nvoke(Chan nelSocket. java:745)
at org.apache.jk.common.Chann elSocket.p rocessConn ection(Cha nnelSocket .java:675)
at org.apache.jk.common.Socke tConnectio n.runIt(Ch annelSocke t.java:868 )
at org.apache.tomcat.util.thr eads.Threa dPool$Cont rolRunnabl e.run(Thre adPool.jav a:684)
at java.lang.Thread.run(Threa d.java:595 )
Database Error: Cann't stop database connection
[Loaded clime.messadmin.model.Erro rData from file:/home2/dluebbe/public _html/WEB- INF/lib/Me ssAdmin-Co re-4.0.jar ]
Mar 27, 2007 10:21:16 AM org.apache.catalina.core.S tandardWra pperValve invoke
SEVERE: Servlet.service() for servlet StudentLoginB threw exception
java.lang.NullPointerExcep tion
at vss.StudentLoginB.doGet(St udentLogin B.java:31)
at vss.StudentLoginB.doPost(S tudentLogi nB.java:13 2)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 709)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 802)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:252 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at clime.messadmin.filter.Mes sAdminFilt er.doFilte r(MessAdmi nFilter.ja va:104)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:202 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 73)
at org.apache.catalina.core.S tandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:214)
at org.apache.catalina.core.S tandardCon textValve. invoke(Sta ndardConte xtValve.ja va:178)
at org.apache.catalina.core.S tandardHos tValve.inv oke(Standa rdHostValv e.java:126 )
at org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:105 )
at org.apache.catalina.core.S tandardEng ineValve.i nvoke(Stan dardEngine Valve.java :107)
at org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:148)
at org.apache.jk.server.JkCoy oteHandler .invoke(Jk CoyoteHand ler.java:3 06)
at org.apache.jk.common.Handl erRequest. invoke(Han dlerReques t.java:385 )
at org.apache.jk.common.Chann elSocket.i nvoke(Chan nelSocket. java:745)
at org.apache.jk.common.Chann elSocket.p rocessConn ection(Cha nnelSocket .java:675)
at org.apache.jk.common.Socke tConnectio n.runIt(Ch annelSocke t.java:868 )
at org.apache.tomcat.util.thr eads.Threa dPool$Cont rolRunnabl e.run(Thre adPool.jav a:684)
at java.lang.Thread.run(Threa d.java:595 )
++++++
org.apache.tomcat.dbcp.dbc
** BEGIN NESTED EXCEPTION **
java.sql.SQLException
MESSAGE: Access denied for user 'root'@'localhost' (using password: NO)
STACKTRACE:
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
at com.mysql.jdbc.MysqlIO.che
at com.mysql.jdbc.MysqlIO.che
at com.mysql.jdbc.MysqlIO.sec
at com.mysql.jdbc.MysqlIO.doH
at com.mysql.jdbc.Connection.
at com.mysql.jdbc.Connection.
at com.mysql.jdbc.NonRegister
at org.apache.tomcat.dbcp.dbc
at org.apache.tomcat.dbcp.dbc
at org.apache.tomcat.dbcp.dbc
at org.apache.tomcat.dbcp.dbc
at org.apache.tomcat.dbcp.dbc
at vss.ConnectionFactory.Conn
at vss.StudentLoginB.doGet(St
at vss.StudentLoginB.doPost(S
at javax.servlet.http.HttpSer
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at clime.messadmin.filter.Mes
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.jk.server.JkCoy
at org.apache.jk.common.Handl
at org.apache.jk.common.Chann
at org.apache.jk.common.Chann
at org.apache.jk.common.Socke
at org.apache.tomcat.util.thr
at java.lang.Thread.run(Threa
** END NESTED EXCEPTION **
Attempted reconnect 3 times. Giving up.)
at org.apache.tomcat.dbcp.dbc
at org.apache.tomcat.dbcp.dbc
at vss.ConnectionFactory.Conn
at vss.StudentLoginB.doGet(St
at vss.StudentLoginB.doPost(S
at javax.servlet.http.HttpSer
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at clime.messadmin.filter.Mes
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.jk.server.JkCoy
at org.apache.jk.common.Handl
at org.apache.jk.common.Chann
at org.apache.jk.common.Chann
at org.apache.jk.common.Socke
at org.apache.tomcat.util.thr
at java.lang.Thread.run(Threa
Caused by: java.sql.SQLException: Server connection failure during transaction. Due to underlying exception: 'java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)'.
** BEGIN NESTED EXCEPTION **
java.sql.SQLException
MESSAGE: Access denied for user 'root'@'localhost' (using password: NO)
STACKTRACE:
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO)
at com.mysql.jdbc.MysqlIO.che
at com.mysql.jdbc.MysqlIO.che
at com.mysql.jdbc.MysqlIO.sec
at com.mysql.jdbc.MysqlIO.doH
at com.mysql.jdbc.Connection.
at com.mysql.jdbc.Connection.
at com.mysql.jdbc.NonRegister
at org.apache.tomcat.dbcp.dbc
at org.apache.tomcat.dbcp.dbc
at org.apache.tomcat.dbcp.dbc
at org.apache.tomcat.dbcp.dbc
at org.apache.tomcat.dbcp.dbc
at vss.ConnectionFactory.Conn
at vss.StudentLoginB.doGet(St
at vss.StudentLoginB.doPost(S
at javax.servlet.http.HttpSer
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at clime.messadmin.filter.Mes
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.jk.server.JkCoy
at org.apache.jk.common.Handl
at org.apache.jk.common.Chann
at org.apache.jk.common.Chann
at org.apache.jk.common.Socke
at org.apache.tomcat.util.thr
at java.lang.Thread.run(Threa
** END NESTED EXCEPTION **
Attempted reconnect 3 times. Giving up.
at com.mysql.jdbc.Connection.
at com.mysql.jdbc.Connection.
at com.mysql.jdbc.NonRegister
at org.apache.tomcat.dbcp.dbc
at org.apache.tomcat.dbcp.dbc
at org.apache.tomcat.dbcp.dbc
at org.apache.tomcat.dbcp.dbc
... 24 more
Database Error: Call admin to set database information
java.lang.NullPointerExcep
at vss.ConnectionFactory.Conn
at vss.StudentLoginB.doGet(St
at vss.StudentLoginB.doPost(S
at javax.servlet.http.HttpSer
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at clime.messadmin.filter.Mes
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.jk.server.JkCoy
at org.apache.jk.common.Handl
at org.apache.jk.common.Chann
at org.apache.jk.common.Chann
at org.apache.jk.common.Socke
at org.apache.tomcat.util.thr
at java.lang.Thread.run(Threa
Database Error: Cann't stop database connection
[Loaded clime.messadmin.model.Erro
Mar 27, 2007 10:21:16 AM org.apache.catalina.core.S
SEVERE: Servlet.service() for servlet StudentLoginB threw exception
java.lang.NullPointerExcep
at vss.StudentLoginB.doGet(St
at vss.StudentLoginB.doPost(S
at javax.servlet.http.HttpSer
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at clime.messadmin.filter.Mes
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.jk.server.JkCoy
at org.apache.jk.common.Handl
at org.apache.jk.common.Chann
at org.apache.jk.common.Chann
at org.apache.jk.common.Socke
at org.apache.tomcat.util.thr
at java.lang.Thread.run(Threa
have you started the server after changing the user id & pwd?
so I assume everything is good now...:-)
ASKER
Kul
It's getting there. We are trying to implement the connection pool, but have had a few difficulties with the programming. I will probably open a new question if the latest solution doesn't work. I felt this question had drifted away from what I originally asked...so it was better to close it and move on to something more focused.
Thanks for all of your help. You may be hearing from me soon.
It's getting there. We are trying to implement the connection pool, but have had a few difficulties with the programming. I will probably open a new question if the latest solution doesn't work. I felt this question had drifted away from what I originally asked...so it was better to close it and move on to something more focused.
Thanks for all of your help. You may be hearing from me soon.
java.lang.OutOfMemoryError
that one means either your application is bleading ( not managing the memory properly ) or your server is little small for the load that its running..
I am inclined towards the first problem..
second exception is rare to be seen.. it happens when a full garbage collection is run & failed on concurrent modes.. ( this means your pages are latching on to the resources and not releasing them).. to me these two looks connected..
I will be able to tell more if you can give us a little more detail about what your application does..