Why jboss terminates abruptly? - java

I have a jboss server running continuously, but after a day or two, it stops saying "Press any key to continue" in the console. I have checked the log file as well but there is no exception. Though the question looks abstract but if any of you have come across this can share any help.
Thanks

I assume you're using Windows. You could try setting the environment variable mentioned in this documentation:
https://docs.jboss.org/author/display/AS71/CLI+Recipes#CLIRecipes-Windowsand%22Pressanykeytocontinue...%22issue
But i'm not sure it will help. It's not clear that there is a connection between the batch interpreter asking you to press a key to continue, and JBoss terminating.
The best solution would obviously be to work on Unix instead of Windows, but i imagine that is out of scope!

Related

Tomcat server starts slowly

I have a situation where Tomcat is starting with my java application, but then hangs for several minutes before continuing. Startup logs do not seem to point to anything specific.
Is there a way that I could debug this?
I encountered once a problem where starting Tomcat on a dedicated server also took ages. My problem was that the entropy source that is used to initialize SecureRandom was short of entropy.
It's a known bug: https://wiki.apache.org/tomcat/HowTo/FasterStartUp#Entropy_Source
If this is your problem, known workarounds are:
Set the following system property: -Djava.security.egd=file:/dev/./urandom
or
Use 'new SecureRandom()' instead of 'SecureRandom.getInstance("SHA1PRNG")' (if you have this in your code [source]).
Your question is very broad. We have nothing to work with here in providing an answer.
All I can give you is generic debugging advice.
Add printouts into your web application's startup sequence. Watch
them and see where it hangs.
Try commenting out part for part of the start-up until you notice that
start-up is suddenly sped up, the last bit you commented out should
be the faulty one.

How to check whether a Javaprocess is still running or not?

I am working on a plugin for the Serversoftware Bukkit which should restart it. So I have added the main Function which checks for the right arguments and then starts Bukkit. But before it starts Bukkit it should wait for Bukkit to shutdown before I start it again. I know I could add a timeout but I hope there is a better way. So does anybody know how to do that?
One way would be to check the os with System.getProperty("os.name"); and run the ad hoc command for that specific platform (for example: Linux and Windows).
When you start multiple java processes they all seem to have the same identifiers, which seems to be your problem. "differentiating" the processes is your problem, not killing them.
So either you could create the process yourself programatically, and thus be able to note the PID that is used for the process. Then killing it would be VERY simple:
http://blog.igorminar.com/2007/03/how-java-application-can-discover-its.html
Another idea would be to use JPS to get information on all the java processes. A simple sudo algorithm is discussed here:
http://bluepedia.blogspot.com/2008/11/jps-differentiate-between-multiple-java.html
Hope I could be of some help..

Catching an exception from another running Java application

I've run into the issue where I have a program (not written by me, by someone else) I want to run 24/7, but sometimes it crashes. Normally, this wouldn't be an issue because I can simply create a process watcher that checks if it crashed, and then restarts it if necessary.
But, this particular program sometimes throws an exception and outputs it into the graphical interface that's integrated into it. In this instance, the program doesn't crash at all. The interface stays up, but the actual server functionality is unavailable.
Is there any way I can intercept this information from this process?
You want to use the Java Virtual Machine Tools Interface. I can't give you the code to catch your exception, but this is where to look. You'll have to do some detective work to find the class that throws the exception, or at least to find some indicator that it has been thrown.
Edit: You can also try calling the vendor to see if they know of a way. You can also look to see if it is writing the exception to a log file, which you could then watch.
This may or may not work, but if when the application displays it's error and the server stops working does the memory usage drop? If so you could probably just add some logic to your process monitor to call the windows command tasklist to see if the memory usage drops below some threshold. You'll have to check how much memory the program normally uses and how much it uses after the error though.
Since you said the server functionality stops working, another option could be to write a simple program that basically just pings the server how ever often you want to make sure it is still up. If not, kill the process and restart it.
I assume you have no access to the source code, so if it is outputting to the GUI the answer is no. Even if you could attach to the running process you would need to intercept the exception, but it is caught and sent to the GUI, not thrown from the application.
In theory, you could screen scrape the application. I don't know of any specific tools for doing this, but they may be out there.
Edit: I may have been wrong above, check out a post here where they get the stack from a running thread. You probably won't be able to capture the exception this way, but if you're lucky the stack trace will look very different when the program is operating normally compared to when an exception has been thrown.
Edit 2: I submitted a second, more accurate answer. See below.
Is the other program Java? Look at AspectJ, you may be able to hack something using it if you have control on the program startup.
Without ability to rebuild the app you are generally out of luck unless you do some extensive hacking. Here is one option I can think of.
Most likely the application replaces System.out and/or System.err with its own stream implementation. If that's the case you can try to locate the class for this stream and replace it with your own wrapper with the same name. You may rename original class using jarjar. In the wapper you can provide console output to detect the exception.

