Bug 807259
Summary: | "UnsupportedOperationException: no transaction" in Seam2 seampay example ftest | ||||||
---|---|---|---|---|---|---|---|
Product: | [Retired] JBoss Enterprise WFK Platform 2 | Reporter: | Ron Šmeral <rsmeral> | ||||
Component: | Seam | Assignee: | Marek Novotny <mnovotny> | ||||
Status: | CLOSED CANTFIX | QA Contact: | Ron Šmeral <rsmeral> | ||||
Severity: | urgent | Docs Contact: | |||||
Priority: | medium | ||||||
Version: | 2.0.0.GA | CC: | amelicha, kpiwko, maschmid, rnewton | ||||
Target Milestone: | --- | Keywords: | Reopened | ||||
Target Release: | --- | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Whiteboard: | Seam2.2 | ||||||
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 15:32:13 UTC | Type: | Bug | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Attachments: |
|
Description
Ron Šmeral
2012-03-27 11:44:19 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. Marek Schmidt <maschmid> made a comment on jira JBPAPP-8322 Reproducible in mail, quartz, seambay and seampay Seam examples 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> Seam 2.3 is not a part of the final payload. Erratum: This a Seam 2.2 issue, reopening. 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; } } } } 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. 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; + } + } + } +} Marek Novotny <mnovotny> updated the status of jira JBPAPP-8322 to Resolved Marek Novotny <mnovotny> made a comment on jira JBPAPP-8322 Added lookup for EAP6 JNDI USerTransaction Ron Šmeral <rsmeral> updated the status of jira JBPAPP-8322 to Reopened 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}}. 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. Marek Novotny <mnovotny> updated the status of jira JBPAPP-8322 to Resolved 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. Marek Schmidt <maschmid> updated the status of jira JBPAPP-8322 to Closed Marek Schmidt <maschmid> made a comment on jira JBPAPP-8322 Verified with Seam from EAP 5.2.0.ER4 on EAP6.0.0 |