Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 768
PaintedRed Avatar asked Nov 23 '13 15:11

PaintedRed


People also ask

Why my WAR file is not deployed in Tomcat?

Try stopping Tomcat, deleting the war and matching folder, copying the new war in, then starting Tomcat. If it works then, the problem might be left over files. (I have an app for example that doesn't completely clean itself up). (3) The app might not be initializing properly due to issues with the app.

Where does Intellij deploy Tomcat?

Tomcat deployment directory Follow x), located in R:\programs\apache-tomcat-6.0.

How can I deploy WAR file in Tomcat?

Perhaps the simplest way to deploy a WAR file to Tomcat is to copy the file to Tomcat's webapps directory. Copy and paste WAR files into Tomcat's webapps directory to deploy them. Tomcat monitors this webapps directory for changes, and if it finds a new file there, it will attempt to deploy it.


2 Answers

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.

like image 56
codelark Avatar answered Oct 09 '22 10:10

codelark


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.

like image 32
Christian Wilkie Avatar answered Oct 09 '22 12:10

Christian Wilkie