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


Reply With Quote
