resteasy

Inject Spring beans into RestEasy

﹥>﹥吖頭↗ 提交于 2019-11-30 03:58:06
问题 Is it possible to inject Spring beans into an RestEasy @Path class? I managed to do it with Jersey, with @InjectParam annotation, but for some other reasons, I need to switch to RestEasy, and I can't seem to find a way to do it (tried good ol' javax.inject.Inject, but nothing). EDIT This solution works: http://www.mkyong.com/webservices/jax-rs/resteasy-spring-integration-example/ but it's not injection.. I'd still prefer something a little more elegant. 回答1: Simply annotate your RestEasy

Use REST client to call multipart/form-data Rest web service

会有一股神秘感。 提交于 2019-11-29 18:25:30
问题 I have a RESTeasy-based REST web service (see below). I'm trying to use the google REST client to execute a request to test my service, but I'm unsure as to how the request should be setup. I'm not sure how to send the byte[] as a param ( filedata ). Any ideas on how to test this? I get the following exception: java.io.IOException: Unable to get boundary for multipart with request: -content-type=multipart/form-data -form params: test=testvalue Rest method: @POST @Path("/upload") @Consumes(

Match Filter with specific Method through NameBinding on RESTeasy

你。 提交于 2019-11-29 18:19:44
问题 I am trying to specify a pre-matching filter that is only associated to some of my API calls, by following what the RESTeasy documentation suggests. Here is what my code looks like: Name binding: @NameBinding public @interface ValidateFoo {} Resource: @Path("/foo/bar") @Produces(MediaType.APPLICATION_JSON) public class FooBar { @GET @ValidateFoo public Object doStuff() { //do stuff } @POST public Object doAnotherStuff() { //do another stuff } } Filter: @ValidateFoo @Provider @PreMatching

@Produces collection in JAXRS / RestEasy

£可爱£侵袭症+ 提交于 2019-11-29 15:13:57
I found some strange behaviour that I cannot understand. I have tested 4 similar examples: 1 @GET @Produces(MediaType.APPLICATION_JSON) public Response produce() { List<Book> books = Arrays .asList(new Book[] { new Book("aaa", "AAA", "12345"), new Book("bbb", "BBB", "09876") }); return Response.ok(books).build(); } 2 @GET @Produces(MediaType.APPLICATION_JSON) public List<Book> produce() { List<Book> books = Arrays .asList(new Book[] { new Book("aaa", "AAA", "12345"), new Book("bbb", "BBB", "09876") }); return books; } 3 @GET @Produces(MediaType.APPLICATION_XML) public List<Book> produce() {

jboss 6.3.0: decent way to remove resteasy and use jersey

淺唱寂寞╮ 提交于 2019-11-29 15:11:52
问题 I am using jersey. this is my jboss-deployment-structure: <?xml version="1.0" encoding="UTF-8" ?> <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <deployment> <exclusions> <module name="org.jboss.resteasy.resteasy-atom-provider" /> <module name="org.jboss.resteasy.resteasy-cdi" /> <module name="org.jboss.resteasy.resteasy-jaxrs" /> <module name="org.jboss.resteasy.resteasy-jaxb-provider" /> <module name="org.jboss.resteasy.resteasy-jackson-provider" /> <module name=

Binding JAX-RS bean validation error messages to the view

ⅰ亾dé卋堺 提交于 2019-11-29 15:07:05
问题 We can easily validate a JAX-RS resource class field or method parameter using bean validation something like the following: @Size(min = 18, max = 80, message = "Age must be between {min} and {max}.") String age; What is the easiest way to bind the error message to a JSP page? (Say, I am using Java EE 7 with Jersey or Resteasy) 回答1: EDIT 1 We introduced new annotation @ErrorTemplate in Jersey 2.3 that covers this use-case. Handling JAX-RS and Bean Validation Errors with MVC describes it

Jetty 9.0 embedded and RestEasy 3.0 keeps throwing NoSuchMethodError

旧巷老猫 提交于 2019-11-29 14:42:07
问题 Today I had the idea to build a very simple web application, which would be powered by a REST backend. Since I wanted a very lightweight server I started looking at Jetty. And since I wanted to try another JAX-RS implementation than Jersey I looked at RestEasy. I thought those 2 would be easy to implement. I was wrong... I imported the basic Jetty server and servlet dependencies since I thought that were the only server requirements for a basic (REST only) Jetty server (I alto tried to use

RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type class org.keycloak.representations.AccessTokenResponse

我是研究僧i 提交于 2019-11-29 13:46:44
I'm trying to test Keycloak REST API. Instaled the version 2.1.0.Final. I can access the admin through browser with SSL without problems. I'm using the code above: Keycloak keycloakClient = KeycloakBuilder.builder() .serverUrl("https://keycloak.intra.rps.com.br/auth") .realm("testrealm") .username("development") .password("development") .clientId("admin-cli") .resteasyClient(new ResteasyClientBuilder().connectionPoolSize(10).build()) .build(); List<RealmRepresentation> rr = keycloakClient.realms().findAll(); And got the error: javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a

Use JAXB XMLAnyElement type of style to return dynamic element names

邮差的信 提交于 2019-11-29 12:04:38
I have read a lot of answers in these forums, as well as other blog posts, but I can't quite seem to connect the pieces together. So, we start with a basic POJO containing a Map properties. It's well established how to wrap this, but that returns some value. What I'm looking to do is take then name (a.k.a. label) and make it an valid XML 'attribute'. So we would get some value. I found one example (will link if I can find it again) as follows: @XmlAnyElement public List<JAXBElement<String>> getXmlProperties() { List<JAXBElement<String>> elements = new ArrayList<JAXBElement<String>>(); for (Map

Reusing JAX RS Client in multi-threaded environment (with resteasy)

ぃ、小莉子 提交于 2019-11-29 11:35:14
问题 According to the documentation, "Clients are heavy-weight objects that manage the client-side communication infrastructure. Initialization as well as disposal of a Client instance may be a rather expensive operation. It is therefore advised to construct only a small number of Client instances in the application. " Ok, I'm trying to cache Client itself and WebTarget instances in a static variable, the someMethod() is invoked in multi-threaded environment: private static Client client =