PaintedRed
PaintedRed

Reputation: 1418

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.

Upvotes: 49

Views: 80159

Answers (13)

Amjad
Amjad

Reputation: 21

Go to the TOMCAT BIN DIRECTORY Run on the command prompt the following command

cd Tomcat-9991\bin

catalina.bat run

the output I got was

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/catalina/startup/Bootstrap : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

Indicating that i had a JAVA Version issue between my tomcat and the JDK I was setting this too.

I could fix it by chainging to the correct version of JDK.

Upvotes: 0

ZunPiau
ZunPiau

Reputation: 1

If you had changed /etc/hosts file, you need to add a line localhost YOU_USER_NAME to it.

Upvotes: 0

cnsuifeng
cnsuifeng

Reputation: 1

One more reason, if your tomcat path contains blank or '(', this error will also occur. Please rename your tomcat path.

Upvotes: 0

gangdaner
gangdaner

Reputation: 61

A simple way is to change the port number in that file:

-Dcom.sun.management.jmxremote.port=1099

notice the port, default is 1099, but when use JMX, it may changed by you or someone, so, just simply change the port, that will be OK, no need to remove it from the tomcat bin folder.

Upvotes: 0

Hunger
Hunger

Reputation: 5405

I meet this problem when try to import a project from eclipse to IDEA.

There is no setter.sh in $CATALINA_HOME/bin. The Project Structure and Run Configuration setting in IDEA looks OK, the whole project works normally in eclipse, but show this error in IDEA.

My solution is, delete the .idea folder, re-import the whole project. I don't know what's the accurate cause of this problem, but is works for me.

Now the log looks like that:

/Library/Tomcat/bin/catalina.sh run

[2015-09-22 12:40:57,906] Artifact bookstore:war exploded: Server is not connected. Deploy is not available.
XXXXXX
Connected to server
[2015-09-22 12:40:58,848] Artifact bookstore:war exploded: Artifact is being deployed, please wait...
XXXXXX
[2015-09-22 12:41:07,862] Artifact bookstore:war exploded: Artifact is deployed successfully
[2015-09-22 12:41:07,863] Artifact bookstore:war exploded: Deploy took 9,015 milliseconds

Upvotes: 0

user5091911
user5091911

Reputation: 123

file->project structure->Project SDK

then reconfigure the SDK.

This really solved my problem.

Upvotes: 4

Pleymor
Pleymor

Reputation: 2911

I had this issue with Tomcat 7.0.27. I upgraded to Tomcat 8.0.21 and it fixed my problem :)

Upvotes: 0

Christian Wilkie
Christian Wilkie

Reputation: 3813

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.

Upvotes: 28

codelark
codelark

Reputation: 12334

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.

Upvotes: 67

Maks Danylenko
Maks Danylenko

Reputation: 60

(3.2) Set JRE_HOME or JAVA_HOME (required)

These variables are used to specify location of a Java Runtime Environment or of a Java Development Kit that is used to start Tomcat.

The JRE_HOME variable is used to specify location of a JRE. The JAVA_HOME variable is used to specify location of a JDK.

Using JAVA_HOME provides access to certain additional startup options that are not allowed when JRE_HOME is used.

If both JRE_HOME and JAVA_HOME are specified, JRE_HOME is used.

Upvotes: 1

user2262727
user2262727

Reputation: 51

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.

Upvotes: 5

Tim Cooper
Tim Cooper

Reputation: 10468

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.

Upvotes: 2

prule
prule

Reputation: 2584

I had this problem when I had set JAVA_OPTS in catalina.bat. Removing this meant that tomcat started and deployed as expected. The JAVA_OPTS values can be set in the Intellij Run config.

Upvotes: 0

Related Questions