Getting ClassNotFoundException org.eclipse.persistence.jpa.rs.resources.MetadataResource

柔情痞子 提交于 2019-12-12 06:16:17

问题


I'm trying to walk through the JPA-RS tutorials like:
http://java.dzone.com/articles/introducing-eclipselink-jpa-rs or
http://www.eclipse.org/eclipselink/documentation/2.5/solutions/restful_jpa.htm

But after trying to deploy (using the maven and glassfish plugin) the application on my glassfish I get the following error stacktrace:

WebModule[/rest]Servlet /rest threw load() exception java.lang.ClassNotFoundException: 
org.eclipse.persistence.jpa.rs.resources.MetadataResource at 
org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1783) at
org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633
) at org.eclipse.persistence.jpa.rs.service.JPARSApplication.(JPARSApplication.java:62) at 
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at 
...

I do not find the class in my imported dependencies:

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>7.0</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>eclipselink</artifactId>
    <version>2.5.0</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0.1</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>org.eclipse.persistence.jpars</artifactId>
    <version>2.6.0</version>
</dependency>

By searching for that error, I getting no one who is sharing the same problem with me. Are you able to help me by getting an solution for that problem? Tell me if you need more conext/background information about the project.

Kind regards.


回答1:


Use your eclipselink dependencies of the same version: either both eclipselink and org.eclipse.persistence.jpars should be 2.6.0 or both should be 2.5.0.

When using 2.6.0 org.eclipse.persistence.jpa.rs.resources.MetadataResource is in the eclipselink.jar



来源:https://stackoverflow.com/questions/30094535/getting-classnotfoundexception-org-eclipse-persistence-jpa-rs-resources-metadata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!