How to analyze JVM crash file hs_err_pidXYZ.log - java

When working on a webapp in Eclipse and Tomcat (wtp) , tomcat crashes and create a file: hs_err_pid20216.log
I tried to use eclipse MAT to analyse the file but MAT doesn't recognize the file as something it can handle, I tried also DAT and it was the same thing. It won't show in the open file dialog.
What kind of file is it?
What should I use to analyze it?
Do I have to make changes to this file so that it will be possible for these tools to parse it.
The log file is available as a GitHub gist
UPDATE:
See #Dan Cruz reply for more information on how to deal with hs_err_pidXYZ.log file. For curious, the cause of the crash was Jackson being confused by a cyclic relationship (bidirectional one-to-many) but this is another story...

What kind of file it is?
It's a HotSpot error log file in text format.
What should I use to analyze it?
Start by downloading the OpenJDK 6 source bundle. Search through the hotspot *.cpp files for strings in the error log. Review the source files for an explanation of what the error log contains.
For example, using OpenJDK 7 sources, you can find siginfo (the operating system process signal information) in the os::print_siginfo() method of os_linux.cpp, Registers (the CPU registers' values) in the os::print_context() method of os_linux_x86.cpp, etc.
Do I have to make changes to this file sothat it will be possible for these tools to parse it.
That would be impossible since the Eclipse Memory Analyzer requires a heap file, which the HotSpot error log is not.

https://fastthread.io gives a well descriptive analyze on the file. it just need to upload it and it will give following items:
Reason to crash
Recommended Solutions
Active Thread (when app crashed)
Core Dump Location
All threads
...

It's a text file. Open it in an editor and try to understand what it means.

Related

A library I am using is opening an input stream and not closing it. How can I close it?

Every few days, I get a SocketException, too many files open. I tracked the issue to a temporary pdf file that is being used during a certain process. The process passes a name of a temporary file that the library creates. At some point, the library opens an input stream but doesn't close it. Given that my code only has the name of the file, is there any way for me to close the stream?
Details:
Java Web App running in Tomcat6
The best approach is to request a version of this library with this bug fixed.
If this is not possible, get the sources, fix the bug yourself.
If you can't (only a binary jar file), try a tool like jd-gui, decompile the faulty class, fix, recompile that class and replace the .class in the jar.
If it still does not work use ASM and add a close statement at the right place. THIS SOLUTION SHOULD BE AVOIDED. It's complex if you do not master this technology.

Is my MainActivity File corrupt after PC failure?

I was using Android Studio, latest release yesterday when my PC decided to just turn off(Turns out PSU's dont last forever). I took the HDD out until I can find a replacement PSU and put it into another PC, upon opening my project I can open the MainAcivity anymore with Android Studio. I opened the Java file with a text editor and it comes up with about 8000 lines of 0's.
Does anyone know how to fix this as I put alot of work and time into that file?
Your file is corrupted, the sector of the disk where the file is stored is effectively damaged / unallocated because the file was being held in the disk cache / currently written.
Resetting the file from version control
If you use a version control mechanism such as git, mercurial or cvs, you can try check-out the file from the system from the moment of your latest successful check-in. If that fails you can try cloning/checkout out the online version of your repository and see if that is the correct version to.
Recovering the file from backups
Every person SHOULD have a proper backup system, making backups is relatively easy to do, and even a git repository stored on multiple computers can already be a good backup.
Even Jeff Atwood has made this mistake in the past. (yes, he is user 1)
Recovering the file using disk checking applications
Sometimes, you may have more luck using chkdsk on Windows or fsck on Linux.
This may happen because you worked on the file, and the file system decided to move the file to another sector for various reasons. Then, while it was moving the file, the hard disk crashed. This left the file pointer referring to the new location, while the file is still safe at the old location.
On Linux and Mac, files recovered by this technique are stored in directory /lost+found, while on Windows, this directory is called "/Found" located in the affected hard drive.
Decompiling your old application
Sometimes, the above techniques are delivering anything resembling your original code. In this case we need to use our must ugly method, decompiling.
There are various java and android decompilers you can use, these can be easily found on google by searching for "java decompiler". I am not going to name them here to prevent this answer from becoming opinium based on what decompiler is the best.

Manage error log in Java

I have an issues with the file Error.log which is generate by Java.
It's too big (Currently >10Go) I can't open it with Notepad++/SublimeText etc.. and as it's on a dedicated computer, transfering it with Teamviewers make Teamviewer crash.
I would like to know if there is a way to configure how the error.log file is generated.
I want to have one file each days and only keep the last 7 days.
Can I configure Java to do that ? Or do I need to redirect System.err to a file ?
Thanks.
There are some java libraries you can use to manage log files the most popular log4j. So if you can edit the source code, this library can help achieve what you want. Besides that there are some tools that can handle large log files and give you search functionnality, edit reports and so on. try look for splunk, elasticsearch, kibana ..
If you have source code available just change log4j configuration. If not then try following
create a job which checks consistently to the log file and rename this when size exceeds some configurable value.

Java program to trace file copying

I want to write a java program which will run in background and trace which file is copying from which source to destination. This program will write this info to a log file. But I am not sure from where to start. Is there anyone out there who can help me to find the starting point?
Edit
I have no restriction to use java. I am open to use any programming language even if its any kind of shell script, I am totally ok. (but only thing is I am on win7). But java would be better :)
Read this to see how to organize file system watches
http://e-blog-java.blogspot.com/2011/03/how-to-watch-file-system-for-changes-in.html
I'm not sure you can know both the source and destination of the copy (at least in Java), but in Java 7 there is a way to watch a directory for create/modification/delete. Read this tutorial.

Trying to find the cause of a Java exception, where are the files?

I have no particular Java knowledge whatsoever. We are running an opensource application which is mainly written in Java. Internet connection dropped while I was editing a job (this is some sort of a translation project management tool) and I cannot open the job anymore.
I checked the database to see if anything is wrong there and all looks fine (I compared values to a working job). Then I logged in to the server and checked logs and seems like this application may be relying on some data which is stored somewhere other than the database.
The log contains tons of lines but I guess this is the one that provides the hint:
ERROR;com.globalsight.everest.workflow.WorkflowProcessAdapter;There is error in create the workflowinstance for the process instance id 54
java.lang.IllegalArgumentException: the userrole value cannot be null
Looks like userrole got messed up while the connection dropped. Now that userrole is not assigned anywhere in the database. I thought I will browse the source files to see where it may be coming from but I am not able to find those. For instance, an exception line says :
com.globalsight.everest.taskmanager.TaskManagerLocal.acceptTask(TaskManagerLocal.java:165)
I browse to that localization and there is a TaskManagerLocal folder there but it is empty. I assume this is compiled in the jar file (right?). Can somebody with Java knowledge shed a light as to how I can dig and find where userrole may be saved and bring by application back up?
Many thanks in advance
com.globalsight... -> globalsight.com
The website states that the sources are on SourceForge
If the project is open source, the code may be packaged inside the JAR file. This is not always the case, as the actual code that is run from the JAR is in compiled bytecode form.
You could try unzipping the JAR using:
jar -xvf the_jar_file.jar
This will create a number of directories/files which may include a src directory. If not, the source is probably not included in the JAR in its un-compiled form, in which case you'd have to download the source from the project site.
Since this error is specifically related to that tool, I'd go to the GlobalSite at http://globalsight.com and ask there. I did a quick search of the site for this error and didn't find anything but you should be able to get some answers (I would think) after posting this on their forum.

Categories

Resources