Bug 1274161 - Add closing sample code for scoped EJB client context
Add closing sample code for scoped EJB client context
Status: CLOSED DEFERRED
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Documentation (Show other bugs)
6.4.0
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: eap-docs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-10-22 03:30 EDT by Eiichi Nagai
Modified: 2015-10-27 15:51 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Build Name: 23088, Development Guide-6.4 Build Date: 08-10-2015 17:02:57 Topic ID: 14110-592100 [Latest]
Last Closed: 2015-10-27 15:51:44 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)

  None (edit)
Description Eiichi Nagai 2015-10-22 03:30:11 EDT
Title: Configure EJBs Using a Scoped EJB Client Context

8.5.5. Configure EJBs Using a Scoped EJB Client Context
https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Development_Guide/sect-Invoking_Session_Beans.html#Configure_EJBs_Using_a_Map-Based_or_Scoped_Context

Describe the issue:
Our documentation is explaining about the org.jboss.ejb.client.scoped.context property with sample code. However, it does not mention as to how to close it.
If using the scoped EJB client context, it have to look up the root JNDI context for "ejb:" and close it in the finally process.

Suggestions for improvement:
Like this community documentation.
https://docs.jboss.org/author/display/AS72/Scoped+EJB+client+contexts 
~~~~
final Properties props = new Properties();
// mark it for scoped EJB client context
props.put("org.jboss.ejb.client.scoped.context","true");
// add other properties
props.put(....);
...
Context jndiCtx = new InitialContext(props);
Context ejbRootNamingContext = (Context) jndiCtx.lookup("ejb:");
try {
    final MyBean bean = ejbRootNamingContext.lookup("app/module/distinct/bean!interface"); // rest of the EJB jndi lookup string
    bean.doSomething();
} finally {
    try {
        // close the EJB naming JNDI context
        ejbRootNamingContext.close();
    } catch (Throwable t) {
        // log and ignore
    }
    try {
        // also close our other JNDI context since we are done with it too
        jndiCtx.close();
    } catch (Throwable t) {
        // log and ignore
    }
 
}
~~~~
Comment 1 anrobert 2015-10-27 15:51:44 EDT
Migrated to JIRA: https://issues.jboss.org/browse/JBEAP-1665

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