Difference com.sun.jersey and org.glassfish.jersey - java

What is the difference between com.sun.jersey and org.glassfish.jersey?
Currently I have my REST service working on com.sun.jersey and I want to write tests, but I can't find a good tutorial for this (nothing seems to work). However, I can find good documentation about the org.glassfish.jersey tests.

The only difference between com.sun.jersey and org.glassfish.jersey is that the package name was changed because Jersey team is now part of another organization (Glassfish).
Versions below 2 use package com.sun.jersey, versions above 2 use org.glassfish.jersey.
And yes, there are some differences between 1.x and 2.x.

Related

Response.readEntity() missing in Jersey 2.17?

I'm getting crazy regarding JAX-RS 2 usage (Jersey 2.17). I migrated from JAX-RS 1.0 and some texts posted here are explaining to use response.readEntity(Class.class). But this method is missing in Jersey 2.17. Is its documentation outdated? How could I extract an entity from Response?
I found a problem in my pom.xml . It was a outdated glassfish-embedded-web with a conflict in Jersey. I removed it and now it's working fine.
I am using jersey-server, jersey-client, jersey-container-servlet-core, all 3 of version 2.23.1. Please make sure you have imported javax.ws.rs-api version 2.0.1 or later. I had not imported it in my build.gradle. After importing, I was able to see readEntity method for my Response class.

Resources linking in Dropwizard / JAX-RS 1.x (JSR 311)

I've got a problem with resources linking in Dropwizard. With JAX-RS 2.0 we've got magical javax.ws.rs.core.Link class which with it's builder can do almost all the work for you. Unfortunately Dropwizard 0.7.1 doesn't depend on the new 2.0 API, but on the old javax.ws.rs:jsr311-api API, which can't handle linking. Or can it? This is the problem I want to solve with Dropwizard. I probably have two ways to do it and I don't know if any of them is valid:
Option 1: I add JAX-RS 2.0 dependency to my project. Voila! I've got Link. But the problem is, that it doesn't work well with old implementations from Jersey - I got AbstractMethodException from UriBuilder, which apparently changed from version 1 to 2. So the answer is to supply new implementations. Can I do it? If yes, than how can I do it? Will new implementations work with dropwizard well?
Option 2: I can just add some other resource linking to dropwizard. Is there some other linking standard/library? I can't use jersey-declarative-linking because it mixes representations with the resources (the linking takes place in representations), and I want my representations not to know a thing about resources layer. So is there another linking standard for Dropwizard, Jersey and JAX-RS 1?
I've finally found an answer to my question.
Option 2 was a dead end. There was no other jax-rs-2-like linking library to either dropwizard or jersey itself.
Option one also was hard to do, but fortunatelly yesterday dropwizard released version 0.8.0-rc1 of their framework, which depends on jersey 2, which is the implementation of JAX-RS 2.0. So for all of you that want to have HATEOAS in dropwizard, version 0.8.0 is for you.

jackson 2.4 looking for old class when deserialising

i am developing a restful service with tomcat 7 and jdk 1.6. for json handling i am using jackson 2.4.2 and it works fine except when i try and deserialise an object (that it has no trouble serialising).
the error is:
java.lang.ClassNotFoundException: org.codehaus.jackson.JsonFactory
which is the place where jackson 1.x kept that particular class. my jackson 2.4.2 has it at
com.fasterxml.jackson.core.JsonFactory
i have no idea as to why it is trying to link the old class. i never used jackson 1.x.
what i use:
asm-3.3.1
commons-io-2.4
jackson-core-2.4.2
jackson-databind-2.4.2
jersey-bundle-1.18
mysql-connector-java-5.1.27
and
com.fasterxml.jackson.annotation
which i have taken from github. what library could be trying to import the old jackson module? any help would be much appreciated.
The issue certainly comes from trying to use Jackson 1.x ObjectMapper and missing underlying JsonFactory for 1.x. Since these come from difference jars (jackson-mapper-asl vs jackson-core-asl), it is likely that somehow one is missing.
Now, since you are not directly using Jackson 1.x, question is who is: perhaps jersey is relying on 1.x?
So there are two related questions: (a) if Jackson 1.x is needed, to bring in core jar as well, or (b) how to remove use of Jackson 1.x altogether.
Note that technically it is quite possible to use both 1.x and 2.x versions of Jackson, since 2.x was specifically designed to be able to co-exist. This to make upgrades easier, and allow gradual (component-by-component) upgrading.

Use Spring module without using Spring and Maven?

I'm currently working on a project that involves building a REST api using JavaEE. The setup of the project is Tomcat, Hibernate, Wink and Jackson Json for the different json-views. At the moment the unit testing of the rest resources is very poor, we've written custom classes that using introspection find the method that corresponds to a given resource but it is getting in our way (all the workarounds that we need to do in order to execute a simple unit test). I did a little research and found this.
My question is how to "install(add)" the MockServletInvocationTest class and its dependencies to the project? We're not using Maven, nor Spring. Is there a way to use Spring modules (I think this mock class is in the Spring test-module) outside Spring and if yes, how?
I found a solution, so for those who are interested: just add the following jars to your WebContent/WEB-INF/lib:
spring-test-xx.jar
spring-core-xx.jar
wink-component-test-support-xx-incubating.jar
commons-logging-xx.jar
And everything workds fine.

Changes done from Spring 2 to Spring 3

Recently while I was upgrading a project in spring 2.5.6 to spring 3.0.5, happened to know that some libraries aren't there anymore and some were renamed like spring-agent to spring-instrument...
Is there any site or a resource to refer to know these sort of changes done in migrating from spring 2 -3 ?
Yes, for most purposes, the Spring Upgrade Guide should provide you with what you need. In particular, check section 2.5 and 2.6 on the new packaging model.
If you are looking for a class that appears to be no longer available, try searching for it with FindJar. Some utility classes have been moved to another packages.

Categories

Resources