I remember the first time I had to work out why WebLogic wouldn't run as a service. It was a frustrating experience. There were no error messages. No Windows error dialog. No console output.
How do you troubleshoot something like this??!!
This short article will show you. For simplicity I'll talk about the node manager, but the same principles apply for running an admin or managed server as a service.
First Steps
First, you still have your server logs. Sure the console output is better, but it's a starting point. Check this log for errors and especially take note of the start up variables such as PATH and CLASSPATH. If the server log isn't being created, that tells you WebLogic probably isn't even being started. (Check that you have a license file if you haven't already.)
Ok, so the logs were no help. The next step is to look at how the service is trying to start WebLogic.
When you install WebLogic as a service, you're really setting up beasvc.exe as the service. This is a tool that BEA/Oracle supplies with your WebLogic installation, and all it does is runs WebLogic using parameters stored in the Windows Registry.
To find out what beasvc is doing, you can either:
beasvc.exe provides an easy debug mode. To use it,open a command-line console (cmd.exe) and change to the directory where all your domains are located (eg c:\bea\user_projects\). Then run the following command:
WL_HOME\server\bin\beasvc.exe -debug "SVC_NAME"
Where WL_HOME is where weblogic server is installed to (Eg. c:\bea\weblogic92) and SVC_NAME is the name of the service.
Running beasvc with this option will give you a lot of useful information. You can find out more about the '-debug' option here.
Simulating BEASVC.EXE
If the '-debug' option isn't helping, or you need to test something specific, you can always simulate how beasvc starts WebLogic. Normally to start WebLogic, you'd go to the startWebLogic.cmd (or other) script, but since you're starting WebLogic as a service this script is useless.
What we need to do is get all the environment variables and start-up parameters and then run WebLogic at the command-line.
To find the start-up parameters in the Windows Registry, first obtain the full service name from the Windows Services management console. To do this, right-click on the service you are troubleshooting, and click Properties. Copy the 'Display Name' field.
In regedit, search for the service using this display name. (On the Find dialog, select 'Look at: Keys' only.)
When you've found the node, expand it and select 'Parameters'. This contains all the important start-up parameters and environment variables.
Now that we have the start-up parameters used by beasvc, we can easily simulate it.
First, open a command console (cmd.exe) and change to the directory specified by the ExecDir registry entry.
Set the PATH variable to the value of the Path registry entry. Now run java.exe with no options. If it does not execute, you know that the registry's Path entry is incorrect. You can either edit it with regedit, or fix your installsvc.cmd script and run it again.
Finally, run java.exe again, this time followed by the CmdLine registry entry. This should run WebLogic as beasvc.exe would, except any errors will be printed to the console window.
Common Problems
With services, I frequently encounter various problems caused by incorrect CLASSPATH or PATH values - usually directory names with spaces that aren't surrounded by quotes. Java can interpret these as separate command line parameters, rather than a single file path.
As a general rule, avoid installing WebLogic to a directory that has a space in the name. If you do, use the old 8dot3 path name (use the DIR /X command to obtain these).
How do you troubleshoot something like this??!!
This short article will show you. For simplicity I'll talk about the node manager, but the same principles apply for running an admin or managed server as a service.
First Steps
First, you still have your server logs. Sure the console output is better, but it's a starting point. Check this log for errors and especially take note of the start up variables such as PATH and CLASSPATH. If the server log isn't being created, that tells you WebLogic probably isn't even being started. (Check that you have a license file if you haven't already.)
Ok, so the logs were no help. The next step is to look at how the service is trying to start WebLogic.
When you install WebLogic as a service, you're really setting up beasvc.exe as the service. This is a tool that BEA/Oracle supplies with your WebLogic installation, and all it does is runs WebLogic using parameters stored in the Windows Registry.
To find out what beasvc is doing, you can either:
- Use the beasvc '-debug' mode; or
- Simulate the way beasvc starts WebLogic.
beasvc.exe provides an easy debug mode. To use it,
WL_HOME\server\bin\beasvc.exe -debug "SVC_NAME"
Where WL_HOME is where weblogic server is installed to (Eg.
Running beasvc with this option will give you a lot of useful information. You can find out more about the '-debug' option here.
If the '-debug' option isn't helping, or you need to test something specific, you can always simulate how beasvc starts WebLogic.
What we need to do is get all the environment variables and start-up parameters and then run WebLogic at the command-line.
To find the start-up parameters in the Windows Registry, first obtain the full service name from the Windows Services management console. To do this, right-click on the service you are troubleshooting, and click Properties. Copy the 'Display Name' field.
In regedit, search for the service using this display name. (On the Find dialog, select 'Look at: Keys' only.)
When you've found the node, expand it and select 'Parameters'. This contains all the important start-up parameters and environment variables.
Now that we have the start-up parameters used by beasvc, we can easily simulate it.
First, open a command console (cmd.exe) and change to the directory specified by the ExecDir registry entry.
Set the PATH variable to the value of the Path registry entry. Now run java.exe with no options. If it does not execute, you know that the registry's Path entry is incorrect. You can either edit it with regedit, or fix your installsvc.cmd script and run it again.
Finally, run java.exe again, this time followed by the CmdLine registry entry. This should run WebLogic as beasvc.exe would, except any errors will be printed to the console window.
Common Problems
With services, I frequently encounter various problems caused by incorrect CLASSPATH or PATH values - usually directory names with spaces that aren't surrounded by quotes. Java can interpret these as separate command line parameters, rather than a single file path.
As a general rule, avoid installing WebLogic to a directory that has a space in the name. If you do, use the old 8dot3 path name (use the DIR /X command to obtain these).
Resources
If you're having trouble working out why an exception is being thrown, you can check if this site covers your scenario: http://www.insideexceptions.com/. It's a good resource for administrators who understand java.
Good posts Casey, keep up the good work.
ReplyDeleteCM.
Thanks Chris!
ReplyDeleteChris,
ReplyDeletedo you know, how to find out parameters of stop status to complete the entire simulation?
Hi Anitka, If you're stopping the process via the Windows Services Computer Management Console, you're really just killing the process. (So you can simulate by using the Windows Task Manager.)
ReplyDeleteIt is possible to change this behavior so that a graceful shutdown occurs when you stop the service. The steps for doing this can be found here: http://e-docs.bea.com/wls/docs81/adminguide/winservice.html
Should "classpath" generated from original script tagged to the cmdLine registry string ? Could you provide working registry string values for Path and CmdLine ? Trying to resolve -
ReplyDeleteError in java application .......
The following line contains specific error details .......
Unable to find a JVM!
John, There is bug with certain JVMs when running on some 64-bit OSs which results in the "Unable to find a JVM!" error message. See the 3rd post here: http://forums.oracle.com/forums/thread.jspa?threadID=1062305
ReplyDeleteExceptional! Thank you!
ReplyDeleteThanks, nice post
ReplyDelete