Archiwa tagu: tomcat

Tomcat on Windows is not starting

Sometimes Tomcat on Windows is not starting, because of some problems. The best starting point is of course to check logs! In my case, I checked commons-daemon.2018-08-13.log file. This log file contained entries:

[2018-08-13 18:42:54] [info] [ 2444] Commons Daemon procrun ( 32-bit) started
[2018-08-13 18:42:54] [info] [ 2444] Running 'tomcio' Service...
[2018-08-13 18:42:54] [info] [ 1896] Starting service...
[2018-08-13 18:42:54] [error] [ 1896] Failed creating java C:\Program Files (x86)\Java\jre1.8.0_144\bin\client\jvm.dll
[2018-08-13 18:42:54] [error] [ 1896] The system cannot find the path specified.
[2018-08-13 18:42:54] [error] [ 1896] ServiceStart returned 1
[2018-08-13 18:42:54] [error] [ 1896] The system cannot find the path specified.
[2018-08-13 18:42:54] [info] [ 2444] Run service finished.

Look like server is not able to find Java… 🙁

Yes, this can be reason, so I updated Java version. I added new „Java path” to system environmnet variable: „path„. But this was not enough, because it was not able to start again.

How to fix this? Solution is easy:

  1. Double click Apache Tomcat in system tray.
  2. Open „Java” tab.
  3. Change Java Virtual Machine path to new path.
  4. Start Tomcat service.

Now everything should works correctly 🙂

How to debug remote application on Tomcat

Some time ago I wrote about a situation when starting of Tomcat from Netbeans failed. Of course when someone follows with steps prepared in this article, debugging is more complicated. But there is one nice feature in Tomcat – we can debug remote servers.

First thing to do is to enable debugging applications deployed on Tomcat, start Tomcat by this way:

Tomcat/bin/catalina.bat jpda start

By default, Tomcat is listening on port 8000 (changing default port is possible in some configuration files).

In second step we should connect from Netbeans to our application. Sources in IDE (in my case: Netbeans) must be identical with classes deployed on Tomcat! If there are any differences, some breakpoints will be unavailable and debugging will not working properly.

Go to Debug menu and fill forms:

Debugger: Java Debugger (JPDA)
Connector: SocketAttach
Port: 8000

and click OK. After a while, breakpoints should be available. Look into console. There are info about enabling each breakpoint.

Starting of Tomcat failed

Some day I had problem with deploying project from Netbeans to Tomcat (you may look to similar discussion on StackOverflow: Starting of Tomcat failed from Netbeans 7.3). Unfortunatelly, any of suggestion didn’t help, so I wrote my own deployer in Windows batch.

Some code:

ECHO AutoDeploy to Tomcat

SET tomcat_path=C:\TOMCAT
SET build_path=D:\SVN\SMOK_ELTE\JAVA\amfgw\build\web\WEB-INF\classes

::Stop Tomcat
echo Stop Tomcat, press any key to continue...

netstat -a -n | findstr :8080 > NUL
if %errorlevel%==0 ( goto :stoptomcat ) else ( goto :next )
echo Closing Tomcat.
call %tomcat_path%\bin\shutdown.bat
goto :next

::Copy compiled classes from Netbeans to Tomcat
XCOPY %build_path% "%tomcat_path%\webapps\ROOT\WEB-INF\classes" /E /C /R /I /K /Y

::Run Tomcat
CALL %tomcat_path%\bin\catalina.bat jpda start

But I wanted more – let Netbeans run this script after building my application.

Edit build.xml file, located in project directory, by putting these lines:
<target name="-post-compile">
<exec dir="." executable="cmd">
<arg line="/c D:\scriptLocation\deployOnTomcat.bat"/>