开发者

Trouble with Aspectj load-time-weaving when using EclipseLink JPA in Spring dm Server 1.x

I am attempting to get EclipseLink JPA worki开发者_C百科ng inside the Spring dm Server OSGi 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 presented in the PetClinic-1.5.0 example for setting up EclipseLink JPA. Everything works until lazy-fetching is enabled (which requires proxied objects).

Once lazy-fetching is enabled, the following error suggests that load-time-weaving is not working correctly.

---- (truncated for readability)

Exception [EclipseLink-60] (Eclipse Persistence Services - 1.1.0.r3634): org.eclipse.persistence.exceptions.DescriptorExcep tion Exception Description: The method [_persistence_setcustomer_vh] or [_persistence_getcustomer_vh] is not defined in the object [net.fractech.fds.backoffice.Job]. Internal Exception: java.lang.NoSuchMethodException: net.fractech.fds.backoffice.Job._persistence_getcu stomer_vh() Mapping: org.eclipse.persistence.mappings.OneToOneMapping[customer] Descriptor: RelationalDescriptor(net.fractech.fds.backoffice.J ob --> [DatabaseTable(JOBS)])


This shows that the _persistence_getcustomer_vh() and _persistence_setcustomer_vh() methods were not automatically weaved into the Job domain object.

Questions

1.) How do I determine if load-time-weaving is actually working; moreover, how do I log which load time weaving agent and weaver was started? How do I pass switches to this weaver to have it output debugging information?

I assume I started load-time-weaving with <context:load-time-weaver aspectj-weaving="on" />

2.) Many searches have revealed that I do not need to pass the -javaagent parameter to the jvm when using dm Server. Is this correct?

3.) I have assured that my domain objects in another bundle have access to the eclipse persistence classes by asserting com.springsource.org.eclipse.persistence;version="[1.1.0,1.1.0]";import-scope:=application in my eclipselink bundle and including all application bundles within a PAR. Are there any other configurations needed to enable EclipseLink JPA in Spring dm Server?


I had similar problems. First try setting eclipselink.weaving.lazy=false, or eclipselink.weaving=false if that doesn't work. I had to set the latter.

If you would like to refer to the setup I am using to see if it applies to you, I have a post about it on my site.


It is 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 -javaagent option then.

You can find working examples with JPA and EclipseLink here http://code.google.com/p/springdm-in-action/ (see Chapter 7).


I have tried to use EquinoxAspectsLoadTimeWeaver into JPa context (with EclipseLink) but it doen't transform the model classes if your EquinoxAspectsLoadTimeWeaver bean declaration is not done into the same bundle than Model bundle.

EquinoxAspectsLoadTimeWeaver transform class ONLY for the classes stored into the bundle wich declare EquinoxAspectsLoadTimeWeaver.

I have tried the sample http://code.google.com/p/springdm-in-action/ (see Chapter 7) (thank for this sample Lukasz). The declaration of EquinoxAspectsLoadTimeWeaver avoid having the error

Caused by: java.lang.IllegalStateException: Cannot apply class transformer without LoadTimeWeaver specified

But Model classes are not transformed (woven). Weaving into EclipseLink manage for instance lazy mode. For instance if you set into the sample model Contact lazy mode 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 Model Contact class is not wowen.

Regards Angelo

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