Tomcat in Idea. War Exploded: Server Is Not Connected. Deploy Is Not Available

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

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.

Tomcat Deployment with IntelliJ - Server is not connected

Because your source code structure is incorrect.

(1) Create folders structure:

.
├── pom.xml
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   └── servlet/
│   │   │   └── ServletHome.java
│   │   └── resources/
│   └── test/
│   ├── java/
│   └── resources/
└── webapp/
├── WEB-INF/
│   └── web.xml
└── hello.jsp

Sample Image

ServletHome.java

package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "servlethome", urlPatterns = {"/servlethome"})
public class ServletHome extends javax.servlet.http.HttpServlet {

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.getWriter().print("Hello World");
}

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req, resp);
}

}

You webapp can access at http://localhost:8080/servlethome
If you want see directly at homepage change to urlPatterns = {"/"}

(2) Add these line to pom.xml

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

result:
Sample Image



Related Topics



Leave a reply



Submit