jersey

Unmarshalling xml to a bean with a colleciton

I'm working with Redmine's xml rest api. The service returns xml like in the example below. I'm using the Jersey Client API to communicate with the restful service. Mapping the plain fields (id, name and so on) in project are no problem, but I'm having trouble with the trackers list. <project> <id>2</id> <name>Project X</name> ...

Jersey client, JAXBContext used when application is executed with Maven, but not with java -jar

I'm implementing a rest client consuming json data using the Jersy Client API. I don't really have much experience with JAXB, and especially not in combination with JSON. I've followed the example provided here (http://blogs.sun.com/enterprisetechtips/entry/consuming_restful_web_services_with) and registered a JAXBContext. Everything w...

Testing CXF and Jersey together causes Spring conflicts?

I have an app that uses CXF as a SOAP client and Jersey to present REST services, with the Jersey classes managed by Spring. This works fine running in Tomcat; however when attempting to test with JerseyTest I get Spring conflicts; it appears JerseyTest doesn't shut-down the Spring context correctly. The test initialisation for Jersey ...

Problem with rest web service?

I have a rest web service, that retrives data from my sql database using hibernate technology. While running, the web sevice throws error below java.lang.NoClassDefFoundError: Could not initialize class com.sample.restlet.HibernateSessionFactory com.sample.restlet.EmployeeResource.(EmployeeResource.java:22) sun.reflect.NativeCo...

Problem arise while integrate hibernate with restful web service?

Hello Everybody, I am using hibernate for a while now without any (bigger) problems. Now I am trying to work out RESTful Webservices with project jersey. It seems that hibernate wich depends on ASM framework (asm.jar, asm-attrs.jar) and jersey which depends on ASM too (asm V3.1 as of asm-3.1.jar) are having problems with the asm impleme...

Binding a Generic Java Class to a JSON using JAXB

I have the following java class @XmlRootElement @XmlSeeAlso(DataClass.class) public static class EnvelopeClass<T> { @XmlElement public String version; @XmlElement public T data; EnvelopeClass() { } EnvelopeClass(String version, T data) { this.version = version; this.data = data; } } ...

Validate JAXBElement in JPA/JAX-RS Web Service

I have a JAX-RS webservice (Jersey) that is a CRUD interface for JPA (EclipseLink) entities. My entities were autogenerated from the database tables and I have annotated them with JAXB annotations so that they can be marshalled/unmarshalled to/from XML. My resource methods take JAXBElement objects as a parameter where required. I don'...

Accessing secure restful web services using jersey client

I have created web services based on Jersey (auto generated via Netbeans). I have also created a user names “testClient” with password “secret” and created User group “Users” and used file Realm using glassfish 3.0.1 admin console. I have also mapped web.xml and sun-web.xml accordingly. My web services are secured successfully; as I a...

How do I set the xml namespace when using Jersey, jaxb & jax-rs

How do I set the xml namespace when using Jersey, jaxb & jax-rs ...

How to choose between Jersey, Apache Wink and JBoss RESTEasy?

I just heard about Apache Wink, and I was wondering what differences it had compared to Jersey or JBoss RESTEasy. What can be done in one that the other two can't? We've been using Jersey for some of our internal projects mostly for it's simplicity, but I can't really figure out what makes these other two any better that I would consid...

OpenJPA, Jersey, JUnit: Using a different persistence unit for my unit tests?

Hi all. I'm building an application using OpenJPA 2.0.0, Jersey 1.3, and JUnit 4.8.1. I've set it up so I have two different persistence units defined in my persistence.xml: "default" and "unittest." Default is set up to connect to an Oracle instance, while unittest is set up to connect to a local H2DB embedded database file. I do th...

Input and Output binary streams using JERSEY?

I'm using Jersey to implement a RESTful API that is primarily retrieve and serve JSON encoded data. But I have some situations where I need to accomplish the following: Export downloadable documents, such as PDF, XLS, ZIP, or other binary files. Retrieve multipart data, such some JSON plus an uploaded XLS file I have a single-page JQ...

RESTful 1-N optional relationships

I trying to learn how to write RESTful apps in Java using Jersey and Hibernate, and I'm struggling to understand how to handle parent/child type relationships when POSTing data to a Resource. I'm using JSON to exchange data, but I don't think that's particularly relevant to my problem. The example I'm working with models the relationshi...

How do I scale my Scala REST application that uses Akka?

I have a Scala application using Akka that receives REST requests, makes some operations against a database, and responds with some information to the client. As it is, my db operations take a long time and my REST-enabled actor is unable to respond to new requests in the meantime, even though I could run lots of operations concurrently ...

How to better transfer objects between Jersey restful enabled classes to JSP pages

I have this : public class Base { @GET @Path("/news/{page_number}") public Viewable news(@PathParam("page_number") int pageNumber) { NewsParams news_params = new NewsParams(); news_params.setPageNumber(pageNumber); return new Viewable("/news.jsp", news_params); } } and the news.jsp is : ...

How to customize namespace prefixes on Jersey(JAX-WS)

Hi, when serializing my resources on Jersey, I want to use namespaces in some cases. Is there any way to customize the namespace prefixes on jersey? Default: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <order xmlns:ns2="http://www.w3.org/2005/Atom"> <price>123</price> <ns2:link rel="duh" href="/abc/123"/> <ns2:l...

Is it possible to configure JAX-RS method with variable number of URI parameters?

Hi, is it possible to configure GET method to read variable number of URI parameters and interpret them either as variable argument (array) or collection? I know query parameters can be read as list/set but I can't go for them in my case. E.g.: @GET @Produces("text/xml") @Path("list/{taskId}") public String getTaskCheckLists(@PathPara...

Xml file not generated on calling to Rest Api s

Hi , i am new to Jersey in calling Rest Api I created a New Blog Bean project in NetBeans and added the Jersey libraries as package blogbean; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfi...

Grizzly http server fails some request

Hi, I created a grizzly web server, to run my jersey application out of tomcat, to speed up tests. I'm a grizzly beginner, but looking through the net I put some code lines together, to make a grizzly web server up and running in less than a working day :) Unfortunately my class has some troubles on concurrent request, often one or mor...

JAX-RS Jersey - Howto force a Response ContentType? Overwrite content negotiation.

Jersey identifies requests by looking at the accept header. I have a request which accepts only text/* - How can i force the response to be for example application/json? @POST @Path("/create") @Produces(MediaType.APPLICATION_JSON) public MyResponseObject create() { return new MyResponseObject(); } If a request is directed to creat...