You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Wildfly 11集成Resteasy遇404错误,无端点可查求助

Troubleshooting Your 404 REST Endpoint Issue on Wildfly 11

Hey there, let's work through this 404 problem step by step—since your project deploys successfully but no endpoints show up in the Wildfly Web Services subsystem, there are several common areas to check:

  • Verify your REST application configuration
    If you're using a JAX-RS Application subclass, make sure it's correctly annotated and specifies your resource classes:

    @ApplicationPath("/rest")
    public class RestApplication extends Application {
        @Override
        public Set<Class<?>> getClasses() {
            Set<Class<?>> resources = new HashSet<>();
            resources.add(BookResource.class);
            return resources;
        }
    }
    

    If you're using web.xml instead, confirm you've configured the Resteasy servlet properly:

    <servlet>
        <servlet-name>ResteasyServlet</servlet-name>
        <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
        <init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>com.yourpackage.RestApplication</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>ResteasyServlet</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
    

    Double-check that the @ApplicationPath value matches the /rest segment in your request URL, and that your BookResource class has the correct @Path("/bookResource") annotation, with the addBook method tagged with the right HTTP verb (like @POST) and @Path("/addBook").

  • Fix Maven dependency conflicts
    Wildfly 11 includes its own version of Resteasy, so your pom.xml dependencies for Resteasy should be marked as provided to avoid version clashes:

    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxrs</artifactId>
        <version>3.0.24.Final</version>
        <scope>provided</scope>
    </dependency>
    

    Remove any conflicting JAX-RS or Resteasy dependencies that might override Wildfly's built-in implementation.

  • Check Wildfly server logs
    Head to your Wildfly standalone/log/server.log file and look for:

    • Resteasy initialization messages (like Registered RESTful API: ...—if these are missing, your endpoints aren't being registered)
    • Deployment warnings or errors (e.g., missing classes, invalid annotations, or configuration issues)
  • Confirm your deployment context path
    Ensure the Library-management segment in your request URL matches the actual deployment name in Wildfly. Check the Wildfly admin console (default: http://localhost:9990) under Deployments to see the exact context path of your project—sometimes Maven's finalName setting can change the war filename, which affects the context path.

  • Validate resource class annotations
    Make sure your BookResource class and methods have all required annotations:

    @Path("/bookResource")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    public class BookResource {
        @POST
        @Path("/addBook")
        public Response addBook(Book book) {
            // Your business logic here
            return Response.ok("Book added").build();
        }
    }
    

    Missing annotations (like forgetting @POST) will prevent the endpoint from being recognized.

If none of these steps resolve the issue, sharing snippets of your pom.xml, web.xml, or resource class code would help narrow things down further!

内容的提问来源于stack exchange,提问作者Subhashc

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:52:04