Hello! Happy tomee user here, but using eclipselink.
While developing a Javafx app theses days I started using Eclipselink because 
I'm familiar with.
So far so good! The app are working with eclipselink and now, feeling inspired 
by this post https://rmannibucau.metawerx.net/openjpa-jakarta-tips.html, I've 
been trying to setup OpenJPA for two days.
First, I could not run the app anymore. OpenJPA throws this exception:
[code]
Caused by: <openjpa-3.2.0-r6f721f6 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: "
com.gilbertoca.corretagem.model.Carteira
com.gilbertoca.corretagem.model.Agente
com.gilbertoca.corretagem.model.Ativo
com.gilbertoca.corretagem.model.AliquotaImposto
com.gilbertoca.corretagem.model.OperacaoPk
com.gilbertoca.corretagem.model.CarteiraPk
com.gilbertoca.corretagem.model.Operacao
com.gilbertoca.corretagem.model.Inventario
com.gilbertoca.corretagem.model.Nota".
        at 
org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:117)
        at 
org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:314)
        at 
org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:240)

[/code]

After that, I configurared the openjpa-maven-plugin to run in the compile 
phase. The compilation results in the title for this post:

[code]
[INFO] --- openjpa-maven-plugin:3.2.0:enhance (enhancer) @ nota-corretagem-fx 
---
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.types.MercadoTipoEnum".
[INFO] Enhancer running on type "class com.gilbertoca.corretagem.model.Ativo".
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.Inventario".
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.Operacao".
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.OperacaoPk".
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.Carteira".
[INFO] Enhancer running on type "class com.gilbertoca.corretagem.model.Nota".
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.types.HorarioEnum".
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.types.MercadoEnum".
[INFO] Enhancer running on type "class com.gilbertoca.corretagem.model.Agente".
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.types.AtivoEnum".
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.types.ModalidadeEnum".
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.CarteiraPk".
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.AliquotaImposto".
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.Inventario$1".
[INFO] Enhancer running on type "class 
com.gilbertoca.corretagem.model.types.OperacaoEnum".
[INFO] No metadata was found for 2 classes; they have been enhanced as 
persistence-aware. If you intended for any of these classes to be 
persistence-capable, then this means that OpenJPA could not find any metadata 
for those classes. This can happen if the directory containing your metadata is 
not in your CLASSPATH, or if your metadata files are not named properly. See 
the documentation on metadata placement for more information. Persistence-aware 
classes: [class com.gilbertoca.corretagem.model.CarteiraPk, class 
com.gilbertoca.corretagem.model.Inventario$1]
[/code]

Feeling brave runned the app again which stopped with other exception:
[code]
       at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native 
Method)
        at 
javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
        ... 1 more
Caused by: <openjpa-3.2.0-r6f721f6 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: "
com.gilbertoca.corretagem.model.CarteiraPk".
        at 
org.apache.openjpa.enhance.ManagedClassSubclasser.prepareUnenhancedClasses(ManagedClassSubclasser.java:117)
        at 
org.apache.openjpa.kernel.AbstractBrokerFactory.loadPersistentTypes(AbstractBrokerFactory.java:314)
        at 
org.apache.openjpa.kernel.AbstractBrokerFactory.initializeBroker(AbstractBrokerFactory.java:240)
        at 
org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:216)
        at 
org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:166)
        at 
org.apache.openjpa.persistence.EntityManagerFactoryImpl.doCreateEM(EntityManagerFactoryImpl.java:282)
        at 
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:201)
        at 
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:188)
        at 
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:178)
        at 
org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:64)
        at 
com.gilbertoca.corretagem.dao.DataSourceFactory.newEntityManager(DataSourceFactory.java:61)
        at 
com.gilbertoca.corretagem.dao.AgenteJpaDao.<init>(AgenteJpaDao.java:17)
        at 
com.gilbertoca.corretagem.AgenteController.<init>(AgenteController.java:56)

[/code]

The CarteiraPk is a simple class representing the Id of Carteira one, which is 
marked with @IdClass(CarteiraPk.class).
Looking for any tip ou help on google, found a lot of people complaining for 
this initial step to use OpenJPA - most of them give up, I think.
Eclipselink does not need this step, neither Hibernate (I've tried it as well 
and the app start up). I don't know how they do that magic!
So, I'm here looking for advice!

Regards, Gilberto!

Obs: 
openjdk-11 and OpenJPA 3.2.0

Reply via email to