resteasy

HTTP Handler and Resteasy Deployment with undertow and resteasy

大兔子大兔子 提交于 2019-12-05 06:31:34
I am trying to run both HTTPServer and also the REST Handler. Only one works at a time not able to make it work both at same time. I need to serve html pages and also the api. here is my code. public class HttpServer { private final UndertowJaxrsServer server = new UndertowJaxrsServer(); private static String rootPath = System.getProperty("user.dir"); private final Undertow.Builder serverBuilder; public HttpServer(Integer port, String host) { serverBuilder = Undertow .builder() .addHttpListener(port, host) .setHandler( Handlers.path().addPrefixPath( "/", Handlers.resource( new

create a Jax-RS RESTful service that accepts both POST and GET?

喜欢而已 提交于 2019-12-05 06:02:49
I'm converting one of my existing service to become RESTful and I've got the basic things working with RestEasy. Some of my client apps should be able to execute both GET and POST requests to several services. I'm just seeking if there is any easy way around jax-rs to specify that API should accept both GETs and POSTs. Following you can find a test method, let me know if you see any way around without duplicating this in another class with @GET and @QueryParam. @POST @Path("/add") public Response testREST(@FormParam("paraA") String paraA, @FormParam("paraB") int paraB) { return Response.status

Basic Authentication with Resteasy client

∥☆過路亽.° 提交于 2019-12-05 05:39:52
I'm trying to perform an basic auth to the login-module which runs on my jboss using REST. I already found an StackOverflow topic which explains how to authenticate with credentials. RESTEasy client framework authentication credentials This does not work. Analysing the established connection with Wireshark I was not able to see an HTTP package with Authorization: Basic. After more research I found this article, http://docs.jboss.org/resteasy/docs/2.3.3.Final/userguide/html/RESTEasy_Client_Framework.html which describes how to append basic auth to ApacheHttpClient4Executor from resteasy. //

Is there a client-side mock framework for RESTEasy?

半腔热情 提交于 2019-12-05 05:24:04
RESTEasy provides the Server-side Mock Framework for mocking server requests. Is there an equivalent for unit testing the client framework ? Is InMemoryClientExecutor intended for this purpose? I'm having trouble finding documentation and examples of how this class should be used. Looks like InMemoryClientExecutor may be used for client-side mocking. Looking in the source , it internally uses the same classes as the server-side mock framework, namely, MockHttpRequest and MockHttpResponse . InMemoryClientExecutor gives you the ability to override createResponse for mocking responses and also

Call ExceptionMapper from another ExceptionMapper in JAX-RS

天涯浪子 提交于 2019-12-05 04:06:35
In my RESTEasy application I'm getting a java.lang.reflect.UndeclaredThrowableException , because a checked exception is being thrown from a method that doesn't declare the exception in the throws clause. So I'm writing an UndeclaredThrowableExceptionMapper . The UndeclaredThrowableException wraps the real exception; I call e.getCause() to retrieve it. Can I then throw it or somehow look up the proper ExceptionMapper to handle it? Bryant Luk You can try adding a @Context javax.ws.rs.ext.Providers field/property to your UndeclaredThrowableExceptionMapper class. Then use Providers

What is the substitue for Resteasy ProxyFactory class

有些话、适合烂在心里 提交于 2019-12-05 03:31:21
I just realized that the ProxyFactory class is marked deprecated in RestEasy version 3.0.0. Sadly the approach that deprecates this class is not documented anywhere. I used to initialize my services this way but what is the new way? protected static final String URL = "http://localhost:12345"+"/api"; protected static final MyService myService = ProxyFactory.create(MyService.class, URL); pico633 RESTEasy 3.0.2.Final ( http://howtodoinjava.com/2013/08/03/jax-rs-2-0-resteasy-3-0-2-final-client-api-example/ ) ResteasyClient client = new ResteasyClientBuilder().build(); ResteasyWebTarget target =

HTTP 500 Response with Body?

偶尔善良 提交于 2019-12-05 00:46:06
I have a RESTEasy service that returns a HTTP 500 when a server side error occurs. I manage to attach a body to the HTTP response in order to give more details about the error. So the response that comes out of the service looks something like this HTTP/1.1 500 Internal Server Error Server: Apache-Coyote/1.1 Content-Type: application/xml;charset=ISO-8859-1 Content-Language: en-US Content-Length: 3251 Date: Thu, 14 Oct 2010 23:22:49 GMT Connection: close <?xml version="1.0" encoding="UTF-8" standalone="yes"?><myErrorEnvelope><internalCode>123</internalCode><description>error details<

How do I handle error states in servlet filters without showing the user a stack trace?

你。 提交于 2019-12-04 23:29:33
问题 I'm working on a Jetty/RESTEasy app. If I throw a WebApplicationException(myResponse) from one of my REST endpoints, it sends the given response to the client. When a filter detects an error, I want the same behavior: It should stop execution from proceeding, and It should give the user a clear, JSON-formatted error that does not include a stack trace. Obviously, just writing to the response stream and return ing works from within the doFilter method. But this doesn't work for other methods

Android resteasy-mobile sample client

泪湿孤枕 提交于 2019-12-04 23:17:15
I'm new in Android programming, and I need to implement an Android resteasy-mobile client. I need to connect with a remote JAX-RS web service. I've searching arround and I can't find a simple sample client. Can you tell me how can I make an Android resteasy-mobile client? Thank you in advance. Finally, I've decided to implement an Android json (Jackson) client whith a Jersey server. Here's my code if someone needs to know how it is: SERVER: package com.sl; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import

JAX-RS Jackson Json Provider Date Format Issue

倖福魔咒の 提交于 2019-12-04 23:02:07
问题 WRT to the following question: Jersey + Jackson JSON date format serialization - how to change the format or use custom JacksonJsonProvider. I wish to know Is Jackson specifying that the json date format should be normalised to a unix time integer? Follow-up questions ... Has there been a change in its stance anytime recently? Shouldn't a date format be normalised to the same format provided by jaxb xml output? why/why not? any effort put into resolving this issue? has RestEasy provided a