Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to stop memory leak problem and Tomcat or Eclipse is not doing the debugging?  RSS feed

 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi experts,

First, I would like to inform that I have more than a memory leak problem as Tomcat or is it Eclipse is not debugging at all.

Here's my log message in which I do not understand why I am getting a 404 and what does 1074 means?


127.0.0.1 - - [22/Jan/2018:13:33:10 +0800] "GET / HTTP/1.1" 404 1074
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/tutorRegister.jsp HTTP/1.1" 200 13656
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/BootStrap/Checkbox.js HTTP/1.1" 404 1108
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/BootStrap/bootstrap-multiselect.js HTTP/1.1" 404 1121
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/js/bootstrap.min.js HTTP/1.1" 404 1106
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/js/jquery.js HTTP/1.1" 404 1099
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/js/jqBootstrapValidation.js HTTP/1.1" 404 1114
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/js/contact_me.js HTTP/1.1" 404 1103
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/Image/aa1.png HTTP/1.1" 404 1100
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:34:33 +0800] "POST /Hi5S/addTutor HTTP/1.1" 200 -
127.0.0.1 - - [22/Jan/2018:13:35:29 +0800] "GET / HTTP/1.1" 404 1074
127.0.0.1 - - [22/Jan/2018:13:35:54 +0800] "GET / HTTP/1.1" 404 1074
127.0.0.1 - - [22/Jan/2018:13:36:16 +0800] "GET / HTTP/1.1" 404 1074




Jan 22, 2018 1:10:31 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
WARNING: The web application [Hi5S] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Jan 22, 2018 1:10:31 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [Hi5S] appears to have started a thread named [Tomcat JDBC Pool Cleaner[1745616951:1516597490962]] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.util.TimerThread.mainLoop(Timer.java:552)
java.util.TimerThread.run(Timer.java:505)



I will be very thankful if someone can help me on the above. Tks.
 
Saloon Keeper
Posts: 1867
238
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

tangara goh wrote:...  and what does 1074 means?



The last number (1074, 13656, 1108, etc.) looks like the size of the payload (and a value of - must inidcate no payload).

tangara goh wrote:127.0.0.1 - - [22/Jan/2018:13:33:10 +0800] "GET / HTTP/1.1" 404 1074
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/tutorRegister.jsp HTTP/1.1" 200 13656
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/BootStrap/Checkbox.js HTTP/1.1" 404 1108
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/BootStrap/bootstrap-multiselect.js HTTP/1.1" 404 1121
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/js/bootstrap.min.js HTTP/1.1" 404 1106
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/js/jquery.js HTTP/1.1" 404 1099
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/js/jqBootstrapValidation.js HTTP/1.1" 404 1114
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/js/contact_me.js HTTP/1.1" 404 1103
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:33:15 +0800] "GET /Hi5S/Image/aa1.png HTTP/1.1" 404 1100
0:0:0:0:0:0:0:1 - - [22/Jan/2018:13:34:33 +0800] "POST /Hi5S/addTutor HTTP/1.1" 200 -
127.0.0.1 - - [22/Jan/2018:13:35:29 +0800] "GET / HTTP/1.1" 404 1074
127.0.0.1 - - [22/Jan/2018:13:35:54 +0800] "GET / HTTP/1.1" 404 1074
127.0.0.1 - - [22/Jan/2018:13:36:16 +0800] "GET / HTTP/1.1" 404 1074


 
tangara goh
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ron,

Thanks for the infor. 
Can I know how to make the debugger shows what's happening?
I do not know why it is not showing at all and everything just stalled.  I can't tell what's the error in my code...  Please help. Tks.
 
Bartender
Posts: 19365
86
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


GET / HTTP/1.1" 404 1074



GET is the HTTP request type.

"/" is the URL relative to the application server (URI).

HTTP/1.1 is the protocol to use (HTTP Version 1.1)

404 is the server response code. As defined by RFC2616, which is the universal Internet standard for HTTP responses. At section 10.4.5, you'll see that it says

RFC2616 wrote:
404 Not Found

   The server has not found anything matching the Request-URI.




In other words, you don't have anything defined to handle a URI of "/", so Tomcat has returned an error page with accompanying response code of 404. This tells me that you've removed or altered the TOMCAT_HOME/webapps/ROOT directory, because that's where the default root webapp lives and it would normally return a "400" response with page content.

The message is wrong, in that Java does not leak "memory", it leaks objects. Specifically in your case, I think it's leaking Database Connections, which means that not only is the memory that holds the Connection being leaked, but OS network sockets are leaking as well.

To avoid this, you MUST close connection pool Connections as soon as you are done using them, and make sure that no Exceptions would bypass the close statement. You cannot depend on the garbage collector to handle this for you. And absolutely do not ever store Connections in session-scope objects.

Database connections are the most commonly leaked objects, but another possibility would be if you spawned threads while handling a servlet or JSP request. J2EE standards strictly forbid doing that. Not only can they leak, they can potentially crash any webapp in the server or even the server itself.

And 1074 is the number of characters in the Tomcat-generated response page that will be displayed in the client's browser.
 
tangara goh
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




In other words, you don't have anything defined to handle a URI of "/", so Tomcat has returned an error page with accompanying response code of 404. This tells me that you've removed or altered the TOMCAT_HOME/webapps/ROOT directory, because that's where the default root webapp lives and it would normally return a "400" response with page content.


And 1074 is the number of characters in the Tomcat-generated response page that will be displayed in the client's browser.



Hi Tim,

Tks for the detailed explanation.  I appreciate it.

I'm not sure why there is a 404 since I have defined the path in my web.xml as follows :


<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
  <display-name>Hi5S</display-name>
  <welcome-file-list>
    <welcome-file>tutorRegister.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
  <welcome-file>index.htm</welcome-file>
  <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <resource-ref>
<description>MySQL Datasource</description>
<res-ref-name>jdbc/hi5s</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
  </web-app>



And looking at the following path :

C:\Users\\workspace5\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps, it shows Hi5S and ROOT folders inside, so what is amiss here ?


The message is wrong, in that Java does not leak "memory", it leaks objects. Specifically in your case, I think it's leaking Database Connections, which means that not only is the memory that holds the Connection being leaked, but OS network sockets are leaking as well.

To avoid this, you MUST close connection pool Connections as soon as you are done using them, and make sure that no Exceptions would bypass the close statement. You cannot depend on the garbage collector to handle this for you. And absolutely do not ever store Connections in session-scope objects.

Database connections are the most commonly leaked objects, but another possibility would be if you spawned threads while handling a servlet or JSP request. J2EE standards strictly forbid doing that. Not only can they leak, they can potentially crash any webapp in the server or even the server itself.



I'd like to clarify do I still need to have a connection(As in programmatically) since I am using xml configuration via hibernate.cfg.xml where the connection properties are stated.

And basically I am using a hibernate SessionFactory to do all the connection transaction etc.

Thanks for your help you can provide.



 
Sheriff
Posts: 4838
135
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused.  I don't see any servlets mapping or URL patterns, like:
 
Tim Holloway
Bartender
Posts: 19365
86
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:I'm confused.  I don't see any servlets mapping or URL patterns, like:



Well, that simply means that it should have defaulted to the first matching welcome-page.

What I am suspecting, however, is that the webapp that owns this particular web.xml is not deployed as the root webapp, and that the root servlet has been removed. Because the URL in question doesn't have an explict webapp context, which means that the root webapp would be the recipient of the request.
 
tangara goh
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:

What I am suspecting, however, is that the webapp that owns this particular web.xml is not deployed as the root webapp, and that the root servlet has been removed. Because the URL in question doesn't have an explict webapp context, which means that the root webapp would be the recipient of the request.



Hi Tim,

I cleaned the Tomcat Directory and changed the location to Tomcat take control and here's what I got :

127.0.0.1 - - [24/Jan/2018:13:17:33 +0800] "GET / HTTP/1.1" 200 11450
0:0:0:0:0:0:0:1 - - [24/Jan/2018:13:17:35 +0800] "GET /Hi5S/tutorRegister.jsp HTTP/1.1" 200 13656
0:0:0:0:0:0:0:1 - - [24/Jan/2018:13:17:35 +0800] "GET /Hi5S/BootStrap/Checkbox.js HTTP/1.1" 404 1107
0:0:0:0:0:0:0:1 - - [24/Jan/2018:13:17:35 +0800] "GET /Hi5S/BootStrap/bootstrap-multiselect.js HTTP/1.1" 404 1120
0:0:0:0:0:0:0:1 - - [24/Jan/2018:13:17:35 +0800] "GET /Hi5S/Image/aa1.png HTTP/1.1" 404 1099
0:0:0:0:0:0:0:1 - - [24/Jan/2018:13:17:35 +0800] "GET /Hi5S/js/jquery.js HTTP/1.1" 404 1098
0:0:0:0:0:0:0:1 - - [24/Jan/2018:13:17:35 +0800] "GET /Hi5S/js/bootstrap.min.js HTTP/1.1" 404 1105
0:0:0:0:0:0:0:1 - - [24/Jan/2018:13:17:35 +0800] "GET /Hi5S/js/jqBootstrapValidation.js HTTP/1.1" 404 1113
0:0:0:0:0:0:0:1 - - [24/Jan/2018:13:17:36 +0800] "GET /Hi5S/js/contact_me.js HTTP/1.1" 404 1102
0:0:0:0:0:0:0:1 - - [24/Jan/2018:13:30:39 +0800] "POST /Hi5S/addTutor HTTP/1.1" 200 -

It looks like it can read the url but I don't see any debugging output in the console...even though I have the right Logging and jars at the build path etc.

And I tried to see if I can see the Tomcat welcome page by starting Tomcat and type http://localhost:8080 it gives me a 404

so from the log it appeared it is working but it is not cos I can't see the Tomcat welcome page at all...

I am really lost and can't seem to overcome this problem.

Hope to hear some pointers here.

Thank you once again.
 
Tim Holloway
Bartender
Posts: 19365
86
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this URL instead: http://localhost:8080/HI5S

One thing to be aware of in Tomcat is that there is no central logging for everything. Tomcat has its own logger, which by default goes to stdout or TOMCAT_HOME/logs/catalina.out (except when it goes to a logs/localhost file!)

Each webapp will have its own logger as well, using whatever logger the application developer set up in the webapp itself. Settings in Tomcats logger will not affect the app's logging and vice versa.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!