1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[JBoss] Error using Restful with JBOSS runtime, bad arguments passed to RestService

Discussão em 'StackOverflow' iniciado por Stack, Maio 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have created a maven webapp and I'm trying to use the restful services and a JBoss 7.0 runtime.

    I've changed the web.xml to call the restful services using javax.ws.rs from which I have also added the jar to the build path. The server starts perfectly, so there is no errors or failures in related to the web.xml file and I can successfully call the first page.

    I've wrote a class called RestService which is supposed to do something when I call another URL (to be precise localhost:8080/myPrj/rest/hello/first), but when I call the URL it shows an error on my eclipse console and on the web browser.

    What am I doing wrong?

    Please help a newbie

    this is my web.xml

    <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd" >

    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">
    <display-name>Archetype Created Web Application</display-name>
    <servlet-mapping>
    <servlet-name>javax.ws.rs.core.Application</servlet-name>
    <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
    </web-app>


    This is the class Restsservice

    import javax.ws.rs.*;
    import javax.ws.rs.core.*;
    import url_checker.*;


    @Path("/hello")
    public class RestService {


    @GET
    @Path("first")
    @Produces(MediaType.TEXT_PLAIN)
    public String hello(){
    System.out.println("here");
    return "Hi everyone";
    }
    @GET
    @Path("go")
    public String go(){
    runProgramMethod();
    return "<p1>Programm running</p1>";
    }
    private void runProgramMethod() {
    MainPauserMethod runner = new MainPauserMethod();


    }
    }


    This is the error message on the browser:


    type Status report

    message Bad arguments passed to public RestService$ServerService(RestService) ( org.jboss.resteasy.spi.BadRequestException: Could not find message body reader for type: class RestService of content type: /

    description The server encountered an internal error (Bad arguments passed to public RestService$ServerService(RestService) ( org.jboss.resteasy.spi.BadRequestException: Could not find message body reader for type: class RestService of content type: /) that prevented it from fulfilling this request.

    And this one on the console on eclipse:

    16:09:37,134 SCHWERWIEGEND [org.jboss.resteasy.core.SynchronousDispatcher] (http-localhost-127.0.0.1-8080-1) Failed executing GET hello/first: org.jboss.resteasy.spi.InternalServerErrorException: Bad arguments passed to public RestService$ServerService(RestService) ( org.jboss.resteasy.spi.BadRequestException: Could not find message body reader for type: class RestService of content type: */*
    at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:122) [resteasy-jaxrs-2.2.1.GA.jar:]
    at org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.createResource(POJOResourceFactory.java:43) [resteasy-jaxrs-2.2.1.GA.jar:]
    at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:208) [resteasy-jaxrs-2.2.1.GA.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519) [resteasy-jaxrs-2.2.1.GA.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496) [resteasy-jaxrs-2.2.1.GA.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119) [resteasy-jaxrs-2.2.1.GA.jar:]
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.2.1.GA.jar:]
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.2.1.GA.jar:]
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.2.1.GA.jar:]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
    at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
    at java.lang.Thread.run(Unknown Source) [:1.8.0_65]
    Caused by: java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [:1.8.0_65]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) [:1.8.0_65]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) [:1.8.0_65]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) [:1.8.0_65]
    at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:82) [resteasy-jaxrs-2.2.1.GA.jar:]
    ... 23 more

    Continue reading...

Compartilhe esta Página