-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Context initialization failed error
PostPosted: Wed Jan 16, 2008 3:16 am 
Newbie

Joined: Wed Jan 16, 2008 3:00 am
Posts: 1
Struts 2 + Spring 2 + JPA + AJAX

I am trying to do this example http://struts.apache.org/2.x/docs/strut ... -ajax.html,

but show following error:

SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personService': Injection of persistence methods failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/proxy/EntityNotFoundDelegate
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:314)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1030)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
at java.security.AccessController.doPrivileged(Native Method)

Thanks.

_________________
lifo


Top
 Profile  
 
 Post subject: Hibernate 3 + JPA + Struts2
PostPosted: Wed Jan 16, 2008 6:38 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
I started off with the same example and it works fine. I cannot remember if I had to modify something in the first place. By now the project moved on quite a bit and I added thing like connection pooling.

Only looking at the stack trace you posted it is hard to tell what's wrong. Here is my jpaContext.xml maybe it helps:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:util="http://www.springframework.org/schema/util"
   xmlns:jndi="http://www.springframework.org/schema/jndi"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.springframework.org/schema/jndi http://www.springframework.org/schema/jndi/spring-jndi-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

   <!--
      Process @PersistenceContext to inject entity manager factory
      
      http://static.springframework.org/spring/docs/2.1.x/reference/orm.html#orm-jpa-straight
      http://static.springframework.org/spring/docs/2.1.x/api/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.html
      
      Note: this post processor is implicitly supplied by context:annotation-config or context:component-scan, however,
      we explicitly choose not to use those mechanisms as they encourge dependency lookup (versus the more flexible dependency injection)       
   -->
   <bean
      class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

   <!--
      Create the JPA EntityManagerFactory
      
      http://static.springframework.org/spring/docs/2.1.x/reference/orm.html#orm-jpa-setup-lcemfb
      http://static.springframework.org/spring/docs/2.1.x/api/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean.html
   -->
   <bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
      <property name="loadTimeWeaver">
         <bean
            class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
      </property>
      <property name="dataSource" ref="dataSource" />
      <property name="jpaVendorAdapter">
         <bean
            class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="database" value="${database}" />
            <property name="showSql" value="${show_sql}" />
         </bean>
      </property>
   </bean>

   <bean id="dataSource"
      class="com.mchange.v2.c3p0.ComboPooledDataSource">
      <property name="driverClass" value="${db.driver}" />
      <property name="jdbcUrl" value="${db.url}" />
      <property name="user" value="${db.username}" />
      <property name="password" value="${db.password}" />
      <property name="initialPoolSize" value="5" />
      <property name="minPoolSize" value="5" />
      <property name="maxPoolSize" value="50" />
   </bean>

   <!--
      Create a transaction manager for JPA operations that exposes JPA transactions to the underlying
      JDBC connection.
      
      http://static.springframework.org/spring/docs/2.1.x/reference/orm.html#orm-jpa-tx
      http://static.springframework.org/spring/docs/2.1.x/api/org/springframework/orm/jpa/JpaTransactionManager.html
   -->
   <bean id="transactionManager"
      class="org.springframework.orm.jpa.JpaTransactionManager">
      <property name="entityManagerFactory"
         ref="entityManagerFactory" />
   </bean>

   <bean class="org.springframework.jmx.export.MBeanExporter">
      <property name="autodetect" value="false" />
      <property name="assembler">
         <bean id="jmxAssembler"
            class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
            <property name="attributeSource">
               <bean
                  class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource" />
            </property>
         </bean>
      </property>
      <property name="beans">
         <map>
            <entry key="org.hibernate:name=statistics">
               <bean class="org.hibernate.jmx.StatisticsService">
                  <property name="statisticsEnabled" value="true" />
                  <property name="sessionFactory">
                     <util:property-path
                        path="entityManagerFactory.sessionFactory" />
                  </property>
               </bean>
            </entry>
         </map>
      </property>
   </bean>

   <!--
      process @Transactional to create transaction proxies
      
      http://static.springframework.org/spring/docs/2.1.x/reference/transaction.html#transaction-declarative-annotations
   -->
   <tx:annotation-driven transaction-manager="transactionManager" />
</beans>


I am using maven to build the project and the ${} values get filtered during the build depending on the target environment.

I am using the following dependencies:
Code:
<dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate</artifactId>
        <version>3.2.5.ga</version>
</dependency>
<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-annotations</artifactId>
   <version>3.3.0.ga</version>
</dependency>
<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-entitymanager</artifactId>
   <version>3.3.1.ga</version>
</dependency>


I hope this helps.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.