小编Ave*_*ish的帖子

HTTP状态415 - 无法使用内容类型

使用JSON正文返回的REST服务的POST操作

org.jboss.resteasy.spi.UnsupportedMediaTypeException

:不能消耗内容类型异常

两者@Consumes(MediaType.APPLICATION_JSON)@Consumes("application/json")返回相同的异常.

我尝试使用Postman API客户端调用该服务.

图片

@RolesAllowed("admin")
@POST   
@Consumes(MediaType.APPLICATION_JSON)
@Path("/auth")
public Response login(UserCl usr){

    if(usr.getUsername().compareTo("user") == 0 && 
                usr.getPassword().compareTo("pass") == 0){                      
        return Response.status(200).build(); 
    }
    else{
        return Response.status(401).build();
    }

}

12:44:07,322 WARN  [org.jboss.resteasy.core.SynchronousDispatcher] (http-localhost-127.0.0.1-8080-1) Failed executing POST user-service/auth: org.jboss.resteasy.spi.UnsupportedMediaTypeException: Cannot consume content type
    at org.jboss.resteasy.core.registry.Segment.match(Segment.java:117) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.registry.SimpleSegment.matchSimple(SimpleSegment.java:33) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:327) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.registry.SimpleSegment.matchSimple(SimpleSegment.java:44) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:327) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:374) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:367) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:307) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:173) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:118) [resteasy-jaxrs-2.3.2.Final.jar:]
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.2.Final.jar:]
    at …
Run Code Online (Sandbox Code Playgroud)

java json resteasy postman

17
推荐指数
1
解决办法
3万
查看次数

应用程序服务器可能已在主机localhost上运行

我正在使用JBoss Application Server进行部署的Web项目中。启动服务器后,我收到以下消息。

应用程序服务器可能已在主机localhost上运行

Web Poller在URL http:// localhost:8080上找到了正在运行的服务器

netstat在使用port的进程上的命令上找不到任何条目8080

还尝试了此问题中提到的解决方案。

java eclipse windows java-ee jboss7.x

1
推荐指数
1
解决办法
8373
查看次数

标签 统计

java ×2

eclipse ×1

java-ee ×1

jboss7.x ×1

json ×1

postman ×1

resteasy ×1

windows ×1