I've created what I think is the simplest war possible, and when I deploy it to tomcat 9.0.43, it works fine. But I can't get it to work with Wildfly 32.0.0.1 beta.
I'm using annotated Servlets, so my source is just:
package infoservlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.time.LocalDateTime;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/")
public class InfoServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
PrintWriter writer = resp.getWriter();
writer.append(LocalDateTime.now() + "\n");
writer.flush();
}
}
My pom is:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>markscottwright</groupId>
<artifactId>infoservlet</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
</build>
</project>
I'm deploying the war by cp-ing it to standalone/deployments
and webapps
. I can see infoservlet.war.deployed
in standalone/deployments
.
My wildfly is running as: standalone.sh -b 127.0.0.1 -Djboss.server.base.dir=/tmp/wildfly3/standalone -Djboss.socket.binding.port-offset=300
, but when I try to GET the deployed servlet:
$ curl localhost:8380/infoservlet/ -I
HTTP/1.1 403 Forbidden
Connection: keep-alive
Content-Type: text/html;charset=UTF-8
Content-Length: 68
Date: Tue, 09 Apr 2024 20:40:02 GMT
Tomcat, on the other hand, works fine:
$ curl localhost:8080/infoservlet/ -I
HTTP/1.1 200
Content-Length: 27
Date: Tue, 09 Apr 2024 20:40:31 GMT
I assume I'm missing something about Wildfly - presumably some kind of security setting. What am I doing wrong?
WildFly 32 is a Jakarta EE 10 container. You're servlet is using Jakarta EE 8. You'd need to migrate your deployment to work with Jakarta EE 10 to work with WildFly 27+.
If you want to use Jakarta EE 8, you'd need to use WildFly 26.1.3.Final.