unresponsive java application for no reason

I have a java application that I run from eclipse 3.5.
My OS is WinXP(SP2) and the JRE version is 6.05.
I run the application on two identical computers (or so I think) but the application behaves differently on each computer.
The computers are the same Dell Optiplex model with the same amount of memory and have the same GPU.
On the first computer, the application runs flawlessly. However, on the second one the application freezes for a couple of minutes and then returns to run normally.
The strange thing is that the CPU usage on the second computer is not high at all. It seems as though my application does not receive any CPU for no apparent reason.
Computers should be deterministic so I assume there must be some difference between the machines but I don't know where to look.
I would love some ideas on where the problem might be.
Thanks,
Yoav.
I've found the problem.
The application that was unresponsive was run in debug mode.
Sorry to have wasted your time...
It may help you to get a Thread Dump when the app freezes. This will hopefully tell you exactly what is holding you up (i.e. waiting for IO somewhere).
Well, I would first update your JRE version as there are newer versions now.
As for both computers being identical, are they really identical? I find it difficult to believe that both have the same exact software and setup and that anything you have done to one, you have always done to the other. If this is indeed the case, you may want to try to debug your application on the second machine (the one that hangs) and find out specifically where it hangs.
It may also help us if you give more information about your application. The problem may not be your computer at all if the application is doing things like web access, network access, etc.
So both computers have nearly identical hardware. A few other things to check
Do they both have Eclipse 3.5, WinXP(SP2) and JRE 6.05 installed?
And behave differently when run from within Eclipse (on both machines or on one run from command-line)?
Is this reproducible? If yes When does it happen? On startup? Or on some specific action?
Does the program have a GUI?
Is there maybe some kind of virus scanner or another comparable software installed on one of the machines which could delay the program
Is networking, file acccess, multithreading involved?
I can think of two non-application possibilities:
Memory Paging. There's something extra happening on the slow machine, so your JVM is not getting a fair share of CPU time. A large daemon process or some such.
Network access. Your app is making some kind of network call and it's glitching or timeing out. Perhaps going and fetching some XML schema, perhaps a disk acesss to a mounted drive.
I've seen all manner of weirdness when apps attempt to access hosts by name and DNS is not well. One machine has an etc/host entry the other does not. Even each machine might want to resolve itself.

How to obtain a Java stack trace from a client running under web start?

I wanted to get ideas from the SO community about this issue.
Here is the problem:
We have a user on the other side of the world launching our app through WebStart. The user, however, is complaining that her whole application freezes up and becomes unresponsive. Usually, the client is doing a lot of database queries to a distributed database.
Questions:
If we ask her to do a CTRL-Break on her application, where would the JVM write the stack trace to?
Would it be enough just to use JConsole?
Would implementing JMX beans on the client be overkill? Would it actually help in troubleshooting issues in production?
Right now the users are running on JRE 1.5.0-b08, but we do plan on migrating to JRE 6 in a couple of months.
What do you think?
José, you can get a lot of information from the JVM in a number of ways.
The best might be to enable debugging in the remote JVM. You can set them using the j2se element in the descriptor XML, as shown here. Since you can set -Xdebug you have a good start; I've never tried to do remote debugging on a web start app, so it may be a little bit of an issue setting up the remote part.
You could also set some things up yourself by adding a separate thread to talk to you remotely and send debugging messages.
You could use a native java or log4j remote logger.
If it's hanging the way you describe, though, the odds are very high that what's happening is a network hangup of some sort. Can you put some tracing/debugging onto your end of the conversation?
Instead of these debugging suggestions, why don't you install an exception handler for your threads? See java.lang.Thread.
void setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler eh)
Here's the relevant javadoc:
http://java.sun.com/javase/6/docs/api/java/lang/Thread.html#setDefaultUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)
If you install that in your code, and once inside Swing's EDT, then just write some java code to e-mail it to yourself, save it on a server, show it to the user, etc.
You need to have the Java Console displayed (run javaws from the command line, and select this from the Preferences dialog), then hit "v"

Categories

Resources