Tomcat in Idea. war exploded: Server is not connected. Deploy is not available

77,411

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.

Solution 3

Removing setenv.sh from $CATALINA_HOME/bin also worked for me. I'm running tomcat7/Ubuntu/IntelliJ 12

With setenv.sh in the bin folder, on startup inside IJ I see in the logs :

/usr/local/tomcat/apache-tomcat-7.0.52/bin/catalina.sh run
[2014-07-28 02:41:39,274] Artifact TomcatDebug:war exploded: Server is not connected. Press 'Deploy' to start deployment.
Jul 28, 2014 2:41:40 PM org.apache.catalina.core.AprLifecycleListener init

odonovanj@ubuntuj:/usr/local/tomcat/apache-tomcat-7.0.52$ sudo netstat -tulpn|grep 2928
tcp6       0      0 :::8080                 :::*                    LISTEN      2928/java       
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      2928/java       
tcp6       0      0 :::8009                 :::*                    LISTEN      2928/java  

After removing, in the logs I see : INFO: Server startup in 76 ms Connected to server [2014-07-28 02:44:35,847] Artifact TomcatDebug:war exploded: Artifact is being deployed, please wait... [2014-07-28 02:44:36,512] Artifact TomcatDebug:war exploded: Artifact is deployed successfully

odonovanj@ubuntuj:/usr/local/tomcat/apache-tomcat-7.0.52$ sudo netstat -tulpn|grep 2346
tcp6       0      0 :::8080                 :::*                    LISTEN      2346/java       
tcp6       0      0 :::50044                :::*                    LISTEN      2346/java       
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      2346/java       
tcp6       0      0 :::8009                 :::*                    LISTEN      2346/java       
tcp6       0      0 :::1099                 :::*                    LISTEN      2346/java       
tcp6       0      0 :::52268                :::*                    LISTEN      2346/java 

Seems like the setenv.sh was overriding $JAVA_OPTS, interfering with JNDI running on port 1099.

Solution 4

file->project structure->Project SDK

then reconfigure the SDK.

This really solved my problem.

Solution 5

I don't understand much about the theory of this, but I got the same error. After waiting a bit I got a message saying:

Error during artifact deployment. See server log for details.

I found the log file it presumably meant: "Tomcat localhost.log" and there was a stack trace there for a "NoClassDefFoundError" and "ClassNotFoundException". I did a refresh of Maven and a "Rebuild project" and that did the trick.

Share:
77,411
PaintedRed
Author by

PaintedRed

Updated on October 10, 2020

Comments

  • PaintedRed
    PaintedRed over 3 years

    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.

  • Templar
    Templar about 10 years
    Yep, this worked for me too. Looks like any setenv.sh (or setenv.bat) will cause this problem to occur.
  • ceram1
    ceram1 almost 10 years
    I cannot find setenv.bat . I'm using tomcat7, where can I find it?
  • Christian Wilkie
    Christian Wilkie almost 10 years
    If you didn't make a setenv.bat then it probably doesn't exist. However it can be found in $CATALINA_HOME/bin/. Also, on Linux it will be setenv.sh.
  • Edenshaw
    Edenshaw over 9 years
    In case you don't have the setenv.sh, sometimes you can find JAVA_OPTS inside the $CATALINA_HOME/bin/catalina.sh file.
  • Hannan Shaik
    Hannan Shaik over 9 years
    Awesome! This was the issue. Please mark this as correct answer.
  • ITisha
    ITisha over 9 years
    Yeah, rebuilt a project with Gradle and have it finally working, thanks!
  • Frank
    Frank almost 9 years
    Hi , I also got the same error ,but I cannot find the setenv.sh(or setenv.bat) in the %CATALINA_HOME%\bin , and the catalina.bat/.sh doesn't contain this command . I just find below : set "JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%"
  • Christopher Schultz
    Christopher Schultz almost 9 years
    This is the correct answer; removing bin/setenv.sh just removes your own local configuration and does not explain what the problem actually is. This answer explains why and how the solution works, and why it's not necessary if you craft your bin/setenv.sh script properly.
  • Christopher Schultz
    Christopher Schultz almost 9 years
    Codelark has a better answer below that explains what it happening, and why simply removing bin/setenv.sh|bat isn't the one-and-only solution to this problem.
  • Christian Wilkie
    Christian Wilkie almost 9 years
    @ChristopherSchultz You're right, Codelark has a more thorough answer. At the time I just happened to find a quick fix and didn't try to figure out the reason my fix worked. I'll edit my answer to suggest users to check out his answer below.
  • Robert Moszczynski
    Robert Moszczynski almost 9 years
    Thanks for the simple answer. It works with maven for me! I lost two hours for looking for environment variable values...
  • munmunbb
    munmunbb over 8 years
    How to find the setenv script?
  • hkong
    hkong over 8 years
    @WendyMunmunWang: it's in $CATALINA_HOME/bin where $CATALINA_HOME is the directory where tomcat was installed to
  • Michael
    Michael over 8 years
    @ChristianWilkie There is no setenv.bat or setenv.sh in $CATALINA_HOME/bin. What should I do?
  • Eidan Spiegel
    Eidan Spiegel over 8 years
    @ChristianWilkie I'm running tomcat 8.0.30 on Mac OS installed from homebrew. I don't have a setenv.sh in my $CATALINA_HOME/bin directory. What should i do?
  • Christian Wilkie
    Christian Wilkie over 8 years
    Sorry Michael/Eidan, not sure since I haven't encountered this issue again after I applied my solution :(
  • Eidan Spiegel
    Eidan Spiegel over 8 years
    @Michael did you end up finding a solution?
  • Dezigo
    Dezigo over 8 years
    I use mac, and I don't have setenv.sh
  • aircraft
    aircraft about 7 years
    @codelark, I don't understand your last paragraph. remove the line from your setenv script and put the jvm options inside the IDEA run configuration.
  • aircraft
    aircraft about 7 years
    I can not understand the answer. I used export JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=512m -Xmx1024m" and set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=512m -Xmx1024m. it not work.
  • Uttam Dutta
    Uttam Dutta over 5 years
    This really helped. Btw, I did file->project structure->Project SDK and then selected the JDK instead of the intelij SDK