jersey

Hibernate lazy loading + Jersey REST = eager loading?

I'm developing a Client-Server-Application with Hibernate as persistence layer and Jersey REST for network communication. Given a user with roles: when I want to display all users in the client, I don't want the roles to be loaded by Hibernate and I don't want them to be sent over the network when I want to modify the user's roles, I...

Add method comment with Jersey

hi, We've been using Jersey for our webservice and it's been great and straightforward. Is there a way to add a small description comment within a method definition (maybe using an annotation like @Description): @GET @Path("/schema/classes/") @Produces( { APPLICATION_RDF, TEXT_N3, APPLICATION_JSON }) @Description("Lists all ontology cl...

Setting Jersey to allow caching?

I have the following returned from a Jersey @GET method. It works, fine but always includes the No-cache header. I'd like to allow the client to cache this data since it rarely changes. ResponseBuilder rb = Response.ok(c); CacheControl cc = new CacheControl(); cc.setMaxAge(60); cc.setNoCache(false); return rb.cacheContro...

Jersey, Spring, Tomcat and Security Annotations

I need to secure a simple jersey RESTful API in a Tomcat 6.0.24 container. I'd like to keep the authentication with Basic Authentication using the tomcat-users.xml file to define the users and roles (this is for now, like I said its small). Now, for authorization I'd like to be able to use the JSR 250 annotations like @RolesAllowed, @Pe...

JAX-RS @PathParam How to pass a String with slashes, hyphens & equals too

I am new to JAX-RS and I am trying to use Jersey to build a simple RESTful Webservice. I have 2 questions. Please clarify these: I am trying to have my simple webservice like this URL http://localhost:8080/SampleJersey/rest/inchi/InChIName The InChIName is a string like this InChI=1S/C9H8O4/c1-6(10)13-8-5-3-2-4-7(8)9(11)12/h2- 5H,1H...

How to get jersey logs at server?

I am using jersey for a REST WS. How do I enable jersey logs at server side? Long story: I get a clientside exception - but I don't see anything in tomcat logs [It doesn't even reach my method]. Since the stack trace is saying "toReturnValue" it did get something from server. But I don't know what the server said. Exception in thread ...

Using Jersey Client inside EJB 3 stateless session bean on Weblogic

Hi, I am using Jersey client inside a EJB 3 stateless session bean. I can deploy the EJB project on Weblogic 11g. But when I try to look up the bean from a JSP, I get the following error javax.ejb.EJBException: EJB Exception: ; nested exception is: java.lang.NoClassDefFoundError: com/sun/jersey/api/client/Client; nested exception is...

Google AppEngine + Local JUnit Tests + Jersey framework + Embedded Jetty

I use Google Appengine for Java (GAE/J). On top, I use the Jersey REST-framework. Now i want to run local JUnit tests. The test sets up the local GAE development environment ( http://code.google.com/appengine/docs/java/tools/localunittesting.html ), launches an embedded Jetty server, and then fires requests to the server via HTTP a...

How to pass a very long string/file into RESTWebservice JAX-RS Jersey

Hello All, I wrote a RESTful webservice using JAX-RS API, that returns an XML string. I am trying to write another RESTful webservice that takes in this XML string, does parsing of it using DOM and extract particular things I want. The XML string happens to be very long so I do not want to pass it as a @QueryParam or @PathParam. Say I...

Looking for an example of a web application which provides and uses a JAX-RS web service for "all" logic.

I am looking for a good example of an open source web application that provides and uses a JAX-RS web service for all business logic calls. That is an application that doesn't only provide a RESTful interface for some parts of the system but also uses the same interface within the application. ...

Using implementation specific classes with standard JAX-RS

I want to use classes from a specific JAX-RS implementation together with the classes defined by Java EE, which are available on an application server. More specifically I want to use Viewable from Jersey but want to use the default Java EE deployment without wrapper servlet. Is it possible? How? Is it a good idea? Or would it be better...

SAXParseException when doing post with a XML file in jersey

Hi out there. I use jaxb in my REST application. I want to send an XML file via a web form. Then the java Class will unmarshal the InputStream. private void unmarshal(Class<T> docClass, InputStream inputStream) throws JAXBException { String packageName = docClass.getPackage().getName(); JAXBContext context = JAXBContext.ne...

curl POST to RESTful services

Hello All, There are a lot of questions on Stackoverflow about curl but I could not figure out what is that I am doing what I am not supposed to. I am trying to call a RESTful service that I had written using Jersey API and am trying to POST an xml string to it and I get HTTP 415 error which is supposed to be a Media Type error. Here i...

Using Jackson as Jersey client serializer

Is it possible to use Jackson as the serializer/marshaller for JSON data instead of JAXB when using Jersey Client API? If so how to configure it? ...

hibernate fail mapping two tables

Hi guys, I'd like to understand how it is possible: Until I was working with one table everything worked fine, when I have mapped another table it fails as shown below: Glassfish start INFO: configuring from resource: /hibernate.cfg.xml INFO: Configuration resource: /hibernate.cfg.xml INFO: Reading mappings from resource : hibernate_ce...

Unable to set cookie in response header (newcookie doesn't show in external browser) : Jersey jax-rs in eclipse galilio

I am trying to set a session cookie from server side : import javax.ws.rs.core.NewCookie; import javax.ws.rs.core.Response; public class Login { @POST @Produces("application/json") @Consumes("application/json") public Response login (String RequestPacket){ NewCookie cookie=null; CacheControl cc=new CacheControl(); cookie = Lo...

can rest framework like jersey be used in clojure instead of compojure

Hi , iam newbie to clojure, just curious as to can i use jersey REST api as REST webframework for clojure? all along i see people talking about compojure? if you can provide me any resource or reasoning that would be great Thank you ...

How to serialize Java primitives using Jersey REST

In my application I use Jersey REST to serialize complex objects. This works quite fine. But there are a few method which simply return an int or boolean. Jersey can't handle primitive types (to my knowledge), probably because they're no annotated and Jersey has no default annotation for them. I worked around that by creating complex ty...

Transaction-per-request and Jersey

I'd like to implement transaction-per-request in conjunction with Jersey resources. By that, I just mean I want a single place to manage transactions, something like: try { chain.doFilter(request, response); commitSession(); } finally { rollbackSession(); // no-op if already committed closeSession(); } In the past, I've...

Practical advice on using Jersey and Guice for RESTful service

From what I can find online, the state of the art for Guice + Jersey integration has stagnated since 2008 when it appears both teams reached an impasse. The crux of the issue is that JAX-RS annotations perform field and method injection and this doesn't play nicely with Guice's own dependency injection. A few examples which I've found d...