Glassfish 3.1.1 上的 OpenJPA 2.1.1 增强问题

发布于 2024-12-02 13:51:57 字数 2157 浏览 1 评论 0原文

我的问题是这个例外:

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中以及通过网络定义-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 仍然无法增强我的实体!

My problem is this exception:

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: "

I'm trying to get an very simple java application with jsf and jpa running, but there seems to be a problem with the enhancement of my entities. As far as I know, tries OpenJPA to enhance my entities at runtime, which are listet in the persistence.xml, however there is no agent to do this. The keyword for this is: Enhancing at Runtime, right?

I thought the enhancement will automatically done by the application server at deployment? How can I configure this?

My exactly environment:

  • Glassfish 3.1.1
  • Derby, which is integrated in Glassfish
  • OpenJPA 2.1.1
  • Mojarra JSF 2.1.3

Update #1:

After some comments I've added the following lines to my persistence.xml:

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

It works now, but OpenJPA throw this warning:

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.

I think this can't be the solution.

Update #2:

Refer to fvu's answer, I've tried to define the -javaagent jvm parameter in the domain.xml and over the web admin console. After a restart appeared the problem again.

Update #3:

Refer to update #2, I've played a bit around. There must be thrown an error, when the -javaagent parameter is used, but the file is missing, right?. Yes, there it is:

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

If I copying the agent to this location, this error doesn't appear, but openjpa could still not enhance my entities!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

向日葵 2024-12-09 13:51:57

如果您仍然遇到问题...我强烈建议您咬紧牙关并设置

If you're still having issues... I'd highly recommend biting the bullet and setting up build time enhancement. You'll be much happier in the long run if you get that going.

装迷糊 2024-12-09 13:51:57

一些想法:

  • 添加 Java 代理以增强 GF 的 JVM 选项,请参阅此链接有关如何安装 javaagent 和 OpenJPA 文档 5.2.3(在运行时增强)的示例。在我看来,这尽可能地模拟桌面应用程序中的增强器激活。

然而,当我阅读 OpenJPA 文档的第 5.2.4 章时,它可能能够自动选择正确的增强器。尝试将 openjpa.jar 复制到域的库目录,并检查服务器重新启动后会发生什么情况。

A couple of ideas:

  • add the Java agent for enhancement to GF's JVM option, see this link for an example of how to install a javaagent and OpenJPA's doc 5.2.3, enhancing at runtime. That emulates enhancer activation in desktop apps as closely as possible IMO.

However, when I read chapter 5.2.4 of the OpenJPA docs it might be capable of picking up the correct enhancer automatically. Try copying openjpa.jar to the domain's library directory, and check what happens after a server restart.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文