Results 1 to 3 of 3

Thread: Weaving prob Spring 2.5.6, EclipseLink 1.1.1, TestContext

  1. #1
    Join Date
    Jan 2008
    Posts
    3

    Default 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="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="myunit" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceP rovider</provider>
    <class>AbstractBusinessObject</class>
    <class>Contract</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
    <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"/>
    </properties>
    </persistence-unit>
    </persistence>

    Here's my applicationContext

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-2.5.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schem...ontext-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <!-- support use of the @Required annotation -->
    <bean
    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">
    <bean
    class="org.springframework.instrument.classloading .InstrumentationLoadTimeWeaver" />
    </property>
    </bean>

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

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

    Here's my ORM mapping

    My entity definition is like this:

    @Entity
    @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")
    @ManyToOne(fetch=LAZY)
    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. #2
    Join Date
    Dec 2009
    Posts
    12

    Default

    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
    Code:
    <property name="eclipselink.weaving" value="false" />
    in persistence.xml is not the solution i am looking for.

  3. #3
    Join Date
    Dec 2009
    Posts
    12

    Default

    It seems that it is common issue with EclipseLink 1.2.

    http://wiki.eclipse.org/EclipseLink/.../JPA/JPASpring

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •