[英]RestEasy JAX-RS ApplicationPath returns 404
I'm converting an app from Jboss 6.4/Java8 -> JBoss 7.2/Java11
and I'm running into the error where my endpoint annotations seem to be ignored by the app and return error code 404.
You can see in the logs where the web context is registered and where the web.xml
authenticates the path based on the security constraint, but the request still returns a 404.
我正在从
Jboss 6.4/Java8 -> JBoss 7.2/Java11
转换应用程序,我遇到了错误,我的端点注释似乎被应用程序忽略并返回错误代码404.
您可以在日志中看到web 上下文已注册,其中web.xml
基于安全约束对路径进行身份验证,但请求仍返回404.
I've updated the EE and REST libraries but to no avail.我已经更新了 EE 和 REST 库,但无济于事。
The app has 2 @ApplicationPath
annotations.该应用程序有 2 个
@ApplicationPath
注释。 How are the JAXRS
annotation different from EAP6 to EAP7? JAXRS
注释与 EAP6 到 EAP7 有何不同?
RestApplication休息应用
package com.web;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/rest")
public class RestApplication extends Application {
}
AppResource应用资源
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/applications")
public class AppResource{
private static final Logger logger = LoggerFactory.getLogger(AppResource.class);
@Context
private HttpServletRequest httpRequest;
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response getApplications() {
...
}
...
}
jboss-deployment-structure jboss-部署结构
<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<module name="org.jboss.resteasy.resteasy-jaxrs"/>
<module name="com.fasterxml.jackson.core.jackson-core"/>
<module name="com.fasterxml.jackson.core.jackson-databind"/>
<module name="com.fasterxml.jackson.core.jackson-annotations"/>
</dependencies>
</deployment>
<sub-deployment name="WebApp.war">
<dependencies>
<module name="javax.api"/>
<module name="javaee.api"/>
<module name="org.jboss.msc"/>
<module name="org.jboss.as.server"/>
<module name="org.jboss.resteasy.resteasy-jaxrs"/>
<module name="com.fasterxml.jackson.core.jackson-core"/>
<module name="com.fasterxml.jackson.core.jackson-databind"/>
<module name="com.fasterxml.jackson.core.jackson-annotations"/>
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
Jaxrs subsystem was missing from my standalone so I needed to add it manually.我的独立设备中缺少 Jaxrs 子系统,因此我需要手动添加它。
SCR可控硅
#JAXRS
if (outcome != success) of /subsystem=jaxrs:read-resource()
/subsystem=jaxrs:add()
reload
end-if
standalone独立的
<subsystem xmlns="urn:jboss:domain:jaxrs:1.0"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.