Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat Intellij Idea: Remote deploy

RackSpace Cloud Server Ubuntu-12.04, Intellij Idea-11.1.2, Windows-8, Tomcat-7.0.26, JDK-6.

On Intellij Idea when i try to run jsf project on my remote Tomcat 7 server it says:

Error running servername: Unable to connect to the ip-address:1099

It seems problem is about JNDI port which is 1099 but I couldn't activate it I guess. Tomcat config is sth. like that:

enter image description here

What I've tried?

Setting CATALINA_OPTS or JAVA_OPTS on the server side with:

 CATALINA_OPTS=-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.port=1099 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.authenticate=false

and

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

But this one did not work, any ideas?

like image 477
Ömer Faruk Almalı Avatar asked Dec 29 '12 19:12

Ömer Faruk Almalı


People also ask

Can IntelliJ connect to remote host?

On the IntelliJ IDEA welcome screen, select Remote Development. In the Run the IDE Remotely section, click SSH Connection. If you have the IDE already running on the remote server and you have a connection link, you can use the Connect to Remote Host With a Link section.

How do I deploy in IntelliJ?

on the main toolbar or press Ctrl+Alt+S to open the Settings/Preferences dialog, and choose the Deployment page (you can access the same page by choosing Tools | Deployment | Configuration from the main menu).

How do I deploy a WAR file in IntelliJ?

Build a WAR artifact After IntelliJ IDEA creates the new project, build a WAR artifact to deploy to the application server. From the main menu, select Build | Build Artifacts. In the Build Artifact dialog, select to build the DockerJavaWebApp:war artifact.

Can I use Tomcat with IntelliJ?

If you're not creating a new project from scratch and instead have an existing project that runs on Tomcat, you can configure IntelliJ IDEA Ultimate to connect to your existing Tomcat installation. Let's work with this application from GitHub: Clone the Project in IntelliJ IDEA and then go to Run > Edit Configurations.


1 Answers

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.

like image 95
Ömer Faruk Almalı Avatar answered Oct 02 '22 15:10

Ömer Faruk Almalı