[ 
https://issues.jboss.org/browse/JBSEAM-3468?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

SBS JIRA Integration updated JBSEAM-3468:
-----------------------------------------

    Forum Reference: https://community.jboss.org/message/783547#783547

    
> Using TransactionManagementType.BEAN sometimes gives 
> javax.persistence.TransactionRequiredException depending on the components on 
> the xhtml page
> -------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: JBSEAM-3468
>                 URL: https://issues.jboss.org/browse/JBSEAM-3468
>             Project: Seam 2
>          Issue Type: Bug
>          Components: EJB3
>    Affects Versions: 2.0.2.SP1
>         Environment: Windows XP, JBoss AS 4.2.2
>            Reporter: Susanne Jarl
>
> I have a SLSB:
> @Name("statService")
> @Stateless
> @TransactionManagement(TransactionManagementType.BEAN)
> public class StatServiceBean implements StatServiceLocal {
>       @In
>       EntityManager entityManager;
>       
>       @Resource
>       SessionContext ejbContext;
> public void generateStat() {
> Query query = entityManager.createNativeQuery(
>                                       "INSERT INTO x"
>                                                       + "SELECT y, 
> :currentDate, count(distinct(ip)) AS number "
>                                                       + "FROM z"
>                                                       + "WHERE datetime 
> BETWEEN :currentDate AND :currentDatePlusOne "
>                                                       + "GROUP BY (x1) " + 
> "ORDER BY number desc ").setParameter(
>                                       "currentDate", 
> calCurrent.getTime()).setParameter("currentDatePlusOne",
>                                       calCurrentPlusOneDay.getTime());        
>                       
>                       // Save to database. Create manual transaction since 
> the built in only works for 5 minutes.
>                       UserTransaction transaction = 
> ejbContext.getUserTransaction();  
>                       try {
>                               transaction.begin();
>                               query.executeUpdate();
>                               transaction.commit();
>                       }
>                       catch (Exception e) {
>                               try {
>                                       log.error("Transaction failed when 
> updating stat. Try rolling back.", e);
>                                       transaction.rollback();                 
>                 
>                               }
>                               catch (Exception exp) {
>                                       log.error("Transaction failed roling 
> back.", exp);
>                               }                               
>                       }
> }
> I have a xhtml page with components calling the generateStat method and 
> depending of what components are on it this code  works or it gives me a 
> TransactionRequiredException.
> This does not work:
> <s:link action="#{statService.generateStat}" value="Update stat" />   
> This does not work "alone":
> <h:form><h:commandButton action="#{statService.generateStat}" 
> value="Uppdatera sidvisningsstatistik" /></h:form>
> but if you add for example:
> <f:subview id="subcriberView" rendered="#{userAdmin.subscriber != null}">     
>                 
> </f:subview>
> so you have both the form with the button and this subview component that 
> calls userAdmin which is a stateful session bean and "subscriber" is just a 
> property, then it works! The sql insert statement is run and the database 
> gets updated and I don't get any exceptions.
> So I guess this must be a bug!
> It seems like you need a call to some SFSB in the same request in order to 
> get the manual userTransaction begin and commit to work. But in the case with 
> <s:link> then it does not  help to add the f:subview code so I don't know...
> In my components.xml I have this code:
> <transaction:ejb-transaction />
>  
> but if I remove it, there is no difference.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
seam-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/seam-issues

Reply via email to