Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] NoSuchMethodError on <init> with dynamic weaving

After some further reading I understand that this problem may be related to class loading.  In light of that I should mention, my project is deployed as a single WAR, all of the classes (EJB, entity, web, etc) are all deployed under WEB-INF/classes, and during unit tests, are all in the target/classes directory.

The class path for the unit test first loads "target/test-classes", then "target/classes", then the Maven dependencies, of which eclipselink-2.3.2 is the first, followed by tomee, then everything else.

I have tried rearranging this in different ways but that doesn't seem to have any effect.  However with this setup, I can't easily ensure that the EJB classes are loaded first followed by the other classes in my project.  Let me know if you think this is relevant.

Randy

On Feb 3, 2015, at 3:45 PM, Randy Tidd wrote:

> I am using EclipseLink 2.3.2 and trying to write unit tests using embedded OpenEJB / TomEE.  I configured dynamic weaving by including my EclipseLink jar as a javaagent and adding these properties:
> 
> 		props.put("eclipselink.weaving", "dynamic");
> 		props.put("eclipselink.weaving.lazy", "true");
> 		props.put("eclipselink.weaving.internal", "true");
> 
> When I run it I can see in the log messages that it is using weaving:
> 
> [EL Finest]: ServerSession(66487094)--Thread(Thread[main,5,main])--property=eclipselink.weaving.changetracking; default value=true
> [EL Finest]: ServerSession(66487094)--Thread(Thread[main,5,main])--property=eclipselink.weaving.lazy; value=true
> [EL Finest]: ServerSession(66487094)--Thread(Thread[main,5,main])--property=eclipselink.weaving.eager; default value=false
> [EL Finest]: ServerSession(66487094)--Thread(Thread[main,5,main])--property=eclipselink.weaving.fetchgroups; default value=true
> [EL Finest]: ServerSession(66487094)--Thread(Thread[main,5,main])--property=eclipselink.weaving.internal; value=true
> 
> and
> 
> [EL Finer]: ServerSession(66487094)--Thread(Thread[main,5,main])--Class [com.xxx.RequestForClassPublic] registered to be processed by weaver.
> 
> But on the first query, I get this error:
> 
> SEVERE: EjbTransactionUtil.handleSystemException: com.xxx.AbstractModifiableEntity.<init>(Lorg/eclipse/persistence/internal/descriptors/PersistenceObject;)V
> java.lang.NoSuchMethodError: com.xxx.AbstractModifiableEntity.<init>(Lorg/eclipse/persistence/internal/descriptors/PersistenceObject;)V
> 	at com.xxx.RequestForClassPublic.<init>(RequestForClassPublic.java)
> 	at com.xxx.RequestForClassPublic._persistence_new(RequestForClassPublic.java)
> 	at org.eclipse.persistence.internal.descriptors.PersistenceObjectInstantiationPolicy.buildNewInstance(PersistenceObjectInstantiationPolicy.java:30)
> 	at org.eclipse.persistence.descriptors.ClassDescriptor.selfValidationAfterInitialization(ClassDescriptor.java:3870)
> 	at org.eclipse.persistence.descriptors.ClassDescriptor.validateAfterInitialization(ClassDescriptor.java:5688)
> 	at org.eclipse.persistence.descriptors.ClassDescriptor.postInitialize(ClassDescriptor.java:3547)
> 	at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:526)
> 	at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:476)
> 	at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:435)
> 	at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:676)
> 	at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:634)
> 	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:284)
> 	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:294)
> 	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:279)
> 	at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createEntityManager(ReloadableEntityManagerFactory.java:162)
> 	at org.apache.openejb.persistence.JtaEntityManagerRegistry.getEntityManager(JtaEntityManagerRegistry.java:119)
> 	at org.apache.openejb.persistence.JtaEntityManager.getEntityManager(JtaEntityManager.java:96)
> 	at org.apache.openejb.persistence.JtaEntityManager.proxyIfNoTx(JtaEntityManager.java:326)
> 	at org.apache.openejb.persistence.JtaEntityManager.createQuery(JtaEntityManager.java:280)
> 
> This entity class RequestForClassPublic inherits from an abstract entity class AbstractModifiableEntity, those are declared like this:
> 
> @MappedSuperclass
> @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
> @EntityListeners(AbstractModifiableEntityListener.class)
> public abstract class AbstractModifiableEntity implements Serializable {
>    // ... bunch of stuff
>    public AbstractModifiableEntity() {
>    }
>    // ... bunch of stuff
> }
> 
> @Entity
> @Table(name="request_for_class_public")
> @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
> public class RequestForClassPublic extends AbstractModifiableEntity implements Serializable, Inquiry {
>    // ... bunch of stuff
>    public RequestForClassPublic() {
>        super();
>    }
>    // ... bunch of stuff
> }
> 
> Note that both the superclass and subclass have a default constructor which I believe is what the exception is complaining about. I've omitted the ivars, methods, and other code from the entity classes since I don't think they're relevant.
> 
> These same entity classes work fine when deployed as an application to Glassfish 3.2 which has EclipseLink 2.3.2 built-in and supports dynamic weaving.  So it is something about the unit test configuration or OpenEJB / TomEE that is causing this problem.
> 
> This may be related to this issue, though this bug was fixed long ago:
> 
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=292385
> 
> Thanks in advance for any tips or guidance.
> 
> Randy
> 
> 
> 
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top