jersey

Jersey Consumes XML post

I want to make a Post to Jersey Rest service. What is the standard way of doing this? @Post @Consumes(MediaType.Application_xml) public Response method(??){} ...

System wide adapter in Jersey?

I'm trying configure a "system wide" custom javax.xml.bind.annotation.adapters.XmlAdapter for the java.util.Locale type in Jersey. It's easy enough to use @XmlJavaTypeAdapter on classes I control but that's not always the case (3rd party code that I can't annotate). It seems like it would be a pretty common problem but I can't find any...

JAX-RS (Jersey) custom exception with XML or JSON

I have a REST service built using Jersey. I want to be able to set the MIME of my custom exception writers depending on the MIME that was sent to the server. application/json is returned when json is received, and application/xml when xml is received. Now I hard code application/json, but that's making the XML clients left in the dark....

Is there any way to override or update Jersey's Jackson version?

We're trying to use Jackson 1.5 to take advantage of some of the polymorphic handling it offers, but it appears that Jersey brings along it's own outdated version of Jackson (1.1.1). When testing Jersey serialized JSON, we get different results than when we serialize by hand in unit tests. {"id":"40","ticketProps":[{"id":"28","field":{...

jersey restful webservice tomcat version

Hi, I want to write a simple restful webservice. As it would be as simple as accessing data from / to the database, I am planning to use tomcat & not any heavy application server. I have existing tomcat 5.5 setup. Which Jersey version would be compatible with tomcat 5.5 & java 1.5? ...

how do I implement a basic java field in a jersey annotated class?

Hi, trying to get the hang of Jersey With a very basic example. Say I have an interface: public interface MyApp { String getName(int id); } and a class to be mapped with jersey: @Path("/app/{id}") public class MyServlet { private MyApp myApp; @GET @Produces("text/plain") public String getName(@PathParm("id") int id) ...

Passing the URI Path to the JAX-RS Providers

I recently implemented a Jersey JAX-RS Rest service. I created a JIBX provider that allows one to unmarshal and marshall between XML and Java types. I would like to also version my service by specifying the version in the URL path. Versioning would include the version of message binding used to marshal and unmarshall the Java types. ...

Why are names returned with @ in JSON using Jersey

I am using the JAXB that is part of the Jersey JAX-RS. When I request JSON for my output type, all my attribute names start with an asterisk like this, This object; package com.ups.crd.data.objects; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlType; @XmlType public class ResponseDetails { @Xm...

Tomcat not responding jersey request

Hi folks, I am facing one problem while writting webservice which will returns json string.I am sending jersey request to tomcat server which is returning json string at first time which is fine but after that if I send another request then it is not responding me.But I can see all the values of json string into logs which I spec...

JAX-RS using exception mappers

Hello, I have read that I can create an implementation of javax.ws.rs.ext.ExceptionMapper that will map a thrown application exception to a Response object. I've created a simple example which throws an exception if the phone length is greater than 20 characters when persisting the object. I am expecting the exception to be mapped to...

NoSQL and REST web-services

I understand that if you use SUN's Jersey REST implementation framework, you get the ability to use XML and JSON doc's interchangably. I've tried this in a simple REST service and it works just fine, marshalling XML or JSON to Java objects and back again without any problems. My Question is this..... Whats the simplest 'NoSQL' way to p...

Deploying Jersey 1.3 Web Service on Weblogic 9.2 or 10.1

Hello, I am having issues deploying my Jersey RESTful web service to weblogic 9.2 I followed a tutorial at http://www.vogella.de/articles/REST/article.html. The tutorial is for java 6 and tomcat 6 which it works fine for. However, I need to convert this to java 5 and tomcat 5.5 so that I can successfully deploy it on weblogic which use...

How to add client filter to dispatch in jersey?

How to add client filter to dispatch in jersey? I want to add gzip filter. I create dispatch object and invoke WS this way. Service svc = Service.create(qname); svc.addPort(qname, HTTPBinding.HTTP_BINDING, server + uri); Dispatch<Object> dispatcher = svc.createDispatch(qname, jaxbContext, ...

How can I make page scrolling trigger mouseover events?

When the mouse starts hovering over an element because of scrolling (either by wheel, or by keyboard scrolling), it does not trigger a mouseover event on the elements it is hovering (Chrome 6 on OSX). What would be an elegant way to trigger the mouseover event for the correct elements when scrolling? ...

Jersey (JSR311-Implementaion) & Redirections

Is there a way to redirect the user-agent in a Jersey Resource? in Spring MVC there's the "redirect:"-Syntax but I didn't find anything comparable in jersey's Viewable class. The only method i found working was using HttpServletResponse.sendRedirect(). Thanks! ...

What is the proper way to ensure EntityManager connections are closed?

There are 19 methods in our DAO layer, each is some variation of this: public TicketProp saveTicketProp(TicketProp prop) { EntityManager em = this.emf.createEntityManager(); try { em.getTransaction().begin(); prop = (TicketProp) em.merge(prop); em.getTransaction().commit(); return prop; } fina...

Jersey Viewable with status code

The JAX-RS implementation Jersey supports MVC style web applications through the Viewable class, which is a container for a template name and a model object. It is used like this: @GET public Viewable get() { return new Viewable("/index", "FOO"); } I wonder how a status code could be returned with this approach. The above would impl...

How to fetch client-side certificate in restful web service (Java & Jersey) without Servlets?

I want to access the "subjectDN" from the client-side certificate, i.e., fetch the user data (common name, email, etc) from the certificate, but am not interested in the authentication part. If I would use a servlet, I understand that I can read the certificate sent in the request header using something like (X509Certificate[])request....

Why would extending JerseyTest vs extending TestCase cause no tests to be found.

I am attempting to get the Jersey test framework working. We are building using maven 1.x. I've created the following testcase... public class SomeResourceTest extends JerseyTest { public SomeResourceTest () throws Exception { super(new WebAppDescriptor.Builder(PACKAGE_NAME) .contextPath(PATH).bu...

Using JAX-RS / Jersey with Freemarker templates

There are examples on the web showing how to use the JAX-RS implementation Jersey with custom template engines like FreeMarker. But these examples are looking a bit improvised or dated. There is also one example relying only on JAX-RS and not Jersy specific classes. Is there a mature ViewProcessor implementation for FreeMarker or do I ha...