jersey

Disabling client cache from Jetty server for REST requests

I have a REST Java server implemented with Jersey running on Jetty. It seems that certain browsers (IE7) internally caches all requests made to the server. What I would like to do is to send a certain HTTP header in the response from the REST server indicating the browser that it shouldn't cache that response, and so will query the ser...

JAX-RS / Jersey how to customize error handling?

I'm learning JAX-RS (aka, JSR-311) using Jersey. I've successfuly created a Root Resource and am playing around with parameters: @Path("/hello") public class HelloWorldResource { @GET @Produces("text/html") public String get( @QueryParam("name") String name, @QueryParam("birthDate") Date birthDate) { // ...

Some examples of Jersey use in Ant scripts?

I am very new to the Jersey framework, and most of what I am seeing on their documentation uses Maven tasks (which I don't have the time to get a degree in). Where can I find--outside of the Jersey documentation, if possible--some real-world examples using Jersey with Ant scripts? I've used NetBeans for making some examples, but I real...

How do I inject dependencies into resources with Jersey?

My initial look at Jersey suggested this was a nice framework that made it easy to create RESTful Java APIs. Unfortunately, since making the decision to use it (together with Grizzly), I've found it to be very poorly documented, consequently it is very hard to perform common tasks (that I'm sure are very easy once you know how). Anyway...

What is the best Java-way to create JSON/XML REST Web services that is similar to WCF?

I'm looking for a best way that is available for Java developers to implement REST services that will be communicating via JSON or XML. I'm looking for production-ready products. I know that Spring 3.0 is coming, but it's not done yet - no luck. Is Jersey the one? My application is hosted by Tomcat, uses Spring, Jettison and XStream....

Jersey in Tomcat+Spring environment can't find ComponentProvider. Why?

I've deployed Jersey on Tomcat and everything works perfectly (when I use the com.sun.jersey.spi.container.servlet.ServletContainer), but as soon as I change it to the com.sun.jersey.spi.spring.container.servlet.SpringServlet (according to all the tutorials I can find), I get a nasty exception: Apr 19, 2009 5:07:35 PM org.apache.catalin...

jersey deployment

Hi, I have developed a jersy Resource class. Can someone please tell me how can i deploy it on a web/app server. Preferebly tomcat or jboss. Or a better question still, can jersey applications with only a resource class be deployed on a web/app server? If yes, How? Adhir ...

How to initialize Jersey with a a specific resource instance with specific MessgeBodyReaders/Writers??

I'm trying to start Jersey on a preconfigured port/url with a preconfigured resource instance. I can't quite figure out how to correctly do it. Here is a snippet of a code. Help me, please, fill in the blanks: @Component @PerRequest @Path("/svc") @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Produces({MediaType.AP...

jersey security and session management

Hi, Is there a way for session management or security available programatically in Jersey specification. e.g. like a web-application session management. Or is transaction, session, security all handeled by the containor on which the jersey application is deployed. Adhir ...

What is the best way to write a test case for JERSEY web services?

I have a JAX-RS web service implemented with Jersey library and now I want to test it. In order to do that I'd like to host this service in my test by preinitializing it with mocked services. What is the best way to host such a service and execute the test calls? @Path("/srv") public class MyService { @GET public void action(@Con...

exception when invoking ehcache-server within embedded Jetty via Cargo: WebApplicationProviderImpl could not be instantiated

I'm working on a web application that uses a standalone ehcache server to cache certain data. The ehcache server is accessed via REST (as opposed to SOAP). For functional testing purposes, I need to run an embedded instance of the ehcache server. The echcache-server project itself does this for its own functional tests, using the Cargo ...

jersey integration with spring

I want to use Jersey 1.1 with spring 2.5. The exact thing that i need to do is write a interface which would be exposed as the service and implementation in a class that extends the interface. I cannot do it in applicationContext.xml, maybe because the XSD has changed. Could some one provide with a sample code/snippet/file where they h...

Exception handling / resource management in Jersey JAX-RS

I'm trying to manage a contended resource (as in: database session) while programming a RESTful web application in Jersey. Usually I'd write code like this: Session session = getSession(); try { doWork(); session.commit(); } finally { session.rollback(); // doesn't hurt after commit session.release(); // or whatever } Now with...

Problem with JERSEY and JAX-RS

I am new to RESTful Services. I am trying to deploy a simplest REST service using jersey, and JAX-RS, but i am getting this error, HTTP ERROR: 404 NOT_FOUND RequestURI=/hosting/demo/example Powered by Jetty:// Where i think i have done everything right, below is the code i am using for it. POM.XML (only pasting the part related to je...

Compatibility Issue of ASM 3.1 and HIbernate and JAX-RS

Hi, I have found out that "Hibernate cannot be combined with the reference implementation of JAX-RS." on the link http://lists.jboss.org/pipermail/hibernate-issues/2009-May/015628.html So i am unable to combine JAX-RS (jersey) with hibernate, does anybody know a work around for this ? ...

How to reuse Jersey's JSON/JAXB for serialization?

I have a JAX-RS REST service implemented using Jersey. One of the cool features of JAX-RS/Jersey is how easily a POJO can be turned into a REST service, simply by sprinkling a few Java annotations... including a trivially easy mechanism for translating POJOs to JSON - using JAXB annotations. Now, I'd like to be able to take advantage of...

How do I marshal nested lists as JSON using Jersey? I get an array of nulls or an array of one-element dictionaries containing an array.

I'm working on a project which uses Jersey to convert objects to JSON. I'd like to be able to write out nested lists, like so: {"data":[["one", "two", "three"], ["a", "b", "c"]]} The object I'd like to convert first represented data as a <LinkedList<LinkedList<String>>>, and I figured Jersey would just do the right thing. The above wa...

DWR like Javascript library for REST

Is there a Javascript library like DWR that can generate javascript stub for REST api. We are using Jersey/JSR-311 for REST on server and was wondering that instead of using libraries like Jquery or dojo if there is a library that can take a Rest class annotated using JSR311 annotations and create javascript stub like DWR does? ...

Jersey - Redirection Using Get Not Put, Causes Redirection Loop

Hello chaps, I'm working on a web app that uses Jersey. I'm trying to implement a get-after-post sort of thing using a URIBuilder and a seeOther response. The aim is to redirect to the same URI the browser is already on, but to force a GET. It works a bit like this: Request comes in via PUT PUT request processed SeeOther response retu...

Binding a JSON to a Java class using JAXB

I have the following JSON, where can be either true or false: {"flag1":<boolean value>, "flag2":<boolean value>} And I have tried to bind it to a Java class using Jersey and the following JAXB annotations: @XmlRootElement public class MyClass { @XmlElement(name = "flag1", type = Boolean.class) private Boolean flag1; @Xml...