zax
zax

Reputation: 91

Can't see entityManagerFactory

My application cant see entityManagerFactory. In my web.xml:

<filter>
   <filter-name>SpringOpenEntityManagerInViewFilter</filter-name>
   <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
   <init-param>
      <param-name>entityManagerFactoryBeanName</param-name>      
      <param-value>entityManagerFactory</param-value>       
   </init-param>
</filter>

<filter-mapping>
    <filter-name>SpringOpenEntityManagerInViewFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

in spring-servlet.xml:

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="showSql" value="true" />
            <property name="generateDdl" value="true" />
            <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
        </bean>
    </property>
    <property name="persistenceUnitName" value="MontyBroganPU" />
    <property name="dataSource" ref="dataSource" />

</bean>

I got still error:

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' is defined

Upvotes: 2

Views: 1543

Answers (1)

rafaelportela
rafaelportela

Reputation: 306

You should setup a JPA-EntityManagerFactory bean in your applicationContext.xml, maybe with your dataSource bean. Take a look on how you can do it:

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/orm.html#orm-jpa-setup

Upvotes: 1

Related Questions