2012-02-15 6 views
0

休止状態のLazyローディングに関する問題OpenEntityManagerInViewFilterを設定しようとしました。私のプロジェクトでOpenEntityManagerInViewFilterを使用しますか?

しかし、私はそれが既に働いているアプリケーションで動作するようにはできません。 Open EMを使用するために、web.xmlに物を追加して、私がやらなければならないapplicationContext.xmlを作成することから、何が得られるでしょうか?

<filter> 
     <filter-name> 
      OpenEntityManagerInViewFilter 
     </filter-name> 
      <filter-class> 
       org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter 
      </filter-class> 
      <init-param> 
       <param-name>singleSession</param-name> 
       <param-value>true</param-value> 
      </init-param> 
      <init-param> 
       <param-name>flushMode</param-name> 
       <param-value>AUTO</param-value> 
      </init-param> 
    </filter> 
    <!-- Include this if you are using Hibernate --> 
    <filter-mapping> 
     <filter-name>OpenEntityManagerInViewFilter</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 

    <!-- Spring config --> 
    <listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

    <listener> 
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> 
    </listener> 

とapplicationContext.xmlをを::

<?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:p="http://www.springframework.org/schema/p" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation=" 
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
    http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd"> 

</beans> 

私はすでに私のアプリを展開することができますが、私は打ち上げにしようとしたとき、私はweb.xmlに追加した

おかげ

それはex:

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

答えて

0

<init-param> 
    <param-name>entityManagerFactoryBeanName</param-name> 
    <param-value>entityManagerFactory</param-value> 
</init-param> 

web.xmlに設定する。この初期化のparamを追加してみてください
0

エラーが示すように、SpringのコンフィグレーションファイルにentityManagerFactoryが定義されていません。または、別の名前で定義されています。

<!-- Add JPA support --> 
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
    <property name="loadTimeWeaver"> 
     <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/> 
    </property> 
</bean> 

<!-- Add Transaction support --> 
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> 
    <property name="entityManagerFactory" ref="entityManagerFactory"/> 
</bean> 
:このようなあなたのapplicationContext.xmlをへてEntityManagerFactoryを作成し
関連する問題