Tomcat Intellij Idea: Remote Deploy

Tomcat Intellij Idea: Remote deploy

My answer to my question:

The correct way to deploy remotely is editing JAVA_OPTS environment variable on the remote server. Just enter the command below:

export JAVA_OPTS="-Dcom.sun.management.jmxremote=
-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false"

If that's not going to work and if you don't have any obsession to deploy your website via Intellij Idea, I've got the solution for this problem. To be able to run your website under Tomcat, you can/should get artifact in form of .war file.

It can be done in Intellij from project settings(ctrl+alt+shift+s) then hit the plus button and add new artifact(web:application archieve)

get war file in Intellij

After rebuilding the artifact, .war file can be seen in project-folder\out\artifacts. Next, you should place this file into your tomcat/webapps folder.

For example if you are using Tomcat-7, the folder that I mean exists in /var/lib/tomcat7/webapps. Before copying your .war file you should rename it as ROOT.war. This provides to access your site directly by http://youripaddress:8080. After restarting Tomcat7 service you can access the site.

But not finished yet, you can debug your project remotely like you are debugging your project at your local machine with Intellij Idea. Open Run/Debug Configuration in Idea, hit the plus button and there must be Remote. This is the way to debug your projects for application servers like JBoss, Glassfish as well in Idea. Enter your host and port numbers, select your project as a module.

Before starting to debug, as Intellij says you should give the following parameter to your server JVM:

JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"

To be able to do that in Ubuntu and for Tomcat-7, modified the catalina.sh file in usr/share/tomcat7 folder. I inserted the parameter above of the if [ -z "$LOGGING_MANAGER" ]; then line. It must be on the middle part of the file. Then you should be able to debug your project with Intellij Idea.

Deploying to a Tomcat server which is already running outside of IntelliJ IDEA

If you want to deploy to Tomcat started outside of IDEA, use the Tomcat Remote Run/Debug configuration type.

The difference of the Remote configuration is that it doesn't start the server, ensure you create Remote configuration, not Local:

Tomcat Remote

It's possible to update application without restarting the server, refer to the Updating Applications on Application Servers help section.

How to deploy IntelliJ IDEA project in Apache Tomcat server?

you have to build a .war file of your project.
grails war

(The .war file is in your Project path.)

Now you can deploy the .war file on your remote tomcat server. You copy the File in the webapps folder, then you can access on it: http://localhost:8080/nameofyourwarfile

If you have a problem you can check the log file: logs/catalina.out

http://docs.grails.org/3.0.17/guide/deployment.html

deploy/debug java code on a remote server using Intellij

There is a step by step deployment guide for PhpStorm, but for IntelliJ IDEA it would be almost the same.

Here is the example configuration for deploying a .jar file from artifact subdirectory to the remote server via SFTP into /home/serge/artifact directory:

connection

mappings

I'd configure the artifact to produce the executable jar. Then adjust the deployment configuration to deploy the jar to the remote server. Or you can use Maven/Gradle to do the same.

Next, you can configure Remote SSH external tool to run the jar on the server (via java -jar jarname.jar:

remote ssh tool

Running on the remote server via Tools | External Tools | hello:

running

To automate the process enable Include in project build for the artifact, enable Automatic upload in Tools | Deployment and enable uploading of external changes in Tools | Deployment | Options.

To debug the code use Remote Debug configuration. Copy the JVM options needed for debug and adjust the options in your remote SSH external tool so that the app is started in debug mode and can accept connections (make sure firewall rules are adjusted to permit the connections on the specified port).

  • remote debug configuration
  • debug external tool configuration
  • proof of working


Related Topics



Leave a reply



Submit