How to Embed Tomcat 6

Embedded Tomcat 7 slow compare to Tomcat 6

Perhaps it's slow due to classpath scanning which is required for annotation-based configuration of Servlet 3.0. If you don't need these features, try to add metadata-complete="true" to your web.xml.

How do you embed Tomcat in a java project?

While not exacting what you're asking for (Tomcat), I'd recommend including Jetty as a light-weight alternative. You can include it within your JAR as a Maven dependency & it's straight-forward to get a server up & running from your code.

From their example on their website, a server with a basic servlet could be done as easily as:

public class MinimalServlets {

public static void main(String[] args) throws Exception {
Server server = new Server(8080);
ServletHandler handler = new ServletHandler();
server.setHandler(handler);
handler.addServletWithMapping(HelloServlet.class, "/*");
server.start();
server.join();
}

public static class HelloServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().println("<h1>Hello SimpleServlet</h1>");
}
}
}

Deploy Spring Boot application in Tomcat 6 (Traditional deployment)

You are going against the Spring Boot requirements by trying to deploy to Tomcat 6. Even if you hack your application to start something might break later. Since you are on Spring Boot 1.5.9.RELEASE the docs mention it clearly:

Tomcat 7 & 8.0 work with Spring Boot, but the default is to use Tomcat 8.5. If you cannot use Tomcat 8.5 (for example, because you are using Java 1.6) you will need to change your classpath to reference a different version.

Tomcat 6 is legacy and running it's a security risk. It's security support ended on 31 December 2016 and you can't download it since 30 March 2017. Upgrade your Tomcat version.

configure Tomcat 6 with IntelliJ

You've defined tomcat's src folder instead of bin folder.
IntelliJ IDEA recognizes Tomcat 6 as predictable for me:
Sample Image
So, please download suitable distribution here:
https://archive.apache.org/dist/tomcat/tomcat-6/v6.0.9/bin/



Related Topics



Leave a reply



Submit