Whatever I do, WildFly returns the 404 code to me
I'm using Java 22.0.1, Intellij Idea and WildFly 32.0.1.Final.
I also tried to run similar and working projects with GitHub on this configuration, but I ran into the same problem
I have created a simple Maven project with the following files:
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ru.sosnilosm.manager</groupId>
<artifactId>task-manager</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>task-manager REST-API</name>
<dependencies>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.15.6.Final</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<!-- So maven doesn't require web.xml.tmp -->
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
package ru.sosnilosm.manager.controller;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/api")
public class JaxRsApplication extends Application {
}
package ru.sosnilosm.manager.controller;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Path("/test")
public class TestController {
@GET
@Produces("text/plain")
public String test() {
return "test";
}
}
Nevertheless, when making a request via Postman at the URL http://localhost:8080/task-manager-1.0-SNAPSHOT/api/test
, I always get a 404 Not Found
Postman results
where did I go wrong?
WildFly 32.0.1.Final - Jakarta EE 10
war_jax-rs_task-manager
├── pom.xml
└── src
└── main
├── java
│ └── ru
│ └── sosnilosm
│ └── manager
│ └── controller
│ ├── JaxRsApplication.java
│ └── TestController.java
└── webapp
├── index.jsp
└── WEB-INF
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ru.sosnilosm.manager.controller</groupId>
<artifactId>jax-rs-task-manager</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<version>10.0.0</version>
<scope>provided</scope>
</dependency>
<!-- Servlet API -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<!-- JAX-RS (Java API for RESTful Web Services) -->
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<finalName>task-manager</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
package ru.sosnilosm.manager.controller;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;
@ApplicationPath("/api")
public class JaxRsApplication extends Application {
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> resources = new HashSet<>();
resources.add(TestController.class);
return resources;
}
}
package ru.sosnilosm.manager.controller;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
@Path("/test")
public class TestController {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String testName(@QueryParam("zipName") String zipName) {
return "test - " + zipName;
}
}
mvn clean package
target/task-manager.war
Note that wildfly 32 supports jakarta ee 10, so the related package names are changed to jakarta.xxx.
import javax.ws.rs.GET;
import jakarta.ws.rs.GET;