resteasy

JSON Serialization loop (infinite recursion) in Wildfly

南楼画角 提交于 2019-12-01 23:54:26
I am developing a straightforward maven-based JavaEE application in IntelliJ IDEA, and obviously I would like to use Wildfly 8 for both development and production. I simply need to expose some entities through some RESTful web services. Those entities have bidirectional relationships, which leads to a loop when they are going to be serialized into JSON. Newer versions of Jackson are able to handle this kind of situation with a special annotation. To get that to work, I need to exclude Wildfly's built-in JSON serializer / jackson provider / whatever it is and use the newer version that comes

RestEasy : org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token(..)

我只是一个虾纸丫 提交于 2019-12-01 20:51:32
I have a rest endpoint which returns List<VariablePresentation> . I am trying to test this rest endpoint as @Test public void testGetAllVariablesWithoutQueryParamPass() throws Exception { final ClientRequest clientCreateRequest = new ClientRequest("http://localhost:9090/variables"); final MultivaluedMap<String, String> formParameters = clientCreateRequest.getFormParameters(); final String name = "testGetAllVariablesWithoutQueryParamPass"; formParameters.putSingle("name", name); formParameters.putSingle("type", "String"); formParameters.putSingle("units", "units"); formParameters.putSingle(

CORS: AngularJS + Resteasy 3 + Wildfly

霸气de小男生 提交于 2019-12-01 17:45:09
问题 I am developing an app using AngularJS and Resteasy. As expected I am facing the well known problem of XMLHttpRequest cannot load http://localhost:8080/..... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 403. As seen on other stack overflow posts [1], I tried using Resteasy's CorsFilter from a Feature object, but I get: [33m02:06:57,883 WARN [org.jboss.resteasy

Resteasy Bean Validation Not Being Invoked

十年热恋 提交于 2019-12-01 17:43:16
Problem Background I have a Resteasy service that uses Spring through Resteasy's SpringContextLoaderListener . This is built on Resteasy version 3.0-beta-6 . I would like to use bean validation on the incoming requests, but I can not get Resteasy to call the validator. It acts like there is no validation configured and simply passes the method the invalid input object. Question How do I enable bean validation in Resteasy? What I've Tried I have done the following: Annotated my resource class with @ValidateRequest Annotated the method parameter with @Valid Annotated the constraints on my input

Rest easy and init params - how to access?

谁都会走 提交于 2019-12-01 17:22:26
I'd like to have some init params in my web.xml and retrieve them later in the application, I know I can do this when I have a normal servlet. However with resteasy I configure HttpServletDispatcher to be my default servlet so I'm not quite sure how I can access this from my rest resource. This might be completely simple or I might need to use a different approach, either way it would be good to know what you guys think. Following is my web.xml, <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

Resteasy and Google Guice: how to use multiple @ApplicationPath and resource with @Injection?

霸气de小男生 提交于 2019-12-01 16:19:17
I created a project to test the dependency injection offered by Google Guice in my Jax-rs resources, using Resteasy. My intentions are: Use multiple @ApplicationPath for the versions of my API. In each class annotated with @ApplicationPath I load a set of classes for the specific version. Each resource have a @Inject (from Google Guice) in his constructor to inject some services. I created two classes annotated with @ApplicationPath : ApplicationV1RS and ApplicationV2RS . In both I added the same resources classes ( UserResource and HelloResource ), only for my test. My Module is configured

Resteasy Bean Validation Not Being Invoked

冷暖自知 提交于 2019-12-01 15:49:03
问题 Problem Background I have a Resteasy service that uses Spring through Resteasy's SpringContextLoaderListener . This is built on Resteasy version 3.0-beta-6 . I would like to use bean validation on the incoming requests, but I can not get Resteasy to call the validator. It acts like there is no validation configured and simply passes the method the invalid input object. Question How do I enable bean validation in Resteasy? What I've Tried I have done the following: Annotated my resource class

Resteasy and Google Guice: how to use multiple @ApplicationPath and resource with @Injection?

不羁的心 提交于 2019-12-01 15:16:36
问题 I created a project to test the dependency injection offered by Google Guice in my Jax-rs resources, using Resteasy. My intentions are: Use multiple @ApplicationPath for the versions of my API. In each class annotated with @ApplicationPath I load a set of classes for the specific version. Each resource have a @Inject (from Google Guice) in his constructor to inject some services. I created two classes annotated with @ApplicationPath : ApplicationV1RS and ApplicationV2RS . In both I added the

RestEasy @Path Question with regular expression

百般思念 提交于 2019-12-01 14:47:08
Is it possible to define path with optional path variables. like the uri below: /app/make/{make}/model/{model}/year/{year}/mileage/{mileage}/fuelType/{fuelType}/maxPrice/{maxprice}/transmission/{transmission}/engineSize/{engineSize} URI may be composed of any 0 or more combinations of the parameters? Is there a way to tell resteasy that all those paths are optional? cheers. Why bother using path segments? If they are optional parameters then it can't be a real hierarchy so why not just use query string parameters. They work much better for this type of parameter. @Path("/make/{make}{model:(

Jboss RestEasy构建简单的RESTful Web Services示例(1)

大憨熊 提交于 2019-12-01 12:21:52
项目上要用到webservice,鉴于现在restful webservice比较流行,打算用restful来建立webservice,网上搜了一遍,认为Jboss的RESTEasy比较容易上手,于是就用它来小试牛刀! RESTEasy是JBoss的一个开源项目,提供各种框架帮助你构建RESTful Web Services和RESTful Java应用程序。作为一个JBOSS的项目,它当然能和JBOSS应用服务器很好地集成在一起。但是,它也能在任何运行JDK5或以上版本的Servlet容器中运行。 Resteasy的使用很简单,主要就是配置web.xml. web.xml <?xml version="1.0" encoding="UTF-8"?> <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_2_5.xsd