12
votes

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?

1
These parameters are for connection with JConsole/VisualVM to a running application. Probably the percentage signs are not needed?Wim Deblauwe
Alternatively; i closed to build from artifact option it does not require JNDI port but now i have to put war exploded or war file into my remote server but the question is where should i put?Ömer Faruk Almalı
See this question for more info on remote deploy in IntelliJ: stackoverflow.com/questions/10461717/…Wim Deblauwe
@WimDeblauwe your comment has a nano-relation with my question.Ömer Faruk Almalı
@JayGridley Yes I did, check my answer.Ömer Faruk Almalı

1 Answers

17
votes

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.