views:

551

answers:

2
<bean id="data.emf"
  class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"  >
  <property name="persistenceUnitName" value="transactions-optional" />

 </bean>

from what i know by default all bean are singleton (according to document) but i somehow still getting duplicated creating of entitymanagerfactory. is there any parameter i can set for bean above in spring 3.0 to force singleton? the problem only appear in gae production, on hosted mode, no problem

+1  A: 

You can force a bean to be a singleton like this:

<bean scope="singleton" ... >
</bean>

You generally don't need to do this, however, since singleton is the default scope, and there's no way to change the default.

The Spring DEBUG-level logs will generate entries every time a bean is instantiated, so have a look through there to see when and where your bean is being processed.

skaffman
i tried set scope="singleton" but still getting same error. i posted full log dump http://codepaste.net/bnwtyh . may i know what i need to look for in the log
cometta
A: 

Maybe the problem doesn't come form the scope. Are you sure you haven't defined another bean in anther place of the program (for example with an annotation) or in another context file? Comment that bean definition and try if it can find a instance of it without declaring it here.

Javi
i already tried search for keyword "transactions-optional" in entire app . no result =(
cometta
as well as "data.emf", entitymanagerfactory keyword. only in xml file
cometta