RESTEasy: Could not find writer for content-type application/json type

If you plan to use newer versions of resteasy that implement JAX-RS 2.0, the following dependencies should solve your problem: <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> <version>3.0.5.Final</version> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>jaxrs-api</artifactId> <version>3.0.5.Final</version> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxb-provider</artifactId> <version>3.0.5.Final</version> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jackson2-provider</artifactId> <version>3.0.5.Final</version> </dependency>

How do I do a multipart/form file upload with jax-rs?

The key is to leverage the @MultipartForm annotations that comes with RESTEasy. This enables you to define a POJO that contains all the parts of the form and bind it easily. Take for example the following POJO: public class FileUploadForm { private byte[] filedata; public FileUploadForm() {} public byte[] getFileData() { return filedata; } @FormParam(“filedata”) … Read more

RESTeasy and Returning to a JSP page with a model

Okay, I figured it out for anyone who is interested. It was actually fairly trivial once I found an example. @GET @Path(“{eventid}”) @Produces(“text/html”) public void getEvent(@Context HttpServletResponse response, @Context HttpServletRequest request, @PathParam(“eventid”) Long eventid) throws ServletException, IOException { EventDao eventdao = DaoFactory.getEventDao(); Event event = eventdao.find(eventid); request.setAttribute(“event”, event); request.getRequestDispatcher(“eventView.jsp”).forward(request, response); }

RESTEasy Client + NoSuchMethodError

This problems are thrown cause of different version of Resteasy Client implementation between your app and Jboss EAP modules. You are using the newest version of jaxrs-client, but JBoss EAP 6.3.0 use very old version (resteasy-jaxrs-2.3.8.Final-redhat-3). Just download latest pack of JBoss Resteasy implementation (sometking like this: resteasy-jboss-modules-3.0.9.Final.zip) and unzip into EAP Modules folder replacing … Read more

Logging request and response in one place with JAX-RS

You can create filters and easily bind them to the endpoints you need to log, keeping your endpoints lean and focused on the business logic. Defining a name binding annotation To bind filters to your REST endpoints, JAX-RS provides the meta-annotation @NameBinding and it can be used as following: @NameBinding @Retention(RUNTIME) @Target({TYPE, METHOD}) public @interface … Read more

Problems Resteasy 3.09 CorsFilter

“Is there another way to configure this CorsFilter and enable the resource scanning?” One way to keep the scanning is just to implement a javax.ws.rs.core.Feature import javax.ws.rs.core.Feature; import javax.ws.rs.core.FeatureContext; import javax.ws.rs.ext.Provider; import org.jboss.resteasy.plugins.interceptors.CorsFilter; @Provider public class CorsFeature implements Feature { @Override public boolean configure(FeatureContext context) { CorsFilter corsFilter = new CorsFilter(); corsFilter.getAllowedOrigins().add(“*”); context.register(corsFilter); return true; … Read more

Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

The problem is the JSON – this cannot, by default, be deserialized into a Collection because it’s not actually a JSON Array – that would look like this: [ { “name”: “Test order1”, “detail”: “ahk ks” }, { “name”: “Test order2”, “detail”: “Fisteku” } ] Since you’re not controlling the exact process of deserialization (RestEasy … Read more