Aspectj load-time-weaving issue when using EclipseLink JPA in Spring dm Server 1.x
I am trying to get EclipseLink JPA to work in OSGi Spring dm Server environment.
Relevant frameworks and libraries downloaded from the Spring Enterprise Bundle Repository include:
- dm Server 1.0.2.SR02
- AspectJ Runtime 1.6.3
- AspectJ Weaver 1.6.3
- Spring Framework 2.5.6.A
- Eclipse Persistence 1.1.0
- Javax Persistence API 1.99.0
I followed the same structure as in the PetClinic-1.5.0 example for setting up EclipseLink JPA. Everything works until lazy fetch is enabled (which requires proxied objects).
After enabling lazy fetching, the following error indicates that load times are not working correctly.
---- (truncated for readability)
Exception [EclipseLink-60] (Eclipse Persistence Services - 1.1.0.r3634): org.eclipse.persistence.exceptions.DescriptorException Exception Description: [_persistence_setcustomer_vh] or [_persistence_getcustomer_vh] method is not defined in [net.fracbackiceoff.fds.fds. .Job]. Inner Exception: java.lang.NoSuchMethodException: net.fractech.fds.backoffice.Job._persistence_getcu stomer_vh () Display: org.eclipse.persistence.mappings.OneToOneMapping [client] Descriptor: RelationalDescriptor.Jf.fracoffice ob β [DatabaseTable (JOBS)])
This shows that the methods _persistence_getcustomer_vh () and _persistence_setcustomer_vh () were not automatically intertwined into a Job domain object.
Questions
1.) How to determine if the load is actually working over time? also, how do I log which shaking load time agent and weaver was launched? How can I pass variables to this weaver so that it outputs debug information?
I assume I started loading in time with <context: load-time-weaver aspectj-weaving = "on" />
2.) Many searches have shown that I don't need to pass the -javaagent parameter to the jvm when using the dm server. Is it correct?
3.) I have assured my domain objects in another package have access to eclipse persistence classes by asserting com.springsource.org.eclipse.persistence; version = "[1.1.0.1.1.0]"; import -scope: = in my eclipselink suite and including all app packages in PAR. Are there any other configurations needed to enable EclipseLink JPA in a Spring dm server?
source to share
Better to use Equinox Waving Springwaver
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
...
<property name="loadTimeWeaver">
<bean class="org.eclipse.equinox.weaving.springweaver.EquinoxAspectsLoadTimeWeaver"/>
</property>
</bean>
You don't need to use the -javaagent parameter.
You can find working examples with JPA and EclipseLink here http://code.google.com/p/springdm-in-action/ (see chapter 7).
source to share
I've tried using EquinoxAspectsLoadTimeWeaver in a JPa context (with EclipseLink), but it doesn't convert the model classes unless your EquinoxAspectsLoadTimeWeaver bean declaration is executed in the same bundle as the model package.
EquinoxAspectsLoadTimeWeaver converts the class ONLY for the classes stored in the bundle declaring EquinoxAspectsLoadTimeWeaver.
I tried the sample http://code.google.com/p/springdm-in-action/ (see chapter 7) (thanks for this sample Lukasz). EquinoxAspectsLoadTimeWeaver declaration avoids the error
Caused by: java.lang.IllegalStateException: Cannot apply class transformer without LoadTimeWeaver specified
But the model classes are not transformed (woven). Weaving in EclipseLink is driven by lazy mode, for example. For example, if you enter the Contact lazy mode sample model like this:
public class Contact {
...
@Column(name="last_name")
@Basic(fetch=FetchType.LAZY)
private String lastName;
you will notice that lazy loading is not applied because the Contact Contact class is not important.
Regards Angelo
source to share