Tomcat failing to startup

9.1k views Asked by At

A few days ago when I turned the computer on, I tried to start up tomcat and got a surprise for the first time since I deal with software development.

The exact error message is:

Using CATALINA_BASE:   "C:\apache-tomcat-8.0.9"
Using CATALINA_HOME:   "C:\apache-tomcat-8.0.9"
Using CATALINA_TMPDIR: "C:\apache-tomcat-8.0.9\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.8.0_45"
Using CLASSPATH:       "C:\apache-tomcat-8.0.9\bin\bootstrap.jar;C:\apache-tomcat-8.0.9\bin\tomcat-juli.jar"
Error occurred during initialization of VM
Could not find agent library D:\Program in absolute path, with error: Can't find dependent libraries

and I cannot get the point of it, nor find any info about this in google, trying with 3 different versions of tomcat 7.0.8, 8.0.5, 8.0.9, with all is the same situation. When I saw this I thought JDK is outdated because I had a few versions of it, then I removed all JDKs and JREs from PC and installed only the last one 8u45, but without any luck. Can somebody point me in the right direction?

The output with echo

Using CATALINA_BASE:   "C:\Users\Denees\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.15.0_base"
Using CATALINA_HOME:   "C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.15"
Using CATALINA_TMPDIR: "C:\Users\Denees\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.15.0_base\temp"
Using JRE_HOME:        "C:\Java\jdk1.8.0_45"
Using CLASSPATH:       "C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.15\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.15\bin\tomcat-juli.jar"
"C:\Java\jdk1.8.0_45\bin\java.exe" -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=1024m -Dhttp.nonProxyHosts="localhost|127.0.0.1|Denees" -Drebel.env.ide.plugin.version=6.2.0.1 -Drebel.env.ide.version=8.0.2 -Drebel.env.ide.product=netbeans -Drebel.env.ide=netbeans -Drebel.base=C:\Users\Denees\.jrebel -Drebel.notification.url=http://localhost:57212 -agentpath:D:\Program Files\NetBeans 8.0.1\java2\griffin\lib\jrebel64.dll -Djava.util.logging.config.file="C:\Users\Denees\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.15.0_base\conf\logging.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager   -Djava.endorsed.dirs="C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.15\endorsed" -classpath "C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.15\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.15\bin\tomcat-juli.jar" -Dcatalina.base="C:\Users\Denees\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.15.0_base" -Dcatalina.home="C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.15" -Djava.io.tmpdir="C:\Users\Denees\AppData\Roaming\NetBeans\8.0.1\apache-tomcat-8.0.15.0_base\temp" org.apache.catalina.startup.Bootstrap  start
2

There are 2 answers

11
Luke Woodward On BEST ANSWER

This is an error caused by an invalid JVM command-line parameter. Here's one way to reproduce it:

C:\>java -agentpath:D:\Program Files\blahblah
Error occurred during initialization of VM
Could not find agent library D:\Program in absolute path, with error: Can't find dependent libraries

Check Tomcat's Java options. Run %CATALINA_HOME%\bin\tomcat8w.exe as administrator, navigate to the Java tab and take a look at the Java Options. If the value of -agentpath has spaces in it, enclose the value in double quotes.

If you can't find any such argument in Tomcat's startup, check the configuration of your Tomcat server in NetBeans. Go to Window > Servers, choose your server in the list on the left and click the Platform tab. If the 'VM Options' field contains a value for the -agentpath parameter, and this value has spaces in it, ensure this value is enclosed in double-quote characters.

The -agentpath parameter is also used if you start Tomcat in Profile Mode. Here's the full command-line I saw used to start Tomcat in Profile Mode in NetBeans 8.0.2, captured with the help of Sysinternals Process Explorer, and formatted for readability:

"C:\Program Files\Java\jdk1.8.0_05\bin\java.exe"   
  -Dhttp.nonProxyHosts="localhost|127.0.0.1|Stalactite"
  -agentpath:"C:\Program Files\NetBeans 8.0.2\profiler\lib\deployed\jdk16\windows-amd64\profilerinterface.dll=C:\Program Files\NetBeans 8.0.2\profiler\lib",5140
  -Dnbprofiler.agentid=1145099082
  -Djava.util.logging.config.file="C:\Apache\Tomcat8.0.12\conf\logging.properties"
  -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
  -Djava.endorsed.dirs="C:\Apache\Tomcat8.0.12\endorsed"
  -classpath "C:\Apache\Tomcat8.0.12\bin\bootstrap.jar;C:\Apache\Tomcat8.0.12\bin\tomcat-juli.jar" 
  -Dcatalina.base="C:\Apache\Tomcat8.0.12"
  -Dcatalina.home="C:\Apache\Tomcat8.0.12"
  -Djava.io.tmpdir="C:\Apache\Tomcat8.0.12\temp"
  org.apache.catalina.startup.Bootstrap start

It's possible that you are using an old version of NetBeans, which might be generating an invalid value for the -agentpath parameter.

Failing all of the above, you will need to find out exactly what the command line being used to start Java is. To do this, edit catalina.bat (C:\apache-tomcat-8.0.9\bin\catalina.bat) in a text editor. Towards the bottom are four lines all beginning with %_EXECJAVA%. Take a copy of each line, paste it immediately above and add echo to the front of it. So instead of it looking something like the following (I've abbreviated the %_EXECJAVA% lines for clarity):

if not "%JPDA%" == "" goto doJpda
if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% ...
goto end
:doSecurity
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% ...
goto end
:doJpda
if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% ...
goto end
:doSecurityJpda
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% ...
goto end

it should look like

if not "%JPDA%" == "" goto doJpda
if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity
echo %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% ...
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% ...
goto end
:doSecurity
echo %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% ...
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% ...
goto end
:doJpda
if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda
echo %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% ...
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% ...
goto end
:doSecurityJpda
echo %_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% ...
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% ...
goto end

Then, when you start Tomcat, you should see the full command line being run to start Java. This should appear in the NetBeans log window, immediately below the line that begins Using CLASSPATH:.

Now that you've done this and got the output, I can see quite quickly that the problem is caused by the following part of the command line.

-agentpath:D:\Program Files\NetBeans 8.0.1\java2\griffin\lib\jrebel64.dll

So you're using JRebel.

I'm not using JRebel, and as I have no social media accounts I can't even register for a trial of it. All I can do is install the JRebel NetBeans plugin and have a look through the various options.

If you're running Tomcat as a remote server, then there is an error in the setup instructions on the Startup tab of the JRebel plugin's options (Tools > Options > JRebel > Startup). Line 3 of the catalina-jrebel.bat file you are asked to create is as follows:

set JAVA_OPTS=-javaagent:%REBEL_HOME%\jrebel.jar -Drebel.remoting_plugin=true %JAVA_OPTS%

This is of course wrong if your REBEL_HOME environment variable contains a space in it, as it appears to do on your machine. The third line of the above batch script should contain quotes around the value of the -javaagent parameter, i.e.:

set JAVA_OPTS=-javaagent:"%REBEL_HOME%\jrebel.jar" -Drebel.remoting_plugin=true %JAVA_OPTS%

If you're starting Tomcat through the IDE, JRebel is supposed to set up the server automatically. If this is what you are doing and things still aren't working for you then I would seek support from ZeroTurnaround, as this is a JRebel issue.

Incidentally, on your machine, it seems the REBEL_HOME environment variable is pointing to somewhere under D:\Program Files\NetBeans 8.0.1 - I thought you said you have NetBeans 8.0.2 installed?

Finally, as a last resort, try reinstalling NetBeans into a folder that doesn't contain any spaces in it.

1
ACV On

You should put "C:\Program Files" in quotes or better, install tomcat to a folder without spaces in its name.