5

I am using Eclipse Luna (versions 4.4.2) and Glassfish 4 to build a REST web-app using JAX-RS.

The following piece of code, which is just a very simple post to the REST api that was previously working just fine, has started throw a very strange error:

@POST
public Response addToWatchlist(WatchlistEntry watchlistentry)
{
    return Response.ok(watchlist_service.addToWatchlist(watchlistentry).toString()).build();
}

The error is below:

Warning: StandardWrapperValve[Jersey Web Application]: Servlet.service() for servlet Jersey Web Application threw exception
java.lang.ClassNotFoundException: javax.xml.parsers.ParserConfigurationException not found by org.eclipse.persistence.moxy

All I have been able to find out about this is this webpage: https://java.net/jira/browse/JERSEY-2888

One of the comments says this has been fixed in EclipseLink 2.6.1 and Jersey 2.19.

I am pretty new to using MAVEN and eclipse - assuming the above is correct, how do I get my Maven Project in Eclipse to update the Jersey version? Also how do I update the EclipseLink version? Their site only seems to have version 2.6.0 available: http://www.eclipse.org/eclipselink/#download

I assume all this can be done through eclipse itself?

All help appreciated!

EDIT 1: It seems like eclipselink 2.6.1 has been released on Oct 15th 2015, as you can see here: http://www.eclipse.org/eclipselink/releases/

However, as you can see here, it doesn't seem to have been incorporated into eclipse for "help -> update software": http://download.eclipse.org/rt/eclipselink/updates/

Which is highly annoying.

I am building my REST website, and no PUT or POST will work because of this error.

Does anybody know how to get 2.6.1 working? I am using a Maven jersey-quickstart-webapp Project.

This bug is a royal pain in the face.

EDIT 2: I've got a hack working today. When I check programmtically what version of eclipselink is being used at runtime like below, it tells me it is version 2.6.1, even though the bug remains:

Class<?> myClass = Class.forName("org.eclipse.persistence.Version");
Method myMethod = myClass.getMethod("getVersion");
String version = myMethod.invoke(null).toString();
System.out.println("version = " + version);

In a related question (How to find what version of EclipseLink my Eclipse Project is using?) I found out how to find the actual jar files glassfish is using for eclipse. They are in the glassfish/modules directory. Inside the org.eclipse.persistence.core.jar file has will be a readme.html which tells you the version of eclipselink that glassfish is using. For me it was 2.6.

I manually updated the org.eclipse.persistence.core.jar and the org.eclipse.persistence.moxy.jar file with the latest versions from the maven site. While this is quite hacky, as I don't know what else is effected by doing this, it does get over this problem. If I find out the correct way to do this, I will write an answer below, for all and sundry.

Community
  • 1
  • 1
Tom O'Brien
  • 1,741
  • 9
  • 45
  • 73
  • I'm pretty sure the updates game me 2.6.1 (but not 2.6.2) when I tried them in Feb-2016. – K.Nicholas Mar 04 '16 at 16:38
  • Yeah - when I try and see by using code in my project to see what version of eclipselink it is using, it says 2.6.1. But when I check the actual org.eclipse.persistence.core.jar in the glassfish/modules directory the readme.html says 2.6. And I still have the error occuring! – Tom O'Brien Mar 04 '16 at 16:47
  • 1
    Sure, the updates in Eclipse are not the same as the version that Glassfish may be using. – K.Nicholas Mar 04 '16 at 17:14
  • I found the answer - by updating the glassfish eclipselink jars. Thanks for the help Nicholas. – Tom O'Brien Mar 04 '16 at 21:08

4 Answers4

2

Going through the Jersey JIRA and eclipse link website it seems like Eclipse link 2.6.1 is still under development i.e. not yet released. That's why its not available for download.

To use an updated version of Jersey in maven you need to give depending to the newer version 2.19 in your pom.xml.

But, since eclipse link 2.6.1 is yet to be released, even if you use newer version of Jersey it might be of little use. But still you can give it a try.

Dhruv Rai Puri
  • 1,335
  • 11
  • 20
  • I've updated the jersey version, but that don't make any difference. When the new version of eclipselink comes out, how do i update it? Does eclipse do it automatically? – Tom O'Brien Oct 14 '15 at 16:10
  • I doubt that automatic update is there. You can check for updates from 'marketplace' inside Eclipse using this link http://download.eclipse.org/rt/eclipselink/updates/ . Currently its showing 2.6.0 as latest. – Dhruv Rai Puri Oct 14 '15 at 16:42
2

To update version of jersey, find the following dependency and update the value of version tag in your pom.xml file

<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-server</artifactId>
    <version>2.22.1</version>
</dependency>
Linh Nguyen
  • 221
  • 2
  • 8
2

Which server are you deploying your project into? I've had A LOT of problems with Glassfish 4.1.1 (incluiding that error). I downgraded to 4.1 and everything runs fine. It may be due to a problem with 4.1.1 newest modules (jars incluided in the server). I hope it helps. Its not the best solution but for me was a temporary workaround 'till I find which modules are failing.

Bisonfan95
  • 327
  • 1
  • 2
  • 11
  • Hi Bisonfan95 - I'm pretty new to glassfish - how do i go about downgrading the version - can't seem to find anything online telling me how to go about this... Tom – Tom O'Brien Nov 11 '15 at 20:49
  • Just download an older distribution. I use netbeans and I can download any distribution from the wizard when setting up my project. If Eclipse doesn't have the option just go to the official glassfish site and search for an older distribution. Cheers :D – Bisonfan95 Nov 13 '15 at 04:21
  • Oh and Obviously configure the project so it deploys on the new older Glassfish you downloaded ehn you Build and Run it :D – Bisonfan95 Nov 13 '15 at 04:23
1

The problem was solved by updating the version of eclipselink that glassfish was using. Eclipse updated it's version, but glassfish needs it's own update. The list of jar files that need to be placed in the glassfish/modules directory is given in this answer: How to change EclipseLink in GlashFish 4.0?

Community
  • 1
  • 1
Tom O'Brien
  • 1,741
  • 9
  • 45
  • 73