Class not found when using JAX-RS with Eclipse and Glassfish

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

The following code snippet, which is just a simple REST api entry that worked fine before, started 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 could find out about this is the web page: https://java.net/jira/browse/JERSEY-2888

One comment says this has been fixed in EclipseLink 2.6.1 and Jersey 2.19.

I'm new to using MAVEN and eclipse - assuming the above is correct, how do I get a Maven project in Eclipse to upgrade a version in Jersey? Also how to update the version of EclipseLink? Version 2.6.0 seems to be available on their site: http://www.eclipse.org/eclipselink/#download

I assume that all this can be done through eclipse itself?

All help appreciated!

EDIT 1: It seems that eclipselink 2.6.1 was released on October 15, 2015, as you can see here: http://www.eclipse.org/eclipselink/releases/

However, as you can see here, it does not seem to have been included in eclipse for โ€œhelp โ†’ update softwareโ€: http://download.eclipse.org/rt/eclipselink/updates/

This is very annoying.

I am building my REST site and no PUT or POST will work due to this error.

Does anyone know how to work 2.6.1? I am using the Maven jersey-quickstart-webapp project.

This mistake is a royal pain in the face.

EDIT 2: I have a hack working today. When I programmatically check which version of eclipselink is used at runtime, as shown below, it tells me that it is version 2.6.1, although the error 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 which version of EclipseLink my Eclipse project uses? ) I found out how to find the actual jar files that the glass chip uses to eclipse. They are located in the glassfish / modules directory. Inside the org.eclipse.persistence.core.jar file there will be readme.html, which indicates the version of eclipselink that the vitreous fish uses. For me it was 2.6.

I manually updated the org.eclipse.persistence.core.jar file and the org.eclipse.persistence.moxy.jar file with the latest versions from maven. Although this is pretty hacky as I donโ€™t know what else has been done by doing this, it is dealing with this problem. If I figure out the right way to do this, I will write the answer below, for everyone and everyone.

+5
source share
4 answers

The problem was resolved by updating the version of eclipselink that the glass fish used. Eclipse has updated its version, but glass fish has this update. The list of jar files that should be placed in the glassfish / modules directory is given in this answer: How to change EclipseLink in GlashFish 4.0?

+1
source

Passing through the JIRA Jersey and Eclipse website, it looks like the Eclipse 2.6.1 link is still under development, that is, not yet released. This is why it is not available for download.

To use the updated version of jersey in maven, you need to give depending on the newer version 2.19 in your pom.xml.

But, since the eclipse 2.6.1 link has not yet been released, even if you are using a newer version of Jersey, this may be of little use. But you can try.

+2
source

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

 <dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-server</artifactId> <version>2.22.1</version> </dependency> 
+2
source

What server are you deploying your project to? I had a lot of problems with Glassfish 4.1.1 (including this error). I dropped to 4.1 and everything is working fine. This may be due to a problem with 4.1.1 latest modules (banks included in the server). I hope this helps. This is not the best solution, but for me there was a temporary workaround until I find which modules fail.

+2
source

Source: https://habr.com/ru/post/1233712/


All Articles