49

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.

1
  • i was also getting same problem on intellij idea and it got resolved after changing to tomcat_8.5 (from tomcat_9). no idea about the reason yet Commented Mar 1, 2017 at 19:51

13 Answers 13

67

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.

6
  • 4
    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. Commented Jun 9, 2015 at 13:58
  • How to find the setenv script?
    – munmunbb
    Commented Nov 28, 2015 at 23:51
  • 6
    I use mac, and I don't have setenv.sh
    – Dezigo
    Commented Jan 24, 2016 at 21:57
  • 1
    @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
    Commented Feb 3, 2017 at 8:36
  • 1
    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.
    – aircraft
    Commented Feb 3, 2017 at 13:31
28

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.

12
  • 1
    Yep, this worked for me too. Looks like any setenv.sh (or setenv.bat) will cause this problem to occur.
    – Templar
    Commented Apr 12, 2014 at 22:58
  • 1
    In case you don't have the setenv.sh, sometimes you can find JAVA_OPTS inside the $CATALINA_HOME/bin/catalina.sh file.
    – Edenshaw
    Commented Oct 15, 2014 at 21:13
  • 2
    Awesome! This was the issue. Please mark this as correct answer. Commented Nov 15, 2014 at 14:37
  • 3
    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%"
    – Frank
    Commented Jun 8, 2015 at 13:35
  • 1
    @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. Commented Jun 10, 2015 at 1:17
5

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.

4
file->project structure->Project SDK

then reconfigure the SDK.

This really solved my problem.

1
  • This really helped. Btw, I did file->project structure->Project SDK and then selected the JDK instead of the intelij SDK Commented Oct 26, 2018 at 15:00
2

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.

2
  • Yeah, rebuilt a project with Gradle and have it finally working, thanks!
    – ITisha
    Commented Jan 9, 2015 at 9:15
  • Thanks for the simple answer. It works with maven for me! I lost two hours for looking for environment variable values...
    – Robert
    Commented Jul 16, 2015 at 10:19
1

(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.

0

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.

0

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

0

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
0

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.

0

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

0

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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.