tomcat as a windows service

Right now to deploy my app, I just copy the tomcat folder to the machine and start the tomcat server. I was wondering if it was possible to then configure tomcat to start as a windows service. In order to do that, I think I will have to download the Windows Tomcat installer, copy my files in that folder and run the services.bat. Is it the correct way of doing this or is there a way to leverage the existing tomcat?
Thanks.

If you want to deploy your application on Tomcat on Windows, do the next steps:

  1. Build and run your project.
    (Once you have successfully run your application, all required files were created in the build/tomcat folder. So you can use them on another tomcat server.)
    Note: It is necessary to build and run a project with the same type of database (adjusted in the “project properties”), which you want to use on your server.

  2. Download the latest stable build of tomcat. Unpack it somewhere on your windows system - so that will be the server folder.

  3. Copy webapps and shared from a project’s build/tomcat directory to corresponding directory of the server.

  4. Copy conf/catalina.properties from your project to server. To enable logging, also copy /conf/logback.xml.

  5. Put required jdbc-driver to the lib-directory of your server. (You can also find it in the lib-directory of your project’s tomcat).

  6. Next, ensure the path to DB is correctly adjusted in your server’s context.xml (the file is located in webapps/app-core/META-INF/ as usual)

  7. Run tomcat/bin/service.bat install. As a result, a new windows service should appear.
    (Tomcat as a windows service can also be installed using 32-bit/64-bit Windows Service Installer distribution. So you can use the way you like.)

  8. Now we should configure the server: go to Tomcat/bin directory and run tomcat8w.exe with the administration rights (right click on the exe-file).

  9. In the opened window switch to “Java” tab (see attached screenshot).
    Set the “Maximum memory pool’ = 1024.

  10. To the “Java Options” field add the following parameters.


-Dfile.encoding=UTF-8
-Dlogback.configurationFile=./conf/logback.xml
-Dcom.sun.management.jmxremote

If you need to debug your application, add also the following


-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n

In the project these properties are set by /bin/setenv.bat, but the service does not launch this file, so we should configure these parameters here.

After those actions, everything should work: configure and start your service, and the application will be accessible by http://localhost:8080/app/#! URL

opts

Hello, I followed the steps above and it doesn’t seem to work. When i browse the URL, i get the following error message:"
HTTP Status 404 - /flux/

type Status report

message /flux/

description The requested resource is not available.

Apache Tomcat/8.0.33

Hello, try to open the tomcat manager (http://localhost:8080/manager/html ) and see if your application is running.

To use the tomcat manager after installation, it is required to specify tomcat user and password.
It may be done by changing the tomcat/conf/tomcat-users.xml. Add the following:


         <role rolename="manager-gui"></role>
	<user username="admin" password="admin" roles="manager-gui"></user>

when I go to the link http://localhost:8080/manager/html, the screen is blank. I wonder if i have to disable the port that CUBA studio is using?

Hi, i give the same error. When i Open Manager, cannot see the application. How can i add manually?

Hi, i’ve copied… in other tomcat path…

when i try to start application in manager, i give:

FALLO - No se pudo arrancar la aplicación en trayectoria de contexto /app
FALLO - Encontrada excepción org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/app]]

I searched on Internet for especific error. Some www says, problem it’s differents versions of Java on Deployment machine and web server machine.

I’ve copied, all content of tomcat folder, and now, works, but…

Can i change app folder name?
When i deploy more then one app of same development, i need to change name of app. it’s possible?

You can change the application name in Studio. See Project properties > Advanced > Modules prefix.
But in general, I would suggest using one app server (Tomcat, whatever) per application, just by changing its ports (for Tomcat, it can also be done on the same Advanced page). Then you will have more freedom in deployment, management, and using different settings depending on load.

Hi Konstantin,

but, when i deploy from one application, to many customers. When i upgrade versions, what files i need to copy, and what files no, to not change config to Db, and other specific things of every installation?

Could you start a separate topic?