问题描述
我的问题是这个例外:
造成者:< openjpa-2.1.1-r422266:1148538非致命用户错误> ; org.apache.openjpa.persistence.ArgumentException:这个配置不允许运行时优化,但是下面列出的类型在编译时或者在类加载时没有使用javaagent增强:
我试图用jsf和jpa运行得到一个非常简单的java应用程序,但似乎存在增强我的实体的问题。我知道,尝试OpenJPA在运行时增强我的实体,这些实体在 persistence.xml
中侦听,但是没有代理可以执行此操作。关键字为:在运行时增强
,对吗?
我认为应用服务器在部署时会自动完成增强功能吗?配置这个?
我确切的环境:
li>
更新#1:
在添加了一些评论后,我在 persistence.xml
中添加了以下几行:
< property name =openjpa.DynamicEnhancementAgentvalue =false/>
< property name =openjpa.RuntimeUnenhancedClassesvalue =supported/>
现在可以使用,但OpenJPA会发出这样的警告:
SEVERE:52 myApp WARN [http-thread-pool-8080(5)] openjpa.Enhance - 为[myApp.model.entities.AbstractEntity myApp类创建子类.model.entities.Post]。
这意味着您的应用程序效率会降低,并且会消耗比运行OpenJPA增强器更多的内存。此外,对于使用字段访问类型的一对一和多对一持久属性,延迟加载将不可用;他们会被热切地加载。
我认为这不可能是解决方案。
更新#2:
请参阅fvu的答案,我试着定义 -javaagent
jvm参数以及通过Web管理控制台。重新启动后出现问题。 domain.xml
中的
更新#3: 更新#2,我玩了一下。当使用 -javaagent
参数时,必须抛出一个错误,但文件丢失了,对吧?是的,它是:
等待domain1启动。命令启动域失败。
起始域domain1错误。
服务器提前退出并退出代码1.
在它死亡之前,它产生了以下输出:
VM初始化期间发生错误
代理程序库无法启动:instrument
打开zip文件或JAR清单时缺少错误:/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!
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.
这篇关于GlassFish 3.1.1上的OpenJPA 2.1.1增强问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!