简体   繁体   English

Wildfly 11,具有resteasy抛出404,未找到端点

[英]Wildfly 11 with resteasy throwing 404 and no endpoints found

I have a project developed using maven, resteasy-3.0.24.Final, wildfly 11. 我有一个使用maven,resteasy-3.0.24.Final,wildfly 11开发的项目。

When I tried to access one of the end point using postman, I got a 404 error. 当我尝试使用邮递员访问端点之一时,出现404错误。

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-servlet-initializer</artifactId>
    <version>3.0.24.Final</version>
</dependency>
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-client</artifactId>
    <version>3.0.24.Final</version>
</dependency>

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

web.xml - I think it is not necessary for wildfly11 web.xml-我认为没有必要使用wildfly11

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>Library</display-name>
   <display-name>Library</display-name>

   <context-param>
      <param-name>resteasy.servlet.mapping.prefix</param-name>
      <param-value>/rest</param-value>
   </context-param>

</web-app>

def- def-

@ApplicationPath("/rest")
    public class LibraryApplication extends Application {

    private Set<Object> singletons = new HashSet<Object>();

    public LibraryApplication() {
        singletons.add(new BookResource());
    }

    @Override
    public Set<Object> getSingletons() {
        return singletons;
    }
  }

resource 资源

@Path("/bookResource")
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.APPLICATION_XML)
public class BookResource {
@Inject
private LibrarianEntityManager manager;

@Path("/addBook")
@POST
public Response addBook(BookModel bookModel) {}

I tried to access http://localhost:8080/Library-management/rest/bookResource/addBook but no luck. 我尝试访问http:// localhost:8080 / Library-management / rest / bookResource / addBook,但是没有运气。 And none of the endpoints defined in Standalone Server Monitor: Subsystems Subsystem: Web Services. 而且,在“独立服务器监视器:子系统子系统:Web服务”中没有定义任何端点。

Any help would be highly appreciated. 任何帮助将不胜感激。 Thanks in advance. 提前致谢。

Note: I was able to deploy this project in tomcat and it did working fine. 注意:我能够在tomcat中部署此项目,并且工作正常。

Got it worked. 知道了。

Wildfly-11 with rest-easy Wildfly-11轻松自在

Dependency - 依赖-

<dependency>
    <groupId>org.jboss.spec.javax.annotation</groupId>
    <artifactId>jboss-annotations-api_1.2_spec</artifactId>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.jboss.spec.javax.ws.rs</groupId>
    <artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
    <scope>provided</scope>
</dependency>

beans.xml- beans.xml-

<?xml version="1.0" encoding="UTF-8"?>
<!-- Marker file indicating CDI should be enabled -->
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
      http://xmlns.jcp.org/xml/ns/javaee
      http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
    bean-discovery-mode="all">
</beans>

index.xml- index.xml-

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Library-management</title>
</head>
<body>

    <p>hello world</em>:

    <ul>
        <li><a href="rest/">abc</a></li>
    </ul>
</body>
</html>

Application- 应用-

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("rest")
public class LibraryApplication extends Application {
}

Resource- 资源-

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Path("/")
public class BookResource {
    @GET
    @Path("/get")
    @Produces({ "application/json" })
    public String getHelloWorld() {
        return "{\"result\":\"";
    }
}

URL: http://localhost:8080/ {context}/rest/get 网址: http:// localhost:8080 / {context} / rest / get

Note: Web xml is not required from wildfly-10 onwards. 注意:从wildfly-10开始,不需要Web xml。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在rest服务实现上找不到resteasy + wildfly + maven投掷类 - resteasy+wildfly+maven throwing class not found on rest service implementation 找不到RESTEasy 404 - RESTEasy 404 not found RESTEasy 和 Wildfly 在请求时返回 405 或 404 - RESTEasy and Wildfly returns 405 or 404 on requests Resteasy不适用于Wildfly 11,但适用于Tomcat - Resteasy is not working with wildfly 11 but fine with Tomcat JAX-RS(Resteasy 3.5.0.Final)+ Wildfly 12 + Java 9 + maven = 404未找到,但JAX-RS(Resteasy 3.5.0.Final)+ Wildfly 12 + Java 8 + maven作品 - JAX-RS (Resteasy 3.5.0.Final) + Wildfly 12 + Java 9 + maven = 404 not found, but JAX-RS (Resteasy 3.5.0.Final) + Wildfly 12 + Java 8 + maven works 部署后,为什么我在RESTEasy(wildfly)上出现404错误? - Why do I get 404 error on RESTEasy (wildfly) after deploy? Resteasy在Wildfly 14(Java 11)上以文本格式导出日期,而在Wildfly 9(Java 8)上以数字格式导出日期 - Resteasy exports dates in textual format on wildfly 14 (Java 11) as opposed to numeric format in wildfly 9 (Java 8) 找不到带有Wildfly的Rest Web服务的404 - 404 not found for a Rest Web service with wildfly Spring restController return not found 404 on wildfly - Spring restController return not found 404 on wildfly WildFly RestEasy版本混乱 - WildFly RestEasy Version confusion
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM