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
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:
Related Topics
Merging Two JSON Documents Using Jackson
Right Way to Write JSON Deserializer in Spring or Extend It
Httpclient 4.0.1 - How to Release Connection
Why Does Collections.Sort Use Mergesort But Arrays.Sort Does Not
Jtable How Prepareeditor Works
How to Loop User Input Until an Integer Is Inputted
Role/Purpose of Contextloaderlistener in Spring
Advantage of Set and Get Methods VS Public Variable
Jni Converting Jstring to Char *
How to Pass Parameter to Jsp:Include via C:Set? What Are the Scopes of the Variables in Jsp
How to Encode Url to Avoid Special Characters in Java
Ssl Peer Shut Down Incorrectly in Java
How Does the JPA @Sequencegenerator Annotation Work
How to Get the Unique Id of an Object Which Overrides Hashcode()
How to Add Button in a Row of Jtable in Swing Java