简体   繁体   English

Javax.persistance在TomEE中不可用

[英]Javax.persistance not available in TomEE

When running my Java EE app on TomEE I get the following error: 在TomEE上运行Java EE应用程序时,出现以下错误:

java.lang.NoClassDefFoundError: javax/persistence/NamedStoredProcedureQuery java.lang.NoClassDefFoundError:javax / persistence / NamedStoredProcedureQuery

There are no compile time errors when I build the app.I am developing in Eclipse and have Apache TomEE selected under targeted runtimes in the project properties, so that the project has access to Java EE. 生成应用程序时没有编译时错误。我正在Eclipse中进行开发,并在项目属性的目标运行 时下选择了Apache TomEE ,以便该项目可以访问Java EE。

As the project uses Hibernate I have the following jars in the WEB-INF\\lib directory (it's my understanding that these jars in turn use javax.persistence): 当项目使用Hibernate时,我在WEB-INF \\ lib目录中有以下jar(据我了解,这些jar依次使用javax.persistence):

  • hibernate-commons-annotations-4.0.4 休眠公地的注解 - 4.0.4
  • hibernate-core-4.3.5 休眠核心-4.3.5
  • hibernate-jpa-2.1 冬眠,JPA-2.1

I've seen a bunch of questions like this one detailing that the solution is to add the required JPA jar into the lib directory of the app and all will be well. 我已经看到了很多类似这样的问题,详细说明了解决方案是将所需的JPA jar添加到应用程序的lib目录中,一切都会很好。 But although that solution may work it sounds hacky to me, I want TomEE to manage the JPA libraries itself. 但是,尽管该解决方案可能行得通,但对我来说似乎有点棘手,但我希望TomEE自己管理JPA库。 It's a Java EE server so why doesn't it do this. 这是一台Java EE服务器,所以为什么不这样做。 Whats a clean solution? 什么是干净的解决方案?

@JB Nizet 's answer is the accepted solution: @JB Nizet的答案是公认的解决方案:

This class exists since JPA 2.1. 从JPA 2.1开始存在此类。 I guess your TomEE version only supports JPA 2.0. 我猜您的TomEE版本仅支持JPA 2.0。 And indeed, thehome page of TomEE says: "Java EE 6 Web Profile". 实际上,TomEE的主页上显示:“ Java EE 6 Web Profile”。 Java EE 6 includes JPA 2.0, not 2.1. Java EE 6包含JPA 2.0,而不是2.1。 – JB Nizet – JB Nizet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 验证javax.persistance注释? - Validating javax.persistance annotations? 如何在Hibernate / javax.persistance中映射一个具有多个表的类? - How to map one class with multiple tables in Hibernate/javax.persistance? TomEE sesison持久性存储不起作用 - TomEE sesison persistance storage not working javax.persistance.Entity无法导入? - javax.persistance.Entity not getting imported? MongoJack支持@ javax.persistance.Id不起作用 - MongoJack support @javax.persistance.Id doesn't work 在TomEE 8中的javax.ws.rs.container.ContainerRequestFilter中注入资源 - Injecting a Resource in a javax.ws.rs.container.ContainerRequestFilter in TomEE 8 第一次测试后,Arquillian TomEE嵌入了javax.naming.ConfigurationException - Arquillian TomEE embedded javax.naming.ConfigurationException after first test Javax-Persistance:实体没有使用 Java 记录的主键 - Javax-Persistance : Entity does not have a primary key using Java records TomEE:javax.servlet.ServletException:java.lang.NoClassDefFoundError:无法初始化类javax.ws.rs.core.UriBuilder - TomEE: javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class javax.ws.rs.core.UriBuilder javax.xml.xpath jar / src是否可用? - javax.xml.xpath jar/src available?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM