6

Trying to run my app with IntelliJ 13 and Apache tomcat 7.0.42. JDK1.6

Always getting the error Artifact app:war exploded: Server is not connected. Deploy is not available.

But when I deploy through terminal with catalina.sh start it works perfectly fine.

I referred this link for setup: http://confluence.jetbrains.com/display/IntelliJIDEA/Application+Servers

Any idea what am I missing?

Here is the Tomcat Catalina log:

Dec 29, 2014 11:43:29 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
Dec 29, 2014 11:43:29 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Dec 29, 2014 11:43:29 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Dec 29, 2014 11:43:29 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 614 ms
Dec 29, 2014 11:43:29 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 29, 2014 11:43:29 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.42
Dec 29, 2014 11:43:29 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Dec 29, 2014 11:43:29 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Dec 29, 2014 11:43:29 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 44 ms
Dec 29, 2014 11:43:39 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Users/yesuagg/apache-tomcat-7.0.42/webapps/manager

Exception in Event log

4:58:40 PM Compilation completed successfully with 104 warnings in 6 sec
4:58:42 PM Application Server was not connected before run configuration stop, reason:
       java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: 
       java.net.ConnectException: Connection refused]
yesuagg
  • 153
  • 1
  • 2
  • 9
  • would you please try setting another version of tomcat in Intellij and test. – Hana Bzh Dec 26 '14 at 14:30
  • 1
    Tried with tomcat6. same error – yesuagg Dec 26 '14 at 14:44
  • Try checking tomcat log file and paste the error it here – Hana Bzh Dec 26 '14 at 15:20
  • @HBizhi: I added the log above. – yesuagg Dec 29 '14 at 06:21
  • You have no error in tomcat log, it means maybe some software seems to block tomcat socket. Try disable all antivirus or applications you think may interfere. Also, please check in Run/Debug configuration, where you defined a tomcat server if the artifact is exists in the box named `Before lunch:Make, Build Artifacts`. If there does not exist try adding it.If this is ok then try changing the port number of the defined tomcat server. – Hana Bzh Dec 29 '14 at 06:33
  • @HBizhi I have Make, Build Artifacts in Before launch. Tried changing the port number as well. same error – yesuagg Dec 29 '14 at 09:50
  • Is there `java.net.BindException: Address already in use` in error message? If there is, be sure some other application in using the port. You can find PID of the process that takes the port with `netstat -ano | findstr 8080` and try to kill him. – Hana Bzh Dec 29 '14 at 10:19
  • No such exception. :( – yesuagg Dec 29 '14 at 10:25
  • I'm really trying hard to solve your question. Hope this happen soon :) please paste whole stack error in your question – Hana Bzh Dec 29 '14 at 10:33
  • @HBizhi: Added event log. Something wrong with JMX port I guess – yesuagg Dec 29 '14 at 11:31
  • Is the artifact you created Exploded? when creating artifact did you choose `Web Application:Exploded`? – Hana Bzh Dec 29 '14 at 12:09

5 Answers5

0

Please check this answer posted by Christian and also read that thread. Tomcat deployment issue via IntelliJ

Simply try removing setenv.sh in $CATALINA_HOME/bin

Community
  • 1
  • 1
ZakiMak
  • 2,072
  • 2
  • 17
  • 26
  • 2
    I have already gone through this thread. I dont have setenv.sh in $CATALINA_HOME/bin – yesuagg Dec 26 '14 at 14:46
  • After deleting I would restart the machine to see how it affects. If you have already done this then I am not sure what else could be wrong :( – ZakiMak Dec 26 '14 at 15:12
  • 1
    Where is $CATALINA_HOME in Windows? I've only set $JAVA_HOME – Gank Oct 23 '15 at 10:04
  • 2
    I don't have C:\java\apache-tomcat-6.0.16\bin\setenv.sh – Gank Oct 23 '15 at 10:05
  • Don't remove files, that's crazy. Just make sure that if you override CATALINA_OPTS, do it with inclusion of previous value - e.g. CATALINA_OPTS=" $CATALINA_OPTS" – mvmn Aug 10 '16 at 13:37
  • @mvmn If you have a `setenv.sh` it's because you manually added it, so removing it isn't "crazy." If you're having issues with it, it's likely because of what you put in the file. – inanutshellus Nov 04 '16 at 14:00
  • "it's because you manually added it, so removing it isn't "crazy." Still is - if I added it, I must've done that for a reason. – mvmn Nov 04 '16 at 14:03
0

I had this issue today and it wasn't due to setenv.sh as discussed on the other thread. In the end it was an issue with $CATALINA_BASE/conf/server.xml.

For some reason in our server.xml we were using a custom engine name for example

<Engine name="custom-value" defaultHost="localhost">

I tried again with a clean server.xml from tomcat 7.0.57 and the artifact deployed perfectly. After trial and error it came down to this one line.

Changing engine name to 'Catalina' as shown below value fixed our issue and allowed our exploded artifact to deploy using our customised server.xml

<Engine name="Catalina" defaultHost="localhost">

If you are seeing this issue try a clean server.xml and work backwards from there.

mattyboy
  • 91
  • 1
  • 2
0

tomcat-7.0-doc RUNNING

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

Community
  • 1
  • 1
0

In my case, Intellij IDEA doesn't support run tomcat8 installed from linux repositories. /usr/share/tomcat/bin/catalina.sh start (not support) /usr/share/tomcat/bin/catalina.sh run (supported)

Only tomcat8 installed from official website. I tried with distribution downloaded from http://tomcat.apache.org/download-80.cgi. So I got successful results.

The reason is in the catalina.sh file from linux distribution, where there isn't "run" command. But in the tomcat downloaded there is "run" command. catalina.sh_InstalledFromLinuxRepository

0

Do you set JAVA_OPTS anywhere in Tomcat bat/sh files? If you do, make sure to keep previous values also - IDEA seems to use those to specify some connection options to Tomcat. E.g. in .sh files do

JAVA_OPTS="<your new stuff> $JAVA_OPTS"

instead of just

JAVA_OPTS=<your new stuff>

P.S. Same answer as this actually: https://stackoverflow.com/a/28867346/307295

Community
  • 1
  • 1
mvmn
  • 3,717
  • 27
  • 30