resteasy

How to get text/xml as UTF-8 from a multipart/form-data request with RESTeasy?

拈花ヽ惹草 提交于 2019-12-02 05:53:10
thanks for your answer, but using an InputStream instead of using getBody(...) does also not work. The code below returns the same result as the one from my original post. final InputStream inStream = fileUploadInput.getFormDataPart(searchedInput, InputStream.class, null); // get bytes final byte[] inBytes = new byte[1024]; final ByteArrayOutputStream outBytes = new ByteArrayOutputStream(inBytes.length); int length = 0; while((length = inStream.read(inBytes)) >= 0) { outBytes.write(inBytes, 0, length); } final byte[] rawInput = outBytes.toByteArray(); // get Encoding final String asciiInput =

resteasy-cdi - getting “Duplicate context initialization parameter resteasy.injector.factory” error

吃可爱长大的小学妹 提交于 2019-12-02 05:40:32
问题 I'm needing CDI functionality on a rest application in which I'm using RESTEASY. So I followed the manual's instruction to setup resteasy-cdi module on my app, that runs on JBoss AS7. But when I start the server I get the following error: 13:48:08,631 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-4) Context [/MainService] startup failed due to previous errors: java.lang.IllegalArgumentException: Duplicate context initialization parameter resteasy.injector.factory My

Using @RolesAllowed to filter entity properties with RESTEasy and Jackson

戏子无情 提交于 2019-12-02 04:04:22
With RESTEasy and Jackson, is it possible to use the @RolesAllowed annotation in my model, in order to avoid certain properties to be serialized in output, depending on the role of the user? I already found a ton of documentation on how to do this with Jersey, but nothing with RESTEasy. I'm blocked on this architecture so switching libraries is not an option, and using the custom ObjectMapper as explained here is not an option either, as the model is big enough to make it too time-consuming to mark every single property of a large dataset for correct serialization. Plus, this refers to an

Maven shade + resteasy Could find writer for content-type

孤者浪人 提交于 2019-12-02 03:24:07
I have a project that works fine with maven managed dependencies. But I have a requirement for giving my jar files as one. For this I use maven-shade plugin ( http://maven.apache.org/plugins/maven-shade-plugin/ ). All class files are exported correctly but when I try to run my application I get an error as: Could find writer for content-type multipart/form-data type: org.jboss.reasteasy.plugins.provider.multipart.MultipartFormDataOutput Any help would be great, thanks. Note: I had a similar problem with spring whose main cause is configuration files. Many jar files contained a configuraiton

JAX-RS NoMessageBodyWriterFoundFailure

大憨熊 提交于 2019-12-02 03:22:58
the method of my jax-rs application: @GET @Produces (MediaType.APPLICATION_JSON) public List <Document> getDocumentList(@HeaderParam("Range") String headerRange) { int [] range = getRangeFromHeader(headerRange); return facade.listByRange(range); } working properly. But If modifications to the: @GET @Produces(MediaType.APPLICATION_JSON) public Response getDocumentList(@HeaderParam("Range") String headerRange) { int[] range = getRangeFromHeader(headerRange); return Response.ok( facade.listByRange(range)) .header("Content-Range", getContentRangeStr(range)).build(); } I receive an error ..

RESTEasy - add a resource class dynamically

依然范特西╮ 提交于 2019-12-02 03:22:45
With RESTEasy I've implemented a subclass of Application to provide a list of singleton resources. Is there a way to add another singleton dynamically later on? I've not found a way to do it from the API docs. I have not tried this myself, but I found a blog post where this is described: http://sarbarian.wordpress.com/2010/03/07/resteasy-and-osgi-perfect-match/ During deployment, RESTEasy puts it's registry in the servlet context. The idea suggstested in the blog, is that you fetch the registry from the servlet context, and then add your resource class. Something like this: import org.jboss

JSON Serialization loop (infinite recursion) in Wildfly

本秂侑毒 提交于 2019-12-02 02:42:01
问题 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

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

天涯浪子 提交于 2019-12-02 00:50:19
问题 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

resteasy-cdi - getting “Duplicate context initialization parameter resteasy.injector.factory” error

落爺英雄遲暮 提交于 2019-12-02 00:41:21
I'm needing CDI functionality on a rest application in which I'm using RESTEASY. So I followed the manual's instruction to setup resteasy-cdi module on my app, that runs on JBoss AS7. But when I start the server I get the following error: 13:48:08,631 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-4) Context [/MainService] startup failed due to previous errors: java.lang.IllegalArgumentException: Duplicate context initialization parameter resteasy.injector.factory My web.xml is the following: <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http:/

jboss Resteasy parameter injection with @Context

荒凉一梦 提交于 2019-12-02 00:03:00
I'm doing a token based authentication using jboss 7.1 and resteasy. I'm using a PreProcessInterceptor to intercept request, get token, retrieve user from token and then check user roles against custom annotations placed on the method. What I want to do now is to inject User into the method like folowing. @Path("/doStuffWithUser") @GET @Requires("ADMIN") // custom annotation public Response doStuffWithUser(@Context User user); I know this is very close from this question and I have tried addapting the differents solutions proposed on the linked github example but I can't find a way to inject