resteasy

RestEasy service deploy in Tomcat 7.0.47

爱⌒轻易说出口 提交于 2019-12-08 07:00:51
问题 I'm developing a Rest service with RestEasy. I need to deploy in Tomcat. And I think that I have problems in my web.xml This is my 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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>MyServices</display-name> <!-- Auto scan REST service -->

Delete a file after a File response

佐手、 提交于 2019-12-08 05:30:29
问题 I want to delete a file after a Resteasy put request. My code: @PUT @Path("/audioconverter") public File audioConverter(@Context HttpServletRequest request, File file, @QueryParam("codec") String codec,.... ... return aFile(); } After the return I want to delete aFile() in the filesystem. How can I do that? 回答1: Following some advice from above I was able to do the following: File zipDirectory = new File(outputZipFolder); StreamingOutput stream = new StreamingOutput() { @Override public void

Could not find JAXBContextFinder for media type: application/json

时光毁灭记忆、已成空白 提交于 2019-12-08 04:30:30
I have a problem with development resteay+ejb+json. Using Jboss-5.1.0.GA. I get example from resteasy-jaxrs and adapted to use for my case. Added jars(this ask me jboss. in other case catch exception - class not found) into \jboss-5.1.0.GA\server\default\lib\ resteasy-jaxb-provider-1.2.1.GA jaxrs-api-2.0.1.GA resteasy-jaxrs-2.0.1.GA Get exception 09:43:15,502 ERROR [SynchronousDispatcher:error] Failed executing GET /basic org.jboss.resteasy.plugins.providers.jaxb.JAXBMarshalException: Could not find JAXBContextFinder for media type: application/json at org.jboss.resteasy.plugins.providers.jaxb

RestEasy: How to validate ClientResponse body?

橙三吉。 提交于 2019-12-08 03:35:03
问题 I have a REST endpoint as @GET @Produces(MediaType.APPLICATION_JSON) public Response getVariables(@QueryParam("_activeonly") @DefaultValue("no") @Nonnull final Active active) { switch(active){ case yes: return Response.ok(VariablePresentation.getPresentationVariables(variableManager.getActiveVariables())).build(); case no: return Response.ok(VariablePresentation.getPresentationVariables(variableManager.getVariables())).build(); } throw new WebApplicationException(Response.Status.BAD_REQUEST);

How to set encoding in RESTeasy to UTF-8?

你。 提交于 2019-12-08 03:27:45
问题 I have a problem with encoding strings in RESTeasy. The problem is that chinese alphabet or any other non-latin characters are not displayed properly. If I try to print them out (or send as response) I get "?????" instead. I believe that default encoding in RESTeasy is us-ascii. Do you know how to change it to UTF-8? Maybe there is another solution to this problem? Here is a short passage from my code: @POST @Path("post") @Consumes(MediaType.MULTIPART_FORM_DATA) public String uploadData(

ClientRequest, how to serialize POJO's to json data correctly? could not find writer for content-type application/json type:

本小妞迷上赌 提交于 2019-12-08 03:07:59
问题 For a REST serives (RESTeasy) I have created JUnit test cases like: @Test public void a100_insertAddressTest() throws Exception { Address addr = new Address(1, "testStreet", "1", (short) 1234, "testCity"); ClientRequest request = new ClientRequest(BASE_URL + "customerID/{id}", sslExecutor_schusb); request.body(MediaType.APPLICATION_XML, addr).pathParameter( "id", 1); ClientResponse<String> response = request.post(String.class); Assert.assertEquals(201, response.getStatus()); response

RESTEasy - Response with duplicated Cache-Control - Wildfly10

夙愿已清 提交于 2019-12-08 02:58:25
问题 I have a GET response with an image: @GET @Path("{id}/thumbnail") public Response readThumbnailById(@PathParam("id") String id, @QueryParam("serviceContext") EIServiceContext serviceContext) throws BadRequestRestException { try { serviceContextServices.setFullContext(serviceContext); byte[] thumbnail = documentClientWebServices.readThumbnailById(id); CacheControl cc = new CacheControl(); cc.setMaxAge(2592000); cc.setPrivate(true); ResponseBuilder builder = Response.ok(thumbnail,"image/png");

Implementing a Locale provider that works in JSF and JAX-RS

蓝咒 提交于 2019-12-07 23:13:49
问题 I've been joyfully using omnifaces' Faces.getLocale() to aquire the locale used by the currently logged in user (which in turn gets this from a <f:view> definition). I really like the fallback approach from view to client to system default locale as it fits the requirements for locale selection in my application: If a user is logged in, use his language preference (obtained from the backend entity) If no user preference can be found, use the highest ranking language from the Accept-Languages

Unable to find a MessageBodyReader of content-type application/json

十年热恋 提交于 2019-12-07 22:18:02
问题 I have a RestEasy Client which gets the Data from rest endpoint. The test looks like @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",

Tomcat 7, Weld, RESTEasy not Scanning JARs

∥☆過路亽.° 提交于 2019-12-07 14:16:33
问题 I have Tomcat 7.0.47 and I'm hosting a REST Easy JAXRS service. The service uses two external JARs, one that has a base repository interface and default implementation and one that creates a concrete repository derived from the base (i.e. these two JARs have a dependency). The service works, i.e. I can send a request and get back data from the database. Now what I'm trying to do is get the repository injected into the REST service, to do this I've changed the REST code to look like @Path("