Solved

My Java application hang - how to investigate reasons of that?

Posted on 2010-11-14
8
784 Views
Last Modified: 2012-05-10
Hi.

I have written some Java application (on PC), packaged it to JAR and started. But after some time it hang. According to a log files I can see that sometimes it happens after ArrayOutOfBounds exception.

My question is - what the usual/recommended ways to investigate and solve such issues?
I mean - what the usual/recommended Java debugging practices?

Is it possible to attach Java process with debugger and check stack, treads, variables and so on?

Run a debug session from Eclipse is not working in my case because my Java application has a specific model which (seems) could not be debugged from Eclipse.
So, yes, I'm writing code in Eclipse but cannot use it as debugger because some things do not work under the Eclipse debugger.
That is why I need something alike to attaching a running Java process with Java debugger and investigate it.
Is it possible at all? What tools/approaches could you could recommend?

Regards,
Dmitry.
0
Comment
Question by:Dmitry_Bond
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 8

Expert Comment

by:robthewolf
ID: 34130871
I have  few suggestions and some questions.  When you say that you cannot use the Eclipse debugger do you mean than you cannot even run it from Eclipse.  To do this you can just right click on the code that contains your main function and click run as.  Then it will run directly from Eclipse you can view the output in the output window.  It will pop up if there is an exception.  The exception will then tell you which line of code it comes form and may even be a clickable link to take you straight there.
If you cannot run it in Eclipse exactly how are you running this.  Are you running this from a command line?  If not open up a command prompt, go to Start and then Run and type cmd.exe.  This will give you the commandline.  using cd navigate to the directory where your executable jar is and type java -jar <name executable jar>.  When you get your exception is should give you a stack trace that tells you where the error is occuring.
Otherwise you might want to look in to a profiler: http://www.yourkit.com/home/index.jsp or http://download.oracle.com/javase/6/docs/technotes/tools/share/jvisualvm.html
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34130877
>>According to a log files I can see that sometimes it happens after ArrayOutOfBounds exception.

That's strange. Normally that would terminate things, not hang them

>>That is why I need something alike to attaching a running Java process with Java debugger

If you can't debug it in Eclipse, you can't debug it in anything. It's possible that some of the binaries have no debug info, in which case they'll need to be recompiled.

Can you post a zip of the source?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34130880
Also, please attach the log file if you can
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 92

Expert Comment

by:objects
ID: 34132595
take a thread dump to determine why it has hung
0
 

Author Comment

by:Dmitry_Bond
ID: 34134362
> take a thread dump to determine why it has hung

Please provide some details how to do it?
Reference to tools and so on.
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 34134424
0
 
LVL 3

Assisted Solution

by:indigo23
indigo23 earned 250 total points
ID: 34147163
try to use the jvisualvm, it is on %JAVA_HOME%/bin folder
0
 

Author Closing Comment

by:Dmitry_Bond
ID: 34430734
I cannot estimate answers because I was moved to another urgent project (non-java). So, the only thing I can do - close the question. Sorry.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most of the developers using Tomcat find it easy to configure the datasource in Server.xml and use the JNDI name in the code to get the connection.  So the default connection pool using DBCP (or any other framework) is made available and the life go…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question