Bug 807259 - "UnsupportedOperationException: no transaction" in Seam2 seampay example ftest
"UnsupportedOperationException: no transaction" in Seam2 seampay example ftest
Status: CLOSED CANTFIX
Product: JBoss Enterprise WFK Platform 2
Classification: JBoss
Component: Seam (Show other bugs)
2.0.0.GA
Unspecified Unspecified
medium Severity urgent
: ---
: ---
Assigned To: Marek Novotny
Ron Šmeral
Seam2.2
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-27 07:44 EDT by Ron Šmeral
Modified: 2016-10-31 21:36 EDT (History)
4 users (show)

See Also:
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; } } } }
Story Points: ---
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 11:32:13 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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


External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker JBPAPP-8322 Critical Closed "UnsupportedOperationException: no transaction" in Seam2 example ftests 2017-06-28 13:40 EDT

  None (edit)
Description Ron Šmeral 2012-03-27 07:44:19 EDT
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 10:27:25 EDT
    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 07:16:35 EDT
Marek Schmidt <maschmid@redhat.com> made a comment on jira JBPAPP-8322

Reproducible in mail, quartz, seambay and seampay Seam examples
Comment 4 Rebecca Newton 2012-06-18 00:43:23 EDT
    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 02:42:36 EDT
Seam 2.3 is not a part of the final payload.
Comment 6 Karel Piwko 2012-06-18 02:43:55 EDT
Erratum: This a Seam 2.2 issue, reopening.
Comment 8 Marek Schmidt 2012-06-18 04:05:06 EDT
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 11:32:13 EDT
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 02:26:10 EDT
    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 16:37:56 EDT
Marek Novotny <mnovotny@redhat.com> updated the status of jira JBPAPP-8322 to Resolved
Comment 13 JBoss JIRA Server 2012-07-17 16:37:56 EDT
Marek Novotny <mnovotny@redhat.com> made a comment on jira JBPAPP-8322

Added lookup for EAP6 JNDI USerTransaction
Comment 14 JBoss JIRA Server 2012-09-07 11:13:33 EDT
Ron Šmeral <rsmeral@redhat.com> updated the status of jira JBPAPP-8322 to Reopened
Comment 15 JBoss JIRA Server 2012-09-07 11:13:33 EDT
Ron Šmeral <rsmeral@redhat.com> 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 13:29:50 EDT
Ron Šmeral <rsmeral@redhat.com> 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 09:20:35 EDT
Marek Novotny <mnovotny@redhat.com> updated the status of jira JBPAPP-8322 to Resolved
Comment 18 JBoss JIRA Server 2012-09-13 07:57:46 EDT
Marek Novotny <mnovotny@redhat.com> 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 10:01:52 EST
Marek Schmidt <maschmid@redhat.com> updated the status of jira JBPAPP-8322 to Closed
Comment 20 JBoss JIRA Server 2012-11-13 10:01:52 EST
Marek Schmidt <maschmid@redhat.com> 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.