Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » MappedSuperclass doesn't work with dynamic weaving
MappedSuperclass doesn't work with dynamic weaving [message #532914] Tue, 11 May 2010 14:37 Go to next message
Adrian Gygax is currently offline Adrian GygaxFriend
Messages: 14
Registered: July 2009
Junior Member
Hi!

I'm using EclipseLink 2.0.1 together with Spring's -javaagent:org.springframework.instrument-3.0.2.RELEASE.jar. Now I added my first MappedSuperclass to my model and there seems to be an issue with dynamic weaving not really weaving that MappedSuperclass.

Facts:
* No problem if using static weaving
* My mapped superclass is never passed to Spring's InstrumentationLoadTimeWeaver, so Eclipselink actually doesn't get a chance to weave its stuff in


Example:
@MappedSuperclass
public abstract class AbstractAuditableEntity {
...
}

@Entity
public class LocalizedMessage extends AbstractAuditableEntity {
...
}

As soon as I execute a query and Eclipselink tries to create an instance of LocalizedMessage I get an exception like this which tells me that weaving didn't ocurr:

Caused by: java.lang.NoSuchMethodError: com.beeline.bop.common.model.AbstractAuditableEntity.<init> (Lorg/eclipse/persistence/internal/descriptors/PersistenceOb ject;)V
at com.beeline.bop.common.model.localization.LocalizedMessage.<init >(LocalizedMessage.java)
at com.beeline.bop.common.model.localization.LocalizedMessage._ persistence_new(LocalizedMessage.java)
at org.eclipse.persistence.internal.descriptors.PersistenceObje ctInstantiationPolicy.buildNewInstance(PersistenceObjectInst antiationPolicy.java:30)
at org.eclipse.persistence.descriptors.ClassDescriptor.selfVali dationAfterInitialization(ClassDescriptor.java:3522)
at org.eclipse.persistence.descriptors.ClassDescriptor.validate AfterInitialization(ClassDescriptor.java:5250)
at org.eclipse.persistence.descriptors.ClassDescriptor.postInit ialize(ClassDescriptor.java:3244)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImp l.initializeDescriptors(DatabaseSessionImpl.java:463)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImp l.initializeDescriptors(DatabaseSessionImpl.java:406)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImp l.postConnectDatasource(DatabaseSessionImpl.java:671)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImp l.login(DatabaseSessionImpl.java:633)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryPro vider.login(EntityManagerFactoryProvider.java:230)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl. deploy(EntityManagerSetupImpl.java:369)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.getServerSession(EntityManagerFactoryImpl.java:151)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.createEntityManagerImpl(EntityManagerFactoryImpl.java:207)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImp l.createEntityManager(EntityManagerFactoryImpl.java:195)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean .invokeProxyMethod(AbstractEntityManagerFactoryBean.java:423 )
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean $ManagedEntityManagerFactoryInvocationHandler.invoke(Abstrac tEntityManagerFactoryBean.java:485)
at $Proxy15.createEntityManager(Unknown Source)
at org.springframework.orm.jpa.SharedEntityManagerCreator$Share dEntityManagerInvocationHandler.invoke(SharedEntityManagerCr eator.java:234)
at $Proxy18.createNamedQuery(Unknown Source)
at com.beeline.bop.persistence.localization.jpa.JPALocalizedMes sageDAO.findAll(JPALocalizedMessageDAO.java:82)
at com.beeline.bop.business.localization.impl.LocalizationServi ceImpl.populateMessageSource(LocalizationServiceImpl.java:96 )
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.beans.factory.support.AbstractAutowireCa pableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapa bleBeanFactory.java:1536)
at org.springframework.beans.factory.support.AbstractAutowireCa pableBeanFactory.invokeInitMethods(AbstractAutowireCapableBe anFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCa pableBeanFactory.initializeBean(AbstractAutowireCapableBeanF actory.java:1409)
... 27 more


So, I don't know if this is an EclipseLink bug, a Spring bug or a bug when using a combination of both. Does anybody have any ideas?
Maybe a classloading problem and EclipseLink should make sure all classes in persistence.xml are actually loaded after persistence context initialization?

[Updated on: Tue, 11 May 2010 15:09]

Report message to a moderator

Re: MappedSuperclass doesn't work with dynamic weaving [message #533179 is a reply to message #532914] Wed, 12 May 2010 13:50 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
Odd, this looks like bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=282518
which has been fixed, but I'm not sure of the timing of when it got in. Can you try using 2.0.2 or better, a 2.0.3 or 2.1 nightly build and see if you still get the exception?

Best Regards,
Chris
Re: MappedSuperclass doesn't work with dynamic weaving [message #533239 is a reply to message #532914] Wed, 12 May 2010 16:34 Go to previous messageGo to next message
Adrian Gygax is currently offline Adrian GygaxFriend
Messages: 14
Registered: July 2009
Junior Member
Hi Chris,

the problem also exists with 2.0.2 and 2.1-M7.

Do you think it's actually possible for EclipseLink to initialize the descriptors without triggering the ClassLoader to load my superclass?

Hope I'll find some time to isolate the problem into a small test project and do some more debugging.
Re: MappedSuperclass doesn't work with dynamic weaving [message #533358 is a reply to message #532914] Thu, 13 May 2010 14:03 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

>> * My mapped superclass is never passed to Spring's InstrumentationLoadTimeWeaver, so Eclipselink actually doesn't get a chance to weave its stuff in

Sounds like it could be a bug in Spring, it might not be considering @MappedSuperclasses for weaving. You might try logging a bug on Spring, and use static weaving as a workaround.

Note, that Spring also has a weaving issue that it does not allow instrumentation until the Spring context is accessed by your application. If you application has trigger the loading of any of the classes before this, then they will already be loaded and will not get weaved.


James : Wiki : Book : Blog : Twitter
Re: MappedSuperclass doesn't work with dynamic weaving [message #533408 is a reply to message #533358] Thu, 13 May 2010 17:47 Go to previous message
Adrian Gygax is currently offline Adrian GygaxFriend
Messages: 14
Registered: July 2009
Junior Member
James wrote on Thu, 13 May 2010 10:03

Note, that Spring also has a weaving issue that it does not allow instrumentation until the Spring context is accessed by your application. If you application has trigger the loading of any of the classes before this, then they will already be loaded and will not get weaved.



Hi James,

yes this was my problem, the class was loaded before Spring initialized EclipseLink's PersistenceWeaver.

I'll stick with static weaving and discuss this in the Spring forums as you suggested.

thanks a lot!
Previous Topic:JPA build entity manager with a specific JDBC connection instance
Next Topic:JPA query that returns LAST (youngest) entity (pk index) for ANY table
Goto Forum:
  


Current Time: Mon Nov 24 16:36:39 GMT 2014

Powered by FUDForum. Page generated in 0.01764 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software