Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Weird problem after a certain period of time

 
David Borchgrevink
Ranch Hand
Posts: 93
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if this is the right forum to be posting this in, but my group (6 students) has a full web app with servlets, jsps, classes, and databases (mySQL). Everything works great (thank god)! But there's a strange problem that occurs:

We have a login and register page for our web app for new and existing users, and after deploying (we're using Tomcat7) everything works great, we can register a new user, login, and use the whole thing. ...But, after an undetermined amount of time the register page won't register new users to the database, and the login page won't login existing users...UNTIL...I undeploy and redeploy from the Tomcat manager page. And then? Everything works great and as intended again.

Does anyone have any ideas what could be causing this? Why would the behavior change if nothing on the server has changed? And why would a fresh deploy immediately fix the problem? Really new to all this, and it's very strange to me so any and all responses are welcomed and appreciated! Thanks in advance!

EDIT: The site is live and here is the address if this will help:

http://23.253.240.14:8080/Search
 
Anuj Sharma R
Greenhorn
Posts: 28
1
Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

Did you check your Tomcat logs?
 
David Borchgrevink
Ranch Hand
Posts: 93
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anuj Sharma R wrote:Hi David,

Did you check your Tomcat logs?


Wow so late tonight, and still I get a response! Why I love this site I haven't checked the Tomcat logs because quite honestly A: I don't know how, and B: I wouldn't know what to look for. Also, now that I've undeployed and redployed, if I were to check these logs, since everything is working, would I even find a problem? Or would I need to wait until it stops working again? Thanks very much for the response!
 
Anuj Sharma R
Greenhorn
Posts: 28
1
Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow so late tonight, and still I get a response!

That is the beauty of being in different time zones - your night is our start of the day :-).

You can see a 'logs' folder typically under your Tomcat deployment folder. There should multiple log files in there. Check for log file with stderr in its name and see if you can find any error/exceptions in there. I don't think you have cleared your logs folder as you were not aware where it was in first place . But in case logs are too big, you should clear those, redeploy the application and then wait for it to happen to decipher the problem from the logs.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agree, start by checking out the log files.

UNTIL...I undeploy and redeploy from the Tomcat manager page

Do you really mean "undeploy"? Or just "Stop" and "Start" (which together is the same as "Reload")? It would be a very unusual problem that requires redeploying.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The log file may also be called "catalina.out". I'm not sure about version 7, I'm still running 6. The most recent entries will be at the bottom of the log.
 
David Borchgrevink
Ranch Hand
Posts: 93
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anuj Sharma R wrote:
Wow so late tonight, and still I get a response!

That is the beauty of being in different time zones - your night is our start of the day :-).

You can see a 'logs' folder typically under your Tomcat deployment folder. There should multiple log files in there. Check for log file with stderr in its name and see if you can find any error/exceptions in there. I don't think you have cleared your logs folder as you were not aware where it was in first place . But in case logs are too big, you should clear those, redeploy the application and then wait for it to happen to decipher the problem from the logs.


Thanks for the response! I'll have to look into that as soon as I have a free minute!

Ulf Dittmer wrote:Agree, start by checking out the log files.

UNTIL...I undeploy and redeploy from the Tomcat manager page

Do you really mean "undeploy"? Or just "Stop" and "Start" (which together is the same as "Reload")? It would be a very unusual problem that requires redeploying.


Yep. I definitely have to undeploy and then redeploy. But like I said, after that, everything is working just as it should be. I agree, really strange.

J. Kevin Robbins wrote:The log file may also be called "catalina.out". I'm not sure about version 7, I'm still running 6. The most recent entries will be at the bottom of the log.


Thanks! I'll definitely be looking for the log files as soon as possible! I'll report back on what I find, if anything. Thanks to all for the suggestions!
 
David Borchgrevink
Ranch Hand
Posts: 93
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay so here's another question: if we have this deployed on someone else's server on their machine at their home, would I be able to go into MY local machine's Tomcat folder and see the same logs? Or would we have to get that person to go through their local machine's logs since it's his Tomcat we're deploying on?

Not sure if how I worded that made any sense. I can clarify if I just confused anyone...

EDIT: I think I just answered my own question. I went into the logs folder on my machine, and the most recent log is from about 2 weeks ago, so I'm assuming the person whose Tomcat we're deployed to will have to go through the logs right? Unless there's a way to access those logs strictly through his Tomcat manager page which I can obviously access...
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You answered correct, those log files are linked to that instance of Tomcat only. You could access them through the Manager app or an app like LambdaProbe if you can get to that server, but it's probably not accessible over the internet if they have it running at home. At least I hope not. That's a security nightmare and probably in violation of their ISP agreement.
 
David Borchgrevink
Ranch Hand
Posts: 93
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J. Kevin Robbins wrote:You answered correct, those log files are linked to that instance of Tomcat only. You could access them through the Manager app or an app like LambdaProbe if you can get to that server, but it's probably not accessible over the internet if they have it running at home. At least I hope not. That's a security nightmare and probably in violation of their ISP agreement.


Also, when this does happen, I open putty which is connected to his server. When I register a new user, what I'm seeing in putty is that the user isn't even being added to the users table in our database. But also, even existing users that are already there in the table can't log in. So strange, but maybe these details will help
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can get to the server with putty, you can view the log files. Just cd to the log file directory and use "less" to view the log file. I'm not sure about the login issues; you definitely have some weirdness going on. I'll withhold any guesses until I see what's in the log file.
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,
Do you close your database connection after
usage or any other resource you had opened
in your servlets or classes?
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, Good point. I'll bet it's exhausting the connection pool. That would explain why existing users can't get logged in either.

David, make sure you have a "finally" block that is closing the connection and the statement.
 
David Borchgrevink
Ranch Hand
Posts: 93
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Ngom wrote:David,
Do you close your database connection after
usage or any other resource you had opened
in your servlets or classes?


J. Kevin Robbins wrote:Paul, Good point. I'll bet it's exhausting the connection pool. That would explain why existing users can't get logged in either.

David, make sure you have a "finally" block that is closing the connection and the statement.


Hey guys, sorry for the delay, I've been tied up with some things for the past week or so, but I'm going to start looking into this again! I'll let you know what I find.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65537
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are not using container-managed connection pooling, you're doing it wrong.
 
David Borchgrevink
Ranch Hand
Posts: 93
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:If you are not using container-managed connection pooling, you're doing it wrong.


Is this something that is handled by Tomcat7 per se? Thanks for the response.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65537
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. The container has a well-debugged and performant connection pooling mechanism. You should be using it.

Connection pooling is like security -- it's really hard to roll your own and get it right.

I'm not sure of the details for setting it up for Tomcat7 (my clients are still on 6), so poke around and you are sure to fund instructions.
 
David Borchgrevink
Ranch Hand
Posts: 93
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Yes. The container has a well-debugged and performant connection pooling mechanism. You should be using it.

Connection pooling is like security -- it's really hard to roll your own and get it right.

I'm not sure of the details for setting it up for Tomcat7 (my clients are still on 6), so poke around and you are sure to fund instructions.


Thanks for the heads up sir. My classmate handled mostly everything regarding the database, but I'll see what I can find with some google searches.
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David, make sure you have a "finally" block that is closing the connection and the statement.

In case you are using Java 7, you can take advantage of try -with-resources block which can handle task of closing DB connection and statements.

Have you used simple JDBC API for DB connections OR any ORM framework ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65537
108
IntelliJ IDE Java jQuery Mac Mac OS X
 
Space pants. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!