Java – Start Tomcat on Console from Jenkins

batch-filejavaJenkinstomcat

I have a batch file which start Tomcat as follows (when running it on Windows it works fine)

...
start C:\Users\root\tomcat\tomcat2\bin\startup.bat

The batch file is called from Jenkins as follows
enter image description here

I have this error in the Jenkins Consol at the end of the build

D:\jenkins\workspace\Start 3T2>start C:\Users\root\tomcat\tomcat2\bin\startup.bat 
Process leaked file descriptors. See http://wiki.jenkins-ci.org/display/JENKINS/Spawning+processes+from+build for more information
Finished: SUCCESS

When I check the task manager I see that the server is started but in background. I need actually to start Tomcat it in the Console.

This is what I did :

  • I added -Dhudson.util.ProcessTree.disable=true in jenkins-slave.xml
    used to start jenkins slave service.
  • I added set BUILD_ID=dontkillme in startup.bat to stop Jenkins from
    stopping the process in the end.

I think Tomcat start correctly in the end but not in Console. I'm running Windows 2012 server/Tomcat7/Jenkins 1.578.

Any idea on how to start Tomcat in a Console ?

Best Answer

AFAIK, if you're trying to start Tomcat console on a given machine which has Jenkins configured as service, it will not work. To make it work, you will have to connect to the given machine using JNLP. In case it's a standalone system and you want to open a Tomcat console using Jenkins, you will have to set up a Slave on the same machine and that too using JNLP (Launch slave agents via Java Web Start) in the Launch method section in Jenkins > Manage Jenkins > Manage Nodes > Slave Node's Configure page.

You can connect to the slave using any of the methods shown below. You will see the below option as soon as you configure the slave node and click Save. I ran the highlighted command from the Win command prompt. In my set up, i had configured Master and Slave on the same machine. I have Win 7 Professional, 64-bit laptop.

enter image description here

Once you run the command, you will see a small window that will pop-up and will display 'Connected' message as shown below:

enter image description here

At least for me, i checked that hudson.util.ProcessTree.disable=true & BUILD_ID parameters were not required. The only thing that i needed was to make sure that the following property is unset: HUDSON_SERVER_COOKIE

enter image description here

P.S.: You might have to make sure to start JNLP on reboot. A start-up script will do that. Also, ensure that your project/job is tied to the given slave which is running using JNLP mechanism.

Related Topic