jsf - Glassfish 3.1.1 上的 OpenJPA 2.1.1 增强问题

标签 jsf jakarta-ee jpa glassfish openjpa

我的问题是这个异常:

Caused by: <openjpa-2.1.1-r422266:1148538 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "

我试图获得一个运行 jsf 和 jpa 的非常简单的 java 应用程序,但我的实体的增强似乎存在问题。据我所知,尝试 OpenJPA 在运行时增强我的实体,这些实体列在 persistence.xml 中,但是没有代理可以执行此操作。关键字是:Enhancing at Runtime,对吧?

我认为增强会在部署时由应用服务器自动完成?我该如何配置?

我的确切环境:

  • Glassfish 3.1.1
  • Derby,集成在 Glassfish 中
  • OpenJPA 2.1.1
  • Mojarra JSF 2.1.3

更新 #1:

经过一些评论后,我将以下几行添加到我的 persistence.xml 中:

<property name="openjpa.DynamicEnhancementAgent" value="false"/>
<property name="openjpa.RuntimeUnenhancedClasses" value="supported" />

它现在可以工作了,但是 OpenJPA 抛出了这个警告:

SEVERE: 52  myApp  WARN   [http-thread-pool-8080(5)] openjpa.Enhance - Creating subclass for "[class myApp.model.entities.AbstractEntity, class myApp.model.entities.Post]". 
This means that your application will be less efficient and will consume more memory than it would if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead.

我认为这不是解决方案。

更新#2:

引用 fvu 的回答,我尝试在 domain.xml 和 Web 管理控制台上定义 -javaagent jvm 参数。重启后问题又出现了。

更新 #3:

请参阅更新#2,我玩过一些。使用-javaagent参数时,肯定会报错,但是文件丢失了,对吧。是的,就是这样:

Waiting for domain1 to start .Command start-domain failed.
Error starting domain domain1.
The server exited prematurely with exit code 1.
Before it died, it produced the following output:

Error occurred during initialization of VM
agent library failed to init: instrument
Error opening zip file or JAR manifest missing : /tmp/openjpa.jar

如果我将代理复制到此位置,不会出现此错误,但 openjpa 仍然无法增强我的实体!

最佳答案

如果您仍然遇到问题...我强烈建议您硬着头皮设置 build time增强。如果你坚持下去,从长远来看,你会更快乐。

关于jsf - Glassfish 3.1.1 上的 OpenJPA 2.1.1 增强问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7294906/

相关文章:

java - 从外部源加载 HTML 的 JSF 标记

jsf - 向页面 "head"方面添加新子项的自定义 JSF 组件

jsf - 在jsf页面中使用ckeditor

java - 如何使用 JPA+Hibernate 在 json 结果中包含连接列

hibernate - 选择的事务策略需要访问 JTA TransactionManager 或 Unable to build EntityManagerFactory

java - 选中项目时,selectManyCheckbox 元素不会复制到数组

java - 如何在 JBoss EAP 7.1 中排除 jackson 库而不排除 Resteasy

Java JPA 实现 - 如何读取/设置属性?

java - 使用 MongoDB 在 Java 中计算距离

java - merge如何避免LazyInitException?