简体   繁体   English

org.jboss.resteasy.client.ClientResponseFailure:无法找到内容类型为文本/纯文本且类型为类java.lang.String的MessageBodyReader

[英]org.jboss.resteasy.client.ClientResponseFailure: Unable to find a MessageBodyReader of content-type text/plain and type class java.lang.String

org.jboss.resteasy.client.ClientResponseFailure: Unable to find a MessageBodyReader of content-type text/plain and type class java.lang.String org.jboss.resteasy.client.ClientResponseFailure:无法找到内容类型为文本/纯文本且类型为类java.lang.String的MessageBodyReader

Please help to solve the issue 请协助解决问题

Provider App : 提供商应用:

@Path("/payment")
public class PaymetResource {

    Object object=null;
    @Path("{type}/{gateWay}")

    public Object getResource(@PathParam("type") String type){

        if(type.equals("creditCard"))
            object = new CreditCardPaymentResource();


        if(type.equals("debitCard"))
            object = new DebitCardPaymentResource();


        return object;
    }
}

public class CreditCardPaymentResource {

    /*
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String processPayments(){
        return "hi boss";
    }*/

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public Response processPayment(@QueryParam("cardNo") String cardNo,@PathParam("gateWay") String gateWay){
        String result="processed payment with Gateway:"+gateWay+" and cardNo :"+cardNo;
        return Response.status(201).entity(result).build();
        //return "processed payment with Gateway:"+gateWay+" and cardNo :"+cardNo;
    }


}

public class DebitCardPaymentResource {


    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String processPayment(@QueryParam("cardNo") String cardNo,@PathParam("gateWay") String gateWay,@QueryParam("pin") String pin){
        return "processed payment with Gateway:"+gateWay+" and cardNo :"+cardNo+"pin No"+pin;
    }

}

client app : 客户端应用程序:

public class RestFirstClient{


    public static void main(String[] args) {
        try{

            ClientRequest request = new ClientRequest("http://localhost:8081/DynamicDispatch/rest/payment/creditCard/HDFC");
            request.accept("text/plain");
            request.queryParameter("cardNo", "669888554");
            ClientResponse<String> response = request.get(String.class);
            System.out.println(response.getEntity().toString());
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}

My program is working fine when we access the service through the url. 当我们通过url访问服务时,我的程序运行正常。 Please help me 请帮我

Url : http://localhost:8081/DynamicDispatch/rest/payment/creditCard/HDFC?cardNo=99809990876 网址: http:// localhost:8081 / DynamicDispatch / rest / payment / creditCard / HDFC?cardNo = 99809990876

output :processed payment with Gateway:HDFC and cardNo :99809990876 输出:使用网关:HDFC和卡处理付款:99809990876

The combination of content-type text/plain and type class java.lang.String is handled by the org.jboss.resteasy.plugins.providers.StringTextStar found in resteasy-core . 内容类型文本/纯文本类型类java.lang.String的组合由在resteasy-core中找到的org.jboss.resteasy.plugins.providers.StringTextStar处理。

And the client is created like: 客户端的创建方式如下:

final ResteasyClient client =
    new ResteasyClientBuilderImpl() //
        .connectTimeout(10, SECONDS) //
        .readTimeout(10, SECONDS) //
        .connectionCheckoutTimeout(10, SECONDS) //
        .register(new StringTextStar()) //
        .build();

final ResteasyWebTarget target = client.target(UriBuilder.fromPath("whatever path"));
final CreditCardPaymentResource client = target.proxy(CreditCardPaymentResource.class);

暂无
暂无

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

相关问题 RESTEASY003145:找不到内容类型 application/json 和类型类 org.keycloak.representations.AccessTokenResponse 的 MessageBodyReader - RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type class org.keycloak.representations.AccessTokenResponse 找不到内容类型为text / html的MessageBodyReader并键入接口java.util.List - Unable to find a MessageBodyReader of content-type text/html and type interface java.util.List 如何解决 java.lang.RuntimeException: RESTEASY007545: Unable to find a MessageBodyReader for media type - How to solve java.lang.RuntimeException: RESTEASY007545: Unable to find a MessageBodyReader for media type 找不到内容类型为application / octet-stream的MessageBodyReader - Unable to find a MessageBodyReader of content-type application/octet-stream javax.ws.rs.ProcessingException:无法找到内容类型application / json的MessageBodyReader并输入类 - javax.ws.rs.ProcessingException: Unable to find a MessageBodyReader of content-type application/json and type class Jersey REST-Client WebTarget - 找不到内容类型的 MessageBodyReader - Jersey REST-Client WebTarget - Unable to find a MessageBodyReader of content-type 找不到类型类 java.lang.String 的 PersistentEntity - Couldn't find PersistentEntity for type class java.lang.String Jersey客户端将内容类型标题设置为text / plain - Jersey Client set content-type header as text/plain 无法将[text / plain,UTF-8]表示转换为类java.lang.String的对象 - Unable to convert a [text/plain,UTF-8] representation into an object of class java.lang.String RestEasy - 无法找到MessageBodyReader? - RestEasy - Unable to find MessageBodyReader?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM