[jboss-user] [JBoss Seam] - Re: How to get EntityManager without @In?

gothmog do-not-reply at jboss.com
Fri Aug 31 05:22:23 EDT 2007


Good idea, I tried it but got


  | 21:11:46,928 ERROR [STDERR] Exception in thread "Thread-21" 
  | 21:11:46,928 ERROR [STDERR] java.lang.IllegalStateException: No application context active
  | 21:11:46,928 ERROR [STDERR] 	at org.jboss.seam.Component.forName(Component.java:1690)
  | 21:11:46,928 ERROR [STDERR] 	at org.jboss.seam.Component.getInstance(Component.java:1740)
  | 21:11:46,928 ERROR [STDERR] 	at org.jboss.seam.Component.getInstance(Component.java:1723)
  | 21:11:46,928 ERROR [STDERR] 	at model.EXAccessPoint.flushToDb(EXAccessPoint.java:217)
  | 21:11:46,928 ERROR [STDERR] 	at model.EXAccessPoint.access$0(EXAccessPoint.java:207)
  | 21:11:46,928 ERROR [STDERR] 	at model.EXAccessPoint$InvalidateList.run(EXAccessPoint.java:257)

Then I noticed that my em has ended up in the conversation scope


  | 21:10:18,545 INFO  [Component] Component: em, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.persistence.ManagedPersistenceContext
  | 

My components.xml looks like

<core:init debug="true" jndi-pattern="isis-prototype/#{ejbName}/local" transaction-management-enabled="true" />
  | 
  | 
  | 	<security:identity authenticate-method="#{authenticator.authenticate}"/>
  | 	
  | 	<web:multipart-filter create-temp-files="true" 
  |                           max-request-size="1000000" 
  |                           url-pattern="*.seam"/>
  | 
  | 	<web:context-filter url-pattern="/content/*"/>
  | 
  | 	<persistence:managed-persistence-context name="em" auto-create="true"
  |                 persistence-unit-jndi-name="java:/viewEntityManagerFactory"/>

and my persistence.xml looks like


  |  <persistence-unit name="viewDatabase">
  |       <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |       <jta-data-source>java:/viewDatasource</jta-data-source>
  |       <properties>
  |          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
  |          <property name="hibernate.show_sql" value="false"/>
  |          <!-- These are the default for JBoss EJB3, but not for HEM: -->
  |          <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
  |          <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
  |          <property name="jboss.entity.manager.factory.jndi.name" value="java:/viewEntityManagerFactory"/>
  |       </properties>
  |    </persistence-unit>

Any ideas?

I can't remember how I did this, but I did read the seam manual on transactions in conversations and (in another class unrelated to this) I followed the approach given, which was to set the flush mode to manual to get the atomic transactions across a conversation on a @Begin, so...


  | @Scope(ScopeType.CONVERSATION)
  | public class MaintainProfileAction implements Serializable {
  | ...
  | 	@Begin(join=true, flushMode=FlushModeType.MANUAL)
  | 	public void find() {
  | ...
  | 

has this forever put the em in conversation scope I wonder ?

Any ideas? another persistence unit?

Troy

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079889#4079889

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079889



More information about the jboss-user mailing list