Tomcat in Idea. war exploded: Server is not connected. Deploy is not available
I'm trying this tutoial. I created new project and ran it.
TomCat started, but then nothing happened. I can manually open in browser http://localhost:8080
and see the TomCat home page. It means server can be started. However I can't open index.jsp. Here is my screen after start:
screenshot
As you can see the project is running, but no info about passed environment variables.
No logs.
I use TomCat 7.0.27
Idea 12.1.6
on Opensuse 12.2
My tomcat HOME folder is /usr/share/tomcat
There was a problem:
Idea couldn't copy conf files from /usr/share/tomcat/conf to /home/loco/.IntelliJIdea12/system/tomcat//conf.
I executed chmod 777 *
in /usr/share/tomcat and the problem gone.
Also I changed the way how TomCat is started. It was default value
/usr/share/tomcat/bin/catalina.sh run
I changed to
/usr/share/tomcat/bin/catalina.sh start
All other steps are done in accordance to tutorial.
Solution 1:
The issue happens when a script in the tomcat startup set of scripts (most commonly setenv.sh
/ setenv.bat
) override the JAVA_OPTS
environment variable without including the original value. IDEA sets JAVA_OPTS
to tell tomcat to listen on 1099 for JMX requests for things like status and deployments.
An example of a line from a setenv.sh
that will break:
export JAVA_OPTS="-XX:MaxPermSize=512m -Xmx1024m"
the corrected version:
export JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=512m -Xmx1024m"
The same example lines from a windows setenv.bat
file:
set JAVA_OPTS=-XX:MaxPermSize=512m -Xmx1024m
and corrected:
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=512m -Xmx1024m
If you only run tomcat from within IDEA, you can do as other have suggested and remove the line from your setenv
script and put the jvm options inside the IDEA run configuration.
Solution 2:
I fixed this by removing my setenv.bat in $CATALINA_HOME/bin. Here were the settings inside:
set JAVA_OPTS=-server -Xmx768m -XX:MaxPermSize=256M
I didn't need these options anymore, so I just removed the file. As prule's answer says, you can move these options to the Intellij Run config. After removing the file, deployment worked fine inside IntelliJ.
edit: For a better answer on why this works, check out codelark's answer below. Also, using his method you can keep your setenv.sh/setenv.bat files which is useful if you don't only run your Tomcat from inside IntelliJ IDEA.