Transaction Management in Seam 2.2.0.GA
nathandennis Jun 11, 2010 2:18 AMjboss seam 2.2.0.GA
jboss AS 5.1.0.GA
upgrading a project that have been running successfully for months on seam 2.1 i have ran in to a problem with Transaction Management. i can seem to find what changed from 2.1 to 2.2.0 and as many of you have realized this is by far the most confusing aspect of this glorious framework.
as i said before this code had been running flawlessly .... (i'll truncate for simplicity)
@Name("nightlyProcessingTMAction") @Stateless @TransactionManagement(TransactionManagementType.BEAN) public class NightlyProcessingTMAction implements NightlyProcessingTMLocal { @In private EntityManager entityManager; @Resource UserTransaction serTransaction; public Boolean nightlyProcess() { try{ //extend timeout serTransaction.setTransactionTimeout(1000000); serTransaction.begin(); entityManager.joinTransaction(); //purge the tpinventory table to tell if any have been deleted Query tppurge = (Query) entityManager.createNativeQuery("delete from Tpinventory"); tppurge.executeUpdate(); entityManager.flush(); serTransaction.commit(); } catch (Exception e1) { // failed to set the transaction timeout => just log some content e1.printStackTrace(); } return true; } @TransactionAttribute(TransactionAttributeType.SUPPORTS) public void processIncoming(){ //do a bunch of processing that if an error occurs we dont want the a huge roll back.. just the one transaction // that we join and dispose of after each persist. as above... }
this was a good solution that we worked very hard on less than a year ago.
im pretty sure this has something to do with the changes to the transaction management in 2.2.0
the error
01:06:01,289 DEBUG [Component] trying to inject with hierarchical context search: entityManager 01:06:01,294 SEVERE [application] java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:comp/env/crookv2/pu javax.faces.el.EvaluationException: java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:comp/env/crookv2/pu at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) at javax.faces.component.UICommand.broadcast(UICommand.java:387) at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:324) at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:299) at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:256)
components.xml
<persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="@puJndiName@"/>
web.xml
<persistence-unit-ref> <persistence-unit-ref-name>crookv2/pu</persistence-unit-ref-name> <persistence-unit-name>../crookv2.jar#crookv2</persistence-unit-name> </persistence-unit-ref>
persistence.xml
<persistence-unit name="crookv2"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>crookv2Datasource</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/> <property name="hibernate.hbm2ddl.auto" value="update"/> <property name="hibernate.default_schema" value="public"/> <property name="jboss.entity.manager.factory.jndi.name" value="java:/crookv2EntityManagerFactory"/> </properties> </persistence-unit>
whats happened too me here? as i said this method was working very well... and still is in production with 2.1.0 on a jboss 5 installation.
ive been reading everything i can find trying to figure out what is going on.
i found this article DeployingToJboss5
but that isnt quite the same thing.
any help would be GREATLY appreciated.