3 Replies Latest reply on Feb 10, 2010 3:21 PM by David Webster

    Issue with LoadTimeWeaver

    David Webster Newbie

      Trying to get a fairly simple .war file to deploy that runs fine in JBoss EWS (Tomcat).  This is a Spring JPA application, thus needing the LoadTimeWeaving classloading mechanism.  Pretty simple in JBoss EWS but have some trouble in JBoss EAP 5.0.1

       

      Followed all the instructions here, put the jars on the server classpath.  Here is the Spring config for the database/JPA portion:

       

          <context:load-time-weaver weaver-class="org.jboss.instrument.classloading.JBoss5LoadTimeWeaver"/>
          <!--                Define below if using database                -->
          <!-- ============================================================ -->
          <!-- Define a datasource via jndi                                 -->
          <!-- ============================================================ -->
          <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
             <property name="jndiName" value="java:com.uprr.app.jbs.inventoryPoolTXDS"/>
          </bean>
         
          <!-- ============================================================ -->
          <!-- entityManagerFactory via a jndi lookup   -->
          <!-- ============================================================ -->
          <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
              <property name="persistenceUnitName" value="jbs_jpalib"/>
              <property name="dataSource" ref="dataSource"/>
          </bean>

       

          <!-- ============================================================ -->
          <!-- TransactionManager bean configuration                        -->
          <!-- ============================================================ -->
          <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
              <property name="entityManagerFactory" ref="entityManagerFactory"/>
              <property name="nestedTransactionAllowed" value="true"/>
          </bean>
          <tx:annotation-driven transaction-manager="transactionManager"/>

       

      After deploying the app, during Spring initialization I get the following error....seems almost like ClassCast type issue:

       

      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name org.springframework.transaction.config.internalTransactionAdvisor': Cannot create inner bean '(inner bean)' of type [org.springframework.transaction.interceptor.TransactionInterceptor] while
      setting bean property 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean
      with name '(inner bean)': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exceptio
      n is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resour
      ce [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory';
      nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in Ser
      vletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.Bean
      NotOfRequiredTypeException: Bean named 'loadTimeWeaver' must be of type [org.springframework.instrument.classloading.LoadTimeWeaver], but was actually of type [org.jboss.instrument.classloading.JBoss5LoadTimeWeaver]
      .

      .

      Big Stack Trace

      .

      .

      .

       

       

       

      Am I missing something fundamental?  thanks for any input...

        • 1. Re: Issue with LoadTimeWeaver
          Ales Justin Master

          Yeah, it's a CCE.

          Looks like you have some duplicate classes - EAP might already include some Spring libs.

          • 2. Re: Issue with LoadTimeWeaver
            Marius Bogoevici Expert

            David,

             

            This really looks like a classloader problem. Is Spring twice on your application classpath by any chance (i.e. once embedded in the app, once in the server)?

             

            Also, if you are using Hibernate, even with JPA, then you shouldn't need a LTW, *unless* you need to set up one already for a different purpose (e.g. aspects or so).

             

            HTH (but let me know how that worked),

            Marius

            • 3. Re: Issue with LoadTimeWeaver
              David Webster Newbie

              Thanks, that was the issue, took spring.jar out of the WEB-INF/lib and that did the trick.

               

              This is a spring JPA application but it defaults to whatever the underlying container uses for it's persistence implementation.  In WebLogic it uses Kodo, in Glassfish it uses toplink-essentials, but it JBoss it cleanly implements Hibernate.  JBoss EWS you have to provide your own, so I opted for Toplink-essentials.   Transaction management is all AOP based so I assumed I needed loadTime class weaving anyway even if Hibernate was the persistance provider.  Maybe not since I'm using a jta transaction source in Jboss EAP?  I'll play around with it some more but seems fine now.

               

              Thanks!