Bug 807259 - "UnsupportedOperationException: no transaction" in Seam2 seampay example ftest
Summary: "UnsupportedOperationException: no transaction" in Seam2 seampay example ftest
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: JBoss Enterprise WFK Platform 2
Classification: Retired
Component: Seam
Version: 2.0.0.GA
Hardware: Unspecified
OS: Unspecified
medium
urgent
Target Milestone: ---
: ---
Assignee: Marek Novotny
QA Contact: Ron Šmeral
URL:
Whiteboard: Seam2.2
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-03-27 11:44 UTC by Ron Šmeral
Modified: 2016-11-01 01:36 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Changes in the JNDI name of UserTransaction lead to an UnsupportedOperationException error in the Seam 2 seampay example ftest. The workaround for this issue is to override org.jboss.seam.transaction.Transaction.getUserTransaction. Include the following class in SEAMPAY_EXAMPLE/src/org/jboss/seam/example/seampay and name it TransactionAS7.java: TransactionAS7.java: import static org.jboss.seam.annotations.Install.*; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.transaction.UserTransaction; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Install; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.jboss.seam.annotations.intercept.BypassInterceptors; import org.jboss.seam.transaction.Transaction; import org.jboss.seam.util.Naming; @Name("org.jboss.seam.transaction.transaction") @Scope(ScopeType.EVENT) @Install(precedence = APPLICATION) // overrides Seam default component of BUILT_IN @BypassInterceptors public class TransactionAS7 extends Transaction { @Override protected UserTransaction getUserTransaction() throws NamingException { final InitialContext context = Naming.getInitialContext(); try { return (UserTransaction) context.lookup("java:comp/UserTransaction"); } catch (final NamingException ne) { try { return (UserTransaction) context.lookup("java:jboss/UserTransaction"); } catch (final Exception cause) { // ignore this so we let the code carry on to try the final JNDI name } try { // Embedded JBoss has no java:comp/UserTransaction final UserTransaction ut = (UserTransaction) context.lookup("UserTransaction"); ut.getStatus(); // for glassfish, which can return an unusable UT return ut; } catch (final Exception e) { throw ne; } } } }
Clone Of:
Environment:
Fedora 16 64-bit, Mozilla Firefox 3.6.25, Oracle JDK 1.6.0_30, Seam 2.2.5.EAP5 (included in EAP 5.1.2.GA)
Last Closed: 2012-06-18 15:32:13 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Server log (6.09 KB, text/plain)
2012-03-27 11:44 UTC, Ron Šmeral
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBPAPP-8322 0 Critical Closed "UnsupportedOperationException: no transaction" in Seam2 example ftests 2017-06-28 17:40:00 UTC

Description Ron Šmeral 2012-03-27 11:44:19 UTC
Created attachment 573034 [details]
Server log

Seam version: 2.2.5.EAP5 (included in EAP 5.1.2.GA)
The seampay example from Seam 2.2 was migrated to EAP6 according to the migration guide on Documentation-Stage (http://documentation-stage.bne.redhat.com/docs/en-US/JBoss_Enterprise_Application_Platform/6/html/Beta_Documentation/Migrate_Seam_22_Archives_to_JBoss_Enterprise_Application_Platform_6.html)
and the bug was verified to occur with EAP 6.0.0.ER1.

This issue was fixed in Seam 2.3, so there is a patch available:
https://github.com/maschmid/Seam2.3/commit/44a14986a9f6003c5a9ac13fcae9365a5860331e#diff-0

Related issue: https://issues.jboss.org/browse/AS7-1358

Bug description:

The ftest fails in 2 methods:
[testng] FAILED: payOnceTest
[testng] java.lang.AssertionError: No money were subtracted from account expected:<991.46> but was:<1001.46>
[testng]     at org.jboss.seam.example.common.test.seampay.selenium.PaymentTest.payOnceTest(PaymentTest.java:77)
[testng] ... Removed 25 stack frames
[testng] FAILED: payEveryMinuteTest
[testng] java.lang.AssertionError: No money were subtracted from account after a minute expected:<992.46> but was:<1002.46>
[testng]     at org.jboss.seam.example.common.test.seampay.selenium.PaymentTest.payEveryMinuteTest(PaymentTest.java:115)
[testng] ... Removed 25 stack frames

Relevant part of server log attached.

Comment 1 Ron Šmeral 2012-03-27 14:27:25 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
This bug is caused by changes in the JNDI name of UserTransaction in AS7 (as opposed to AS6 and below).

It can be worked around by overriding org.jboss.seam.transaction.Transaction.getUserTransaction, as described in https://issues.jboss.org/browse/JBPAPP-8322.

Comment 2 JBoss JIRA Server 2012-05-03 11:16:35 UTC
Marek Schmidt <maschmid> made a comment on jira JBPAPP-8322

Reproducible in mail, quartz, seambay and seampay Seam examples

Comment 4 Rebecca Newton 2012-06-18 04:43:23 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,3 +1,5 @@
-This bug is caused by changes in the JNDI name of UserTransaction in AS7 (as opposed to AS6 and below).
+Changes in the JNDI name of UserTransaction lead to an UnsupportedOperationException error in the Seam 2 seampay example ftest. The workaround for this issue is to override org.jboss.seam.transaction.Transaction.getUserTransaction.
 
-It can be worked around by overriding org.jboss.seam.transaction.Transaction.getUserTransaction, as described in https://issues.jboss.org/browse/JBPAPP-8322.+Include the following class in SEAMPAY_EXAMPLE/src/org/jboss/seam/example/seampay and name it TransactionAS7.java:
+
+<snipped for brevity>

Comment 5 Karel Piwko 2012-06-18 06:42:36 UTC
Seam 2.3 is not a part of the final payload.

Comment 6 Karel Piwko 2012-06-18 06:43:55 UTC
Erratum: This a Seam 2.2 issue, reopening.

Comment 8 Marek Schmidt 2012-06-18 08:05:06 UTC
Workaround is to create this class in your application:

TransactionAS7.java:


import static org.jboss.seam.annotations.Install.*;
 
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.transaction.UserTransaction;
 
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.transaction.Transaction;
import org.jboss.seam.util.Naming;
 
@Name("org.jboss.seam.transaction.transaction")
@Scope(ScopeType.EVENT)
@Install(precedence = APPLICATION) // overrides Seam default component of BUILT_IN
@BypassInterceptors
public class TransactionAS7 extends Transaction {
 
    @Override
    protected UserTransaction getUserTransaction() throws NamingException {
        final InitialContext context = Naming.getInitialContext();

        try {
          return (UserTransaction) context.lookup("java:comp/UserTransaction");
        } catch (final NamingException ne) {
            try {
                // JBoss AS7 (with patch from https://issues.jboss.org/browse/AS7-1358)
                return (UserTransaction) context.lookup("java:jboss/UserTransaction");
            } catch (final Exception cause) {
                // ignore this so we let the code carry on to try the final JNDI name
            }

            try {
                // Embedded JBoss has no java:comp/UserTransaction
                final UserTransaction ut = (UserTransaction) context.lookup("UserTransaction");
                ut.getStatus(); // for glassfish, which can return an unusable UT
                return ut;
            } catch (final Exception e) {
                throw ne;
            }
        }
    }
}

Comment 10 mark yarborough 2012-06-18 15:32:13 UTC
WFK 2.0 does not delivere Seam 2.2, however, these issues have already been documented in the EAP 6 release notes, so no need to duplicate each issue in WFk 2.0 release notes. However, we should include a pointer to the EAP 6 release notes to assist customers looking for Seam 2.2 bug information.

Comment 11 Rebecca Newton 2012-06-20 06:26:10 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -2,4 +2,50 @@
 
 Include the following class in SEAMPAY_EXAMPLE/src/org/jboss/seam/example/seampay and name it TransactionAS7.java:
 
-<snipped for brevity>+TransactionAS7.java:
+
+
+import static org.jboss.seam.annotations.Install.*;
+ 
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.UserTransaction;
+ 
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.transaction.Transaction;
+import org.jboss.seam.util.Naming;
+ 
+@Name("org.jboss.seam.transaction.transaction")
+@Scope(ScopeType.EVENT)
+@Install(precedence = APPLICATION) // overrides Seam default component of BUILT_IN
+@BypassInterceptors
+public class TransactionAS7 extends Transaction {
+ 
+    @Override
+    protected UserTransaction getUserTransaction() throws NamingException {
+        final InitialContext context = Naming.getInitialContext();
+
+        try {
+          return (UserTransaction) context.lookup("java:comp/UserTransaction");
+        } catch (final NamingException ne) {
+            try {
+                return (UserTransaction) context.lookup("java:jboss/UserTransaction");
+            } catch (final Exception cause) {
+                // ignore this so we let the code carry on to try the final JNDI name
+            }
+
+            try {
+                // Embedded JBoss has no java:comp/UserTransaction
+                final UserTransaction ut = (UserTransaction) context.lookup("UserTransaction");
+                ut.getStatus(); // for glassfish, which can return an unusable UT
+                return ut;
+            } catch (final Exception e) {
+                throw ne;
+            }
+        }
+    }
+}

Comment 12 JBoss JIRA Server 2012-07-17 20:37:56 UTC
Marek Novotny <mnovotny> updated the status of jira JBPAPP-8322 to Resolved

Comment 13 JBoss JIRA Server 2012-07-17 20:37:56 UTC
Marek Novotny <mnovotny> made a comment on jira JBPAPP-8322

Added lookup for EAP6 JNDI USerTransaction

Comment 14 JBoss JIRA Server 2012-09-07 15:13:33 UTC
Ron Šmeral <rsmeral> updated the status of jira JBPAPP-8322 to Reopened

Comment 15 JBoss JIRA Server 2012-09-07 15:13:33 UTC
Ron Šmeral <rsmeral> made a comment on jira JBPAPP-8322

Still present in EAP 5.2.0.ER2. Quartz, seambay, seampay and mail all behave the same as before, throwing {{java.lang.UnsupportedOperationException: no transaction}}.

Comment 16 JBoss JIRA Server 2012-09-07 17:29:50 UTC
Ron Šmeral <rsmeral> made a comment on jira JBPAPP-8322

It appears that the first catch block in the {{getUserTransaction}} method should catch {{NamingException}} (not NNFE), since that's what is thrown by {{InitialContext.lookup}}. Also, in the {{return}} statement, the result of the lookup should be cast to {{(javax.transaction.UserTransaction)}} instead of {{org.jboss.seam.transaction.UserTransaction}}.
This way, the tests pass.

Comment 17 JBoss JIRA Server 2012-09-10 13:20:35 UTC
Marek Novotny <mnovotny> updated the status of jira JBPAPP-8322 to Resolved

Comment 18 JBoss JIRA Server 2012-09-13 11:57:46 UTC
Marek Novotny <mnovotny> made a comment on jira JBPAPP-8322

This issues is a little dejavu  between EAP5 and EAP6 environment.
Anyway we said that we are supporting Seam 2.2.x on EAP6. So we did all fixes to able that in EAP 5 Seam releases. I have proposed the RN text.

Comment 19 JBoss JIRA Server 2012-11-13 15:01:52 UTC
Marek Schmidt <maschmid> updated the status of jira JBPAPP-8322 to Closed

Comment 20 JBoss JIRA Server 2012-11-13 15:01:52 UTC
Marek Schmidt <maschmid> made a comment on jira JBPAPP-8322

Verified with Seam from EAP 5.2.0.ER4 on EAP6.0.0


Note You need to log in before you can comment on or make changes to this bug.