jersey

Jersey / ServletContext and resource loading on startup.

Hello, I'm kind of new in web development with Java. I am developing a web service and I've chosen REST / Jersey for it. I want to init some stuff on startup of the service and to keep them all along the life of the service. First question : Is the constructor of the Jersey Servlet a good place to do that ? Basically, what I want t...

@Path and regular expression (Jersey/REST)

Hi there! I'm using Jersey in a REST project and I'm needing to use regular expression. Digging about it is simple like: @Path("/resources) public class MyResource { @GET @Path("{subResources:.*}") public String get(@PathParam("subResources") String subResources) {...} } But, doing like this, the method is getting the requ...

jersey webservice not returning jsonp

Hi I am trying to create a webservice that will return jsonp. At the moment it is only returning json Here is my code `@Path("/jsonp") public class JsonpWebservice { @GET @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) public JSONWithPadding readAllP(@QueryParam("jsoncallback") @DefaultValue("jsoncallback") String js...

Enable Grizzly to perform JaaS simple HTTP AUTH

How can I make Grizzly HTTP server allow JaaS for simple HTTP AUTH? I can't see any code/sample out there: There's another post here in StackOverflow that directly assumes that jaaS is available in Grizzly, but doesn't explain how to add it. ...

Digest authentication with Jersey Client

Hi there, I have written a REST web service with Jersey Server (that totally rocks !). I am now developing the client part of it, with Jersey Client as well. On the server side, I have chosen a DIGEST authentication, because I personally think that BASIC authentication is an heresy that should be marked as "DEPRECATED" in our heads. U...

XML strings in JAXB

I have a JPA entity class mimicking a table. Something like this: @XmlType(name="MyClassElementType") public class MyClass { String name; String xmlDesc; public MyClass() {} @XmlElement String getName() { return name; } void setName(String name) { this.name = name; } @XmlElement String getXmlDesc() { r...

Tomcat Restart automatically Web Application on startup, after error

Hi, I've a big trouble on tomcat. Before explaine, let me tell is the first time I see something like this... I'm building an application using JPA on Hibernate, Spring 3.0 and Jersey REST Framework. When using glassfish, everything works fine, but deployng the same application on tomcat, I registered the following error code: GR...

How to return an ArrayList from a database query?

I am querying a database for a web service using the Jersey JAX-RS. I can return a single row as XML or JSON, but I can't figure out how to return multiple records. Do I use an ArrayList? If so how? Does anyone have an example of how to do this? Thanks ...

passing request params from jQuery to jersey service using json

hi, im trying to POST (cross domain) some data to a jersey web service and retrieve a response (a GenericEntity object). The post successfully gets mapped to my jersey endpoint however when i pull the parameters from the request they are empty.. $ .ajax({ type: "POST", dataType: "application/json; charset=utf-8", url: jersey...

Using @Context, @Provider and ContextResolver in JAX-RS

I'm just getting acquainted with implementing REST web services in Java using JAX-RS and I ran into the following problem. One of my resource classes requires access to a storage backend, which is abstracted away behind a StorageEngine interface. I would like to inject the current StorageEngine instance into the resource class serving th...

Jersey / JAXB: Unmarshaling of empty json array results in a list with one item where all fields are set to null

I have a really simple rest web service returning a list of questions. This code works as expected when the number of questions returned are greater than zero. But if the server returns an empty json array like [], JAXB creates a list with one question instance where all fields are set to null! I'm new to both Jersey and JAXB so I don'...

Jersey JAX-RS on Glassfish 3.0.1: Can I have an empty webapp element in my web.xml?

My understanding is that glassfish 3 is JEE6 compliant and jax-rs-aware, and that consequently I do not have to include the jersey servlet container and mapping in my web.xml file. Here's what I was hoping my web.xml could look like <webapp> </webapp> That doesn't work though, as I get 404's when I try to hit my jax-rs path-anotated ...

JAXB with namespace unmarshalling (using Jersey from REST service)

I'm trying to unmarshal a simple xml document from a public api from Convio. I'm not getting any compiler errors with the following code, but it won't produce a result either. The values are null. If I remove the schema and namespace items from the xml document and remove the namespace attribute from the POJO then it will run just fine. ...

How Jersey extracts generic type from Collections to invoke javax.ws.rs.ext.MessageBodyWriter#writeTo()?

In a Rest Service using the JAX-RS specification, I can define a generic service like @GET @Path("something") @Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) public List<MyPojo> getMyPojoList() { ... } Something magic happens in Jersey because when invoking javax.ws.rs.ext.MessageBodyWriter#writeTo(T t, ...

is possible to combine: jersey + jetty + spring

Hi, I'm trying to create a webserver embedding jetty (rather than J2E) , and map my servlets RESTfully, using jersey. I'm using spring for dependency injection, and mapping the servlets as beans However, when I try to make an HTTP req to the mapped servlets, i get error 500- server error, or 404, page not found. I'm not sure if i'm doin...

Java Jax-rs Jersey Spring: How to create a MessageBodyReader and MessageBodyWriter for Multipart

I have an application with Java/Jersey/Spring2.5/Jboss. In one of the service response, I want to use Multipart. How can I send a Multipart response? How should I implement the MessageBodyReader and MessageBodyWriter? I'm wrapping a byte[] in the Multipart. I have to display this on a JSP. Before this, I was using a JAXB object to wrap ...

How to configure a custom Spring PerformanceInterceptor for a Resource Method

I'm using Java/Spring/Jersey v1.0.3/Jboss. I want to configure a PerformanceInterceptor for my resource. How can I do this? Let's say I have the following configuration: <bean id="service" class="com.services.RESTfulService" /> <bean name="servicePointcut" class="org.springframework.aop.support.NameMatchMethodPointcut"> <property name="...

Pass List to RESTful webservice

Is there a way to pass a list to RESTFul web service method in Jersey? Something like @PathParam("list") List list? ...

Jersey - JaxB: Should I send the stack trace for Bad XML?

For any bad XML, by default the Jersey - JaxB throws the following: Method failed: HTTP/1.1 400 Bad Request My client(REST ws user) is insisting on giving a full blown info about the problem in the XML. Is it wise to give the stack trace of the problem in the XML? ...

Protocol Buffers MIME problem

Help! Trying to implement Protocol Buffers via Rest (Jersey), but get this exception. class com.util.ProtobufMessageBodyReader class com.util.ProtobufMessageBodyWriter Jul 6, 2010 3:43:37 PM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-9102 Jul 6, 2010 3:43:37 PM org.apache.catalina.startup.Catali...