Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 714

Why does my servlet return 403 in Wildfly but 200 in tomcat? [duplicate]

$
0
0

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/ -IHTTP/1.1 403 ForbiddenConnection: keep-aliveContent-Type: text/html;charset=UTF-8Content-Length: 68Date: Tue, 09 Apr 2024 20:40:02 GMT

Tomcat, on the other hand, works fine:

$ curl localhost:8080/infoservlet/ -IHTTP/1.1 200 Content-Length: 27Date: 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?


Viewing all articles
Browse latest Browse all 714

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>