[英]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.