RestEasy+WildFly入门示例遇404错误,求排查配置问题
Let’s walk through the likely issues and fixes for your 404 Not Found error when accessing your JAX-RS endpoint:
1. Fix the jboss-deployment-structure.xml Subsystem Name
This is probably the root cause. In WildFly 13, the JAX-RS subsystem is named jaxrs, not resteasy. Your current exclusion isn’t working, so WildFly’s built-in Resteasy is conflicting with your bundled version. Update your file to:
<?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure> <deployment> <exclude-subsystems> <subsystem name="jaxrs" /> <!-- Corrected subsystem name --> </exclude-subsystems> <exclusions> <module name="javax.ws.rs.api" /> <module name="org.jboss.resteasy.resteasy-jaxrs" /> <module name="org.jboss.resteasy.resteasy-jaxrs-all" /> </exclusions> <local-last value="true" /> </deployment> </jboss-deployment-structure>
This properly excludes WildFly’s native JAX-RS/Resteasy components so your bundled 3.7.0.Final version takes precedence.
2. Add the Missing Resteasy Servlet Initializer Dependency
Your Maven setup is missing a critical dependency that helps Resteasy register resources in a Servlet container. Add this to your pom.xml:
<dependencies> <!-- Existing Resteasy JAX-RS dependency --> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> <version>${resteasy.version}</version> <scope>compile</scope> </dependency> <!-- Add this initializer dependency --> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-servlet-initializer</artifactId> <version>${resteasy.version}</version> <scope>compile</scope> </dependency> <!-- Servlet API (provided by WildFly) --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> </dependencies>
This ensures your HelloWorldApplication is detected and your MessageResource is registered correctly.
3. Adjust the @ApplicationPath Annotation
Using an empty string for @ApplicationPath can cause path resolution issues in WildFly. Update it to use a slash instead:
@ApplicationPath("/") public class HelloWorldApplication extends Application { // ... existing code ... }
This sets your application’s root context to /, making your endpoint paths resolve as expected.
4. Verify Your Full Access URL
Don’t forget your WAR file’s deployment context path. For example:
- If your WAR is named
helloworld.war, the full URL should behttp://localhost:8080/helloworld/hello/World - To use the root context (so you can access
http://localhost:8080/hello/Worlddirectly), rename your WAR toROOT.warbefore deploying to WildFly.
5. Check WildFly Logs for Registration Confirmation
Look in WildFly’s standalone/log/server.log for lines like:
Registered RESTful resource: class com.yourpackage.MessageResource
If you don’t see this, it means your resource isn’t being registered—double-check the above steps, especially the initializer dependency and jboss-deployment-structure.xml changes.
内容的提问来源于stack exchange,提问作者techStack

