Announcement Announcement Module
No announcement yet.
Weaving prob Spring 2.5.6, EclipseLink 1.1.1, TestContext Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Weaving prob Spring 2.5.6, EclipseLink 1.1.1, TestContext

    I'm having this problem when I'm testing a DAO that gets an object that contains a lazy-loaded reference to another object.

    It looks like the load time weaving is not happening, but what am I missing?

    Here's my persistence.xml

    <persistence version="1.0" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
    <persistence-unit name="myunit" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceP rovider</provider>
    <property name="eclipselink.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
    <property name="eclipselink.logging.level" value="FINE"/>
    <property name="eclipselink.weaving" value="true"/>
    <property name="eclipselink.weaving.lazy" value="true"/>
    <property name="eclipselink.weaving.fetchgroups" value="false"/>
    <property name="eclipselink.weaving.changetracking" value="false"/>
    <property name="eclipselink.orm.throw.exceptions" value="true"/>

    Here's my applicationContext

    <beans xmlns=""
    xmlns:xsi="" xmlns:context=""

    <!-- support use of the @Required annotation -->
    class="org.springframework.beans.factory.annotatio n.RequiredAnnotationBeanPostProcessor" />

    <!-- support use of Spring annotations as alternative to xml -->
    <context:annotation-config />

    <!-- this switches on the load-time weaving -->
    <context:load-time-weaver aspectj-weaving="on" />

    <context:component-scan base-package="contract" />

    <bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
    <property name="persistenceUnitName" value="myunit" />
    <property name="loadTimeWeaver">
    class="org.springframework.instrument.classloading .InstrumentationLoadTimeWeaver" />

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionM anager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />

    support declarative transaction management at the service method level
    <tx:annotation-driven />

    Here's my ORM mapping

    My entity definition is like this:

    @AttributeOverride(name = "id", column = @Column(name = "CONTRACTID"))
    public class Contract extends AbstractBusinessObject {

    and the lazy-loaded attribute is like this:

    @JoinColumn(name="PARENT", referencedColumnName = "CONTRACTID")
    private Contract parent;

    I'm getting this exception

    org.springframework.transaction.CannotCreateTransa ctionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-0] (Eclipse Persistence Services - 1.1.1.v20090430-r4097): org.eclipse.persistence.exceptions.IntegrityExcept ion
    Descriptor Exceptions:

    Exception [EclipseLink-60] (Eclipse Persistence Services - 1.1.1.v20090430-r4097): org.eclipse.persistence.exceptions.DescriptorExcep tion
    Exception Description: The method [_persistence_setparent_vh] or [_persistence_getparent_vh] is not defined in the object [Contract].
    Internal Exception: java.lang.NoSuchMethodException: Contract._persistence_getparent_vh()
    Mapping: org.eclipse.persistence.mappings.OneToOneMapping[parent]
    Descriptor: RelationalDescriptor(Contract --> [DatabaseTable(CONTRACT)])

    My classpath

    includes spring.jar, spring-aspects.jar, aspectjrt.jar, aspectjweaver.jar

    My integration test
    extends AbstractTransactionalJUnit4SpringContextTests
    and I'm launching it with this VM argument: -javaagent:C:/TOOLS/spring-framework-2.5.6.SEC01/dist/weaving/spring-agent.jar

    I'm running the test from Eclipse 3.4 on Java 6

  • #2
    I have currently exactly the same problem with Spring3.0.1-A and eclipselink 1.2.0. When I changed some fetchtypes from eager to lazy the problems started in JUnit tests. The same code still works when deployed on Weblogic 11g, so the problem must be with the spring loadtimeweaver. I am using InstrumentationLoadTimeWeaver and JUnit test is started with java-agent:spring-instrumentation.jar VM param.

    Anyone managed to solve this issue?
    And using
    <property name="eclipselink.weaving" value="false" />
    in persistence.xml is not the solution i am looking for.


    • #3
      It seems that it is common issue with EclipseLink 1.2.

      Is it really so that there's no way of getting weaving work with EclipseLink 1.2 in Spring?