Bug 1274161 - Add closing sample code for scoped EJB client context
Summary: Add closing sample code for scoped EJB client context
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Documentation
Version: 6.4.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: eap-docs
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-10-22 07:30 UTC by Eiichi Nagai
Modified: 2019-08-15 05:43 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
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 19:51:44 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Eiichi Nagai 2015-10-22 07:30:11 UTC
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 19:51:44 UTC
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.