Announcement Announcement Module
Collapse
No announcement yet.
OpenJPA and load time weaving troubles Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OpenJPA and load time weaving troubles

    I currently having problems using the OpenJPA, Spring and Tomcat (5.5.23) combination. I have some persistent classes which are enhanced at build-time using PCEnhancer which comes with OpenJPA . When I try to start my webapp context (which makes use of these classes) I get the following error:

    Error creating bean with name 'entityManagerFactory'
    Cannot apply class transformer without LoadTimeWeaver specified


    I don't really get that. I thought that enhancing your persistent classes at build-time negates the need of load time weaving. In the Spring reference documentation it is clearly stated:
    When is load time weaving required?
    Not all JPA providers impose the need of a JDK agent (Hibernate being an example). If your provider does not require an agent or you have other alternatives (for example applying enhancements at build time through a custom compiler or an ant task) the load time weaver should not be used.
    Is this contradicting or am I missing something here?

    In desperation I've tried what is suggested in section 12.6.1.2.1. Tomcat setup but that did not work.

    Does anybody have some ideas for me?

  • #2
    Originally posted by lnoordermeer View Post
    I thought that enhancing your persistent classes at build-time negates the need of load time weaving.
    You are correct; if you've run the OpenJPA enhancer, you do not need the load-time weaver in theory. I'm not sure whether or not this is properly auto-detected, though.

    Additionally, in recent builds of OpenJPA, both enhancement and load-time weaving are optional.

    What does your persistence.xml look like?

    -Patrick

    Comment


    • #3
      Originally posted by pcl View Post
      You are correct; if you've run the OpenJPA enhancer, you do not need the load-time weaver in theory. I'm not sure whether or not this is properly auto-detected, though.

      Additionally, in recent builds of OpenJPA, both enhancement and load-time weaving are optional.

      What does your persistence.xml look like?

      -Patrick
      It is pretty straight forward:
      Code:
      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
      	version="1.0">
      	<persistence-unit name="SpringJpaGettingStarted"
      		transaction-type="RESOURCE_LOCAL">
      		<class>com.foo.bar.SomeClass</class>
      		<class>com.foo.bar.SomeOtherClass</class>
      		<class>etc</class>
      	</persistence-unit>
      </persistence>
      The configuration of the entity manager looks like this:
      Code:
          <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
          <property name="dataSource" ref="dataSource" />
          <!--
          <property name="loadTimeWeaver">
            <bean class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/>
          </property>  
          -->
          <property name="jpaVendorAdapter">
            <bean
              class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
              <property name="database" value="MYSQL"/>
              <property name="showSql" value="true" />
              <property name="generateDdl" value="true" />
            </bean>
          </property>

      Comment

      Working...
      X