blob: 65da7d2924158f77298d11d486d21222b58cff67 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<!-- $PAGETITLE -->
<TITLE>OpenEJB - JNDI Names</TITLE>
<LINK href="http://openejb.apache.org/default.css" rel="stylesheet" type="text/css">
<LINK href="http://openejb.apache.org/style.css" rel="stylesheet" type="text/css">
<LINK rel="SHORTCUT ICON" href="http://openejb.apache.org/images/favicon.ico">
<SCRIPT language="JavaScript" src="http://cwiki.apache.org/confluence/pages/viewpage.action?spaceKey=OPENEJB&title=functions.js" type="text/javascript"></SCRIPT>
<META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
<BODY bgcolor="#ffffff" link="#6763a9" vlink="#6763a9" topmargin="0" bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<!-- Delay the loading of the external javascript file needed for labels (as it takes too long to load and visibly holds loading of the page body) -->
<!-- To do this without javascript errors over undefined functions, we need to declare stubs here (that are overrided later by the proper implementations) -->
<SCRIPT language="JavaScript" type="text/javascript">
function doAddLabel(hideTextfieldAfterAddParam)
{
// stub
}
function onAddLabel()
{
// stub
}
function showLabelsInput()
{
// stub
}
</SCRIPT>
<A name="top"></A>
<TABLE border="0" cellpadding="0" cellspacing="0" width="100%" height="400">
<TR>
<TD width="20" valign="top" align="left" bgcolor="#7270c2"><IMG src="http://openejb.apache.org/images/dotTrans.gif" width="1" height="1" border="0"></TD>
<TD width="95" valign="top" align="left" bgcolor="#7270c2"><IMG src="http://openejb.apache.org/images/dotTrans.gif" width="1" height="1" border="0"></TD>
<TD width="7" valign="top" align="left"><IMG src="http://openejb.apache.org/images/dotTrans.gif" border="0" width="1" height="1"></TD>
<TD width="40" valign="top" align="left"><IMG src="http://openejb.apache.org/images/dotTrans.gif" width="40" height="6" border="0"></TD>
<TD width="100%" valign="top" align="left" bgcolor="#5A5CB8"><IMG src="http://openejb.apache.org/images/top_2.gif" width="430" height="6" border="0"></TD>
<TD width="120" valign="top" align="left" bgcolor="#E24717"><IMG src="http://openejb.apache.org/images/top_3.gif" width="120" height="6" border="0"></TD>
</TR>
<TR>
<TD width="20" bgcolor="#7270c2" valign="top" align="left"><IMG src="http://openejb.apache.org/images/dotTrans.gif" border="0" width="1" height="1"></TD>
<TD width="95" bgcolor="#7270c2" valign="top" align="left"><IMG src="http://openejb.apache.org/images/dotTrans.gif" border="0" width="1" height="1"></TD>
<TD width="7" bgcolor="#ffffff" valign="top" align="left"></TD>
<TD width="40" valign="top" align="left"><IMG src="http://openejb.apache.org/images/dotTrans.gif" width="1" height="1" border="0"></TD>
<TD id="breadcrumbs" width="100%" valign="middle" align="left">
<!-- $TOP_NAV_BAR -->
<SPAN id="Content">
<A href="index.html" title="Index">Index</A> | <A href="news.html" title="News">News</A> | <A href="faq.html" title="FAQ">FAQ</A> | <A href="download.html" title="Download">Download</A> | <A href="mailing-lists.html" title="Mailing Lists">Lists</A> | <SPAN class="nobr"><A href="http://issues.apache.org/jira/browse/OPENEJB" title="Visit page outside Confluence" rel="nofollow">Issues<SUP><IMG class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN>
</SPAN>
<IMG src="http://openejb.apache.org/images/dotTrans.gif" width="1" height="2" border="0"></TD>
<TD width="120" height="20" valign="top" align="left">&nbsp;</TD>
</TR>
<TR>
<TD width="20" bgcolor="#7270c2" valign="top" align="left"><IMG src="http://openejb.apache.org/images/dotTrans.gif" width="20" height="3" border="0"></TD>
<TD width="95" bgcolor="#7270c2" valign="top" align="left"><IMG src="http://openejb.apache.org/images/line_sm.gif" width="105" height="3" border="0"></TD>
<TD width="7" bgcolor="#a9a5de" valign="top" align="left"><IMG src="http://openejb.apache.org/images/line_sm.gif" width="7" height="3" border="0"></TD>
<TD width="40" valign="top" align="left"><IMG src="http://openejb.apache.org/images/line_light.gif" width="40" height="3" border="0"></TD>
<TD width="100%" valign="top" align="left"><IMG src="http://openejb.apache.org/images/line_light.gif" width="430" height="3" border="0"></TD>
<TD width="120" valign="top" align="left"><IMG src="http://openejb.apache.org/images/dotTrans.gif" border="0" width="1" height="1"></TD>
</TR>
<TR>
<TD bgcolor="#7270c2" valign="top" align="left"><IMG src="http://openejb.apache.org/images/dotTrans.gif" width="20" height="10" border="0"></TD>
<TD id="leftColumn" valign="top" style="padding-top: 0px;">
<SPAN id="Content">
<H3><A name="Navigation-Overview"></A>Overview</H3>
<UL class="alternate" type="square">
<LI><A href="index.html" title="Index">Home</A></LI>
<LI><A href="news.html" title="News">News</A></LI>
<LI><A href="faq.html" title="FAQ">FAQ</A></LI>
<LI><A href="download.html" title="Download">Download</A></LI>
<LI><A href="examples.html" title="Examples">Examples</A></LI>
<LI><A href="mailing-lists.html" title="Mailing Lists">Mailing Lists</A></LI>
<LI><A href="source-code.html" title="Source Code">Source Code</A></LI>
</UL>
<H3><A name="Navigation-General"></A>General</H3>
<UL class="alternate" type="square">
<LI><A href="deploy-tool.html" title="Deploy Tool">Deployment</A></LI>
<LI><A href="startup.html" title="Startup">Startup</A></LI>
<LI><A href="validation-tool.html" title="Validation Tool">Validation</A></LI>
<LI><A href="webadmin.html" title="Webadmin">Webadmin</A></LI>
</UL>
<H3><A name="Navigation-Configuration"></A>Configuration</H3>
<UL class="alternate" type="square">
<LI><A href="configuration.html" title="Configuration">General</A></LI>
<LI><A href="deployments.html" title="Deployments">Deployments</A></LI>
<LI><A href="containers.html" title="Containers">Containers</A></LI>
</UL>
<H3><A name="Navigation-Servers"></A>Servers</H3>
<UL class="alternate" type="square">
<LI><A href="local-server.html" title="Local Server">Local</A></LI>
<LI><A href="remote-server.html" title="Remote Server">Remote</A></LI>
</UL>
<H3><A name="Navigation-Integrations"></A>Integrations</H3>
<UL class="alternate" type="square">
<LI><A href="tomcat.html" title="Tomcat">Tomcat</A></LI>
<LI><A href="geronimo.html" title="Geronimo">Geronimo</A></LI>
<LI><A href="webobjects.html" title="WebObjects">WebObjects</A></LI>
</UL>
<H3><A name="Navigation-Community"></A>Community</H3>
<UL class="alternate" type="square">
<LI><A href="team.html" title="Team">Team</A></LI>
<LI><A href="articles.html" title="Articles">Articles</A></LI>
<LI><A href="annoyances.html" title="Annoyances">Annoyances</A></LI>
<LI><SPAN class="nobr"><A href="index.html" title="Visit page outside Confluence" rel="nofollow">Wiki<SUP><IMG class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN></LI>
<LI><SPAN class="nobr"><A href="irc://irc.freenode.net/#openejb" title="Visit page outside Confluence" rel="nofollow">IRC<SUP><IMG class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN></LI>
</UL>
</SPAN>
<H3 class="heading3">Feeds</H3>
<TABLE border="0" cellspacing="4px">
<TR>
<TD align="right">
<A href="http://cwiki.apache.org/confluence/spaces/rss.action?key=OPENEJB&newPages=false"><IMG src="http://openejb.apache.org/images/rss.gif" border="0"></A><BR>
</TD>
<TD align="left">
<A href="http://cwiki.apache.org/confluence/spaces/rss.action?key=OPENEJB&newPages=false">Site</A>
</TD>
</TR>
<TR>
<TD align="right">
<A href="http://cwiki.apache.org/confluence/spaces/blogrss.action?key=OPENEJB"><IMG src="http://openejb.apache.org/images/rss.gif" border="0"></A>
</TD>
<TD align="left">
<A href="http://cwiki.apache.org/confluence/spaces/blogrss.action?key=OPENEJB">News</A>
</TD>
</TR>
</TABLE>
</TD>
<TD width="7" bgcolor="#a9a5de" valign="top" align="left">&nbsp;</TD>
<TD width="40" valign="top" align="left">&nbsp;</TD>
<TD rowspan="4" width="100%" valign="top">
<TABLE cols="1" rows="2" border="0" cellpadding="0" cellspacing="0" width="100%">
<TR>
<TD valign="top" align="left"><BR>
<TABLE cols="3" rows="1" border="0" cellpadding="0" cellspacing="0" width="100%">
<TR>
<TD valign="top" width="200" align="left">
<A href="http://openejb.org/">
<IMG border="0" hspace="0" src="http://openejb.apache.org/images/logo_openejb.gif" vspace="0">
</A>
</TD>
<TD align="right" valign="middle" style="padding:0px;margin:0px;">
<TABLE style="padding:0px;margin:0px;">
<TR>
<TD>
<A href="http://www.apache.org/">
<IMG src="http://www.apache.org/images/asf-logo.gif" border="0" width="258" height="66">
</A>
</TD>
<TR>
<!--
<tr>
<td align="right" valign="top" style="font- size:12px;color:#777777">
[OpenEJB is a Podling in the Apache Incubator]
</td>
</tr>
-->
</TABLE>
</TD>
</TR>
</TABLE>
<BR>
</TD>
</TR>
<TR>
<TD valign="top" align="left">
<IMG border="0" height="7" hspace="0" src="http://openejb.apache.org/images/dotTrans.gif"><BR>
<DIV id="page_title">
<TABLE width="100%">
<TR>
<TD>
<!-- $TITLE -->
JNDI Names
</TD>
<!-- Google CSE Search Box Begins -->
<TD align="right">
<FORM id="searchbox_010475492895890475512:_t4iqjrgx90" action="http://www.google.com/cse">
<INPUT type="hidden" name="cx" value="010475492895890475512:_t4iqjrgx90">
<INPUT type="hidden" name="cof" value="FORID:0">
<INPUT name="q" type="text" size="25">
<INPUT type="submit" name="sa" value="Search">
</FORM>
<SCRIPT type="text/javascript" src="http://www.google.com/coop/cse/brand?form=searchbox_010475492895890475512:_t4iqjrgx90"></SCRIPT>
</TD>
<!-- Google CSE Search Box Ends -->
<TD align="right" style="padding-left:0px;"><A style="color:#999;font-size:small;font-weight:normal;" href="http://cwiki.apache.org/confluence/pages/editpage.action?spaceKey=OPENEJB&title=JNDI%20Names">[ edit ]</A></TD>
<TD align="right" width="25">
<SCRIPT type="text/javascript" language="javascript">
document.write('<a href="http://cwiki.apache.org/confluence/pages/viewpage');
document.write('.action?pageId=33329&decorator=printable">');
</SCRIPT>
<IMG src="http://cwiki.apache.org/confluence/images/icons/print_16.gif" height="16" width="16" border="0" align="absmiddle" title="Print"></A>
</TD>
</TR>
</TABLE>
</DIV>
<IMG border="0" height="1" hspace="0" src="http://openejb.apache.org/images/dotTrans.gif"></TD>
</TR>
</TABLE>
<P>
<!-- $BODY -->
<DIV id="PageContent">
<DIV class="pagecontent">
<DIV class="wiki-content">
<H1><A name="JNDINames-What%27sMyBean%27sJNDIName%3F"></A>What's My Bean's JNDI Name?</H1>
<P>There are two things to keep in mind before you start reading:</P>
<OL>
<LI>OpenEJB provides a default JNDI name to your EJB.</LI>
<LI>You can customize the JNDI name.</LI>
</OL>
<H2><A name="JNDINames-DefaultJNDIname"></A>Default JNDI name </H2>
<P>The default JNDI name is in the following format:</P>
<DIV class="code"><DIV class="codeContent">
<PRE class="code-java">{deploymentId}{interfaceType.annotationName}</PRE>
</DIV></DIV>
<P>Lets try and understand the above format. Both <B>deploymentId</B> and <B>interfaceType.annotationName</B> are pre-defined variables. There are other pre-defined variables available which you could use to customize the JNDI name format.</P>
<H1><A name="JNDINames-JNDINameFormatting"></A>JNDI Name Formatting</H1>
<P>The <B>openejb.jndiname.format</B> property allows you to supply a template for the global JNDI names of all your EJBs. With it, you have complete control over the structure of the JNDI layout can institute a design pattern just right for your client apps. See the <A href="service-locator.html" title="Service Locator">OPENEJB:Service Locator</A> doc for clever ways to use the JNDI name formatting functionality in client code.</P>
<TABLE class="confluenceTable"><TBODY>
<TR>
<TH class="confluenceTh"> variable </TH>
<TH class="confluenceTh"> description </TH>
</TR>
<TR>
<TD class="confluenceTd"> moduleId </TD>
<TD class="confluenceTd"> Typically the name of the ejb-jar file or the &lt;ejb-jar id=&quot;&quot;&gt; id value if specified </TD>
</TR>
<TR>
<TD class="confluenceTd"> ejbType </TD>
<TD class="confluenceTd"> STATEFUL, STATELESS, BMP_ENTITY, CMP_ENTITY, or MESSAGE_DRIVEN </TD>
</TR>
<TR>
<TD class="confluenceTd"> ejbClass </TD>
<TD class="confluenceTd"> for a class named <EM>org.acme.superfun.WidgetBean</EM> results in <B>org.acme.superfun.WidgetBean</B> </TD>
</TR>
<TR>
<TD class="confluenceTd"> ejbClass.simpleName </TD>
<TD class="confluenceTd"> for a class named <EM>org.acme.superfun.WidgetBean</EM> results in <B>WidgetBean</B> </TD>
</TR>
<TR>
<TD class="confluenceTd"> ejbClass.packageName </TD>
<TD class="confluenceTd"> for a class named <EM>org.acme.superfun.WidgetBean</EM> results in <B>org.acme.superfun</B> </TD>
</TR>
<TR>
<TD class="confluenceTd"> ejbName </TD>
<TD class="confluenceTd"> The ejb-name as specified in xml or via the 'name' attribute in an @Stateful, @Stateless, or @MessageDriven annotation </TD>
</TR>
<TR>
<TD class="confluenceTd"> deploymentId </TD>
<TD class="confluenceTd"> The unique system id for the ejb. Typically the ejbName unless specified in the openejb-jar.xml or via changing the <SPAN class="nobr"><A href="http://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=OPENEJB&title=openejb.deploymentId.format&linkCreation=true&fromPageId=33329" title="Create Page: openejb.deploymentId.format" class="createlink">OPENEJB:openejb.deploymentId.format<SUP><IMG class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/plus.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN> </TD>
</TR>
<TR>
<TD class="confluenceTd"> interfaceType </TD>
<TD class="confluenceTd"> see interfaceType.annotationName </TD>
</TR>
<TR>
<TD class="confluenceTd"> interfaceType.annotationName </TD>
<TD class="confluenceTd"> Following the EJB 3 annotations @RemoteHome, @LocalHome, @Remote and @Local
<UL class="alternate" type="square">
<LI><B>RemoteHome</B> <EM>(EJB 2 EJBHome)</EM></LI>
<LI><B>LocalHome</B> <EM>(EJB 2 EJBLocalHome)</EM></LI>
<LI><B>Remote</B> <EM>(EJB 3 Business Remote)</EM></LI>
<LI><B>Local</B> <EM>(EJB 3 Business Local)</EM></LI>
<LI><B>Endpoint</B> <EM>(EJB webservice endpoint)</EM></LI>
</UL>
</TD>
</TR>
<TR>
</TR>
<TR>
<TD class="confluenceTd"> interfaceType.xmlName </TD>
<TD class="confluenceTd"> Following the ejb-jar.xml descriptor elements &lt;home&gt;, &lt;local-home&gt;, &lt;business-remote&gt;, &lt;business-local&gt;, and &lt;service-endpoint&gt;:
<UL class="alternate" type="square">
<LI><B>home</B> <EM>(EJB 2 EJBHome)</EM></LI>
<LI><B>local-home</B> <EM>(EJB 2 EJBLocalHome)</EM></LI>
<LI><B>business-remote</B> <EM>(EJB 3 Business Remote)</EM></LI>
<LI><B>business-local</B> <EM>(EJB 3 Business Local)</EM></LI>
<LI><B>service-endpoint</B> <EM>(EJB webservice endpoint)</EM></LI>
</UL>
</TD>
</TR>
<TR>
</TR>
<TR>
<TD class="confluenceTd"> interfaceType.xmlNameCc </TD>
<TD class="confluenceTd"> Camel-case version of interfaceType.xmlName:
<UL class="alternate" type="square">
<LI><B>Home</B> <EM>(EJB 2 EJBHome)</EM></LI>
<LI><B>LocalHome</B> <EM>(EJB 2 EJBLocalHome)</EM></LI>
<LI><B>BusinessRemote</B> <EM>(EJB 3 Business Remote)</EM></LI>
<LI><B>BusinessLocal</B> <EM>(EJB 3 Business Local)</EM></LI>
<LI><B>ServiceEndpoint</B> <EM>(EJB webservice endpoint)</EM></LI>
</UL>
</TD>
</TR>
<TR>
<TD class="confluenceTd"> interfaceType.openejbLegacyName </TD>
<TD class="confluenceTd"> Following the OpenEJB 1.0 hard-coded format:
<UL class="alternate" type="square">
<LI><EM>(empty string)</EM> <EM>(EJB 2 EJBHome)</EM></LI>
<LI><B>Local</B> <EM>(EJB 2 EJBLocalHome)</EM></LI>
<LI><B>BusinessRemote</B> <EM>(EJB 3 Business Remote)</EM></LI>
<LI><B>BusinessLocal</B> <EM>(EJB 3 Business Local)</EM></LI>
<LI><B>ServiceEndpoint</B> <EM>(EJB webservice endpoint)</EM></LI>
</UL>
</TD>
</TR>
<TR>
<TD class="confluenceTd"> interfaceClass </TD>
<TD class="confluenceTd"><UL class="alternate" type="square">
<LI><EM>(business)</EM> for a class named <EM>org.acme.superfun.WidgetRemote</EM> results in <B>org.acme.superfun.WidgetRemote</B></LI>
<LI><EM>(home)</EM> for a class named <EM>org.acme.superfun.WidgetHome</EM> results in <B>org.acme.superfun.WidgetHome</B></LI>
</UL>
</TD>
</TR>
<TR>
</TR>
<TR>
<TD class="confluenceTd"> interfaceClass.simpleName </TD>
<TD class="confluenceTd"><UL class="alternate" type="square">
<LI><EM>(business)</EM> for a class named <EM>org.acme.superfun.WidgetRemote</EM> results in <B>WidgetRemote</B></LI>
<LI><EM>(home)</EM> for a class named <EM>org.acme.superfun.WidgetHome</EM> results in <B>WidgetHome</B></LI>
</UL>
</TD>
</TR>
<TR>
<TD class="confluenceTd"> interfaceClass.packageName </TD>
<TD class="confluenceTd"> for a class named <EM>org.acme.superfun.WidgetRemote</EM> results in <B>org.acme.superfun</B> </TD>
</TR>
</TBODY></TABLE>
<P>This can be set on a server level via a <EM>system property</EM>, for example:</P>
<DIV class="panel"><DIV class="panelContent">
<P>$ ./bin/openejb start &quot;-Dopenejb.jndiname.format={ejbName}/{interfaceClass}&quot;</P>
</DIV></DIV>
<P>Or on a per ejb jar basis in a META-INF/openejb-jar.xml file as follows:</P>
<DIV class="code"><DIV class="codeContent">
<PRE class="code-xml"><SPAN class="code-tag">&lt;openejb-jar&gt;</SPAN>
<SPAN class="code-tag">&lt;properties&gt;</SPAN>
openejb.deploymentId.format = {ejbName}
openejb.jndiname.format = {deploymentId}{interfaceType.annotationName}
<SPAN class="code-tag">&lt;/properties&gt;</SPAN>
<SPAN class="code-tag">&lt;/openejb-jar&gt;</SPAN></PRE>
</DIV></DIV>
<H2><A name="JNDINames-Settings"></A>Settings</H2>
<P><B>You are responsible for ensuring the names don't conflict.</B> </P>
<H3><A name="JNDINames-Conservativesettings"></A>Conservative settings</H3>
<P>A very conservative setting such as &quot;<EM>{deploymentId}/{interfaceClass}</EM>&quot; would guarantee that each and every single interface is bound to JNDI. If your bean had a legacy EJBObject interface, three business remote interfaces, and two business local interfaces, this pattern would result in <B>six</B> proxies bound into JNDI.</P>
<P>Similarly conservative settings would be:</P>
<UL class="alternate" type="square">
<LI><EM>{deploymentId}/{interfaceClass.simpleName}</EM></LI>
<LI><EM>{moduleId}/{ejbName}/{interfaceClass}</EM></LI>
<LI><EM>{ejbName}/{interfaceClass}</EM></LI>
<LI><EM>{moduleId}/{ejbClass}/{interfaceClass}</EM></LI>
<LI><EM>{ejbClass}/{interfaceClass}</EM></LI>
<LI><EM>{ejbClass}/{interfaceClass.simpleName}</EM></LI>
<LI><EM>{ejbClass.simpleName}/{interfaceClass.simpleName}</EM></LI>
<LI><EM>{interfaceClass}/{ejbName}</EM></LI>
</UL>
<P>Bordeline optimistic:</P>
<UL class="alternate" type="square">
<LI><EM>{moduleId}/{interfaceClass}</EM></LI>
<LI><EM>{interfaceClass}</EM></LI>
</UL>
<P>The above two settings would work if you the interface wasn't shared by other beans.</P>
<H3><A name="JNDINames-Pragmaticsettings"></A>Pragmatic settings</H3>
<P>A more middle ground setting such as &quot;<EM>{deploymentId}{interfaceType.annotationName}</EM>&quot; would guarantee that at least one proxy of each interface type is bound to JNDI. If your bean had a legacy EJBObject interface, three business remote interfaces, and two business local interfaces, this pattern would result in <B>three</B> proxies bound into JNDI: one proxy dedicated to your EJBObject interface; one proxy implementing all three business remote interfaces; one proxy implementing the two business local interfaces.</P>
<P>Similarly pragmatic settings would be:</P>
<UL class="alternate" type="square">
<LI><EM>{moduleId}/{ejbClass}/{interfaceType.annotationName}</EM></LI>
<LI><EM>{ejbClass}/{interfaceType.xmlName}</EM></LI>
<LI><EM>{ejbClass.simpleName}/{interfaceType.xmlNameCc}</EM></LI>
<LI><EM>{interfaceType}/{ejbName}</EM></LI>
<LI><EM>{interfaceType}/{ejbClass}</EM></LI>
</UL>
<H3><A name="JNDINames-Optimisticsettings"></A>Optimistic settings</H3>
<P>A very optimistic setting such as &quot;<EM>{deploymentId}</EM>&quot; would guarantee only one proxy for the bean will be bound to JNDI. This would be fine if you knew you only had one type of interface in your beans. For example, only business remote interfaces, or only business local interfaces, or only an EJBObject interface, or only an EJBLocalObject interface.</P>
<P>If a bean in the app did have more than one interface type, one business local and one business remote for example, by default OpenEJB will reject the app when it detects that it cannot bind the second interface. This strict behavior can be disabled by setting the <B>openejb.jndiname.failoncollision</B> system property to <EM>false</EM>. When this property is set to false, we will simply log an error that the second proxy cannot be bound to JNDI, tell you which ejb is using that name, and continue loading your app.</P>
<P>Similarly optimistic settings would be:</P>
<UL class="alternate" type="square">
<LI><EM>{ejbName}</EM></LI>
<LI><EM>{ejbClass}</EM></LI>
<LI><EM>{ejbClass.simpleName}</EM></LI>
<LI><EM>{moduleId}/{ejbClass.simpleName}</EM></LI>
<LI><EM>{moduleId}/{ejbName}</EM></LI>
</UL>
<H1><A name="JNDINames-AdvancedDetailsonEJB3.0BusinessProxies%28thesimplepart%29"></A>Advanced Details on EJB 3.0 Business Proxies (the simple part)</H1>
<P>If you implement your business interfaces, your life is simple as your proxies will also implement your business interfaces of the same type. Meaning any proxy OpenEJB creates for a business local interface will also implement your other business local interfaces. Similarly, any proxy OpenEJB creates for a business remote interface will also implement your other business remote interfaces.</P>
<H1><A name="JNDINames-AdvancedDetailsonEJB3.0BusinessProxies%28thecomplicatedpart%29"></A>Advanced Details on EJB 3.0 Business Proxies (the complicated part)</H1>
<P>{info:Who should read?}<BR>
Read this section of either of these two apply to you:</P>
<UL class="alternate" type="square">
<LI>You do not implement your business interfaces in your bean class</LI>
<LI>One or more of your business remote interfaces extend from javax.rmi.Remote</LI>
</UL>
<P>If neither of these two items describe your apps, then there is no need to read further. Go have fun.<BR>
{info}</P>
<H3><A name="JNDINames-Notimplementingbusinessinterfaces"></A>Not implementing business interfaces</H3>
<P>If you do not implement your business interfaces it may not be possible for us to implement all your business interfaces in a single interface. Conflicts in the throws clauses and the return values can occur as detailed <A href="multiple-business-interface-hazzards.html" title="Multiple Business Interface Hazzards">here</A>. When creating a proxy for an interface we will detect and remove any other business interfaces that would conflict with the main interface.</P>
<H3><A name="JNDINames-Businessinterfacesextendingjavax.rmi.Remote"></A>Business interfaces extending javax.rmi.Remote</H3>
<P>Per spec rules many runtime exceptions (container or connection related) are thrown from javax.rmi.Remote proxies as java.rmi.RemoteException which is not a runtime exception and must be throwable via the proxy as a checked exception. The issue is that conflicting throws clauses are actually removed for two interfaces sharing the same method signature. For example two methods such as these:</P>
<UL class="alternate" type="square">
<LI>InterfaceA: void doIt() throws Foo;</LI>
<LI>InterfaceB: void doIt() throws RemoteException;</LI>
</UL>
<P>can be implemented by trimming out the conflicting throws clauses as follows:</P>
<UL class="alternate" type="square">
<LI>Implementation: void doIt(){}</LI>
</UL>
<P>This is fine for a bean class as it does not need to throw the RMI required javax.rmi.RemoteException. However if we create a proxy from these two interfaces it will also wind up with a 'doIt(){}' method that cannot throw javax.rmi.RemoteException. This is very bad as the container does need to throw RemoteException to any business interfaces extending java.rmi.Remote for any container related issues or connection issues. If the container attempts to throw a RemoteException from the proxies 'doIt(){}' method, it will result in an UndeclaredThrowableException thrown by the VM.</P>
<P>The only way to guarantee the proxy has the 'doIt() throws RemoteException {}' method of InterfaceB is to cut out InterfaceA when we create the proxy dedicated to InterfaceB.</P>
</DIV>
</DIV>
</DIV>
</P>
</TD>
</TR>
<TR height="5">
<TD width="20" height="5" bgcolor="#7270c2" valign="top" align="left">&nbsp;</TD>
<TD width="95" height="5" bgcolor="#7270c2" valign="top">&nbsp;</TD>
<TD width="7" height="5" bgcolor="#a9a5de" valign="top" align="left">&nbsp;</TD>
<TD width="40" height="5" valign="top" align="left">&nbsp;</TD>
<TD width="120" height="5" valign="top" align="left">&nbsp;</TD>
</TR>
<TR>
<TD width="20" height="5" bgcolor="#7270c2" valign="top" align="left">&nbsp;</TD>
<TD width="95" bgcolor="#7270c2" valign="BOTTOM" align="left">&nbsp;</TD>
<TD width="7" bgcolor="#a9a5de" valign="top" align="left"><IMG src="http://openejb.apache.org/images/dotTrans.gif" width="1" height="25" border="0"></TD>
<TD width="40" valign="top" align="left"><IMG src="http://openejb.apache.org/images/dotTrans.gif" width="1" height="25" border="0"></TD>
<TD width="120" valign="top" align="left">&nbsp;</TD>
</TR>
<TR>
<TD width="20" height="5" bgcolor="#7270c2" valign="top" align="left">&nbsp;</TD>
<TD width="95" bgcolor="#7270c2" valign="BOTTOM" align="left">&nbsp;</TD>
<TD width="7" bgcolor="#a9a5de" valign="top" align="left"><IMG src="http://openejb.apache.org/images/dotTrans.gif" width="1" height="25" border="0"></TD>
<TD width="40" valign="top" align="left"><IMG src="http://openejb.apache.org/images/dotTrans.gif" width="1" height="25" border="0"></TD>
<TD width="120" valign="top" align="left">&nbsp;</TD>
</TR>
<TR height="5">
<TD width="20" rowspan="2" height="100%" bgcolor="#7270c2" valign="bottom" align="left"><IMG src="http://openejb.apache.org/images/stripes1.gif" width="20" height="125" border="0"></TD>
<TD width="95" rowspan="2" height="100%" bgcolor="#7270c2" valign="bottom" align="left"><IMG src="http://openejb.apache.org/images/stripe105.gif" width="105" height="125" border="0"></TD>
<TD width="7" rowspan="2" height="100%" bgcolor="#a9a5de" valign="top" align="left">&nbsp;</TD>
<TD width="40" height="100%" valign="top" align="left">&nbsp;</TD>
<TD width="120" height="100%" valign="top" align="left">&nbsp;</TD>
</TR>
<TR height="5">
<TD width="40" height="25" valign="top" align="left">&nbsp;</TD>
<TD width="100%" height="25" valign="bottom" align="left"><BR>
<BR>
<IMG src="http://openejb.apache.org/images/line_light.gif" border="0" width="430" height="3"><BR>
<P>
</P>
<SPAN class="bodyGrey">
<SMALL><NOTICE><!-- $FOOTER -->
Apache OpenEJB is an project of The Apache Software Foundation (ASF)
</NOTICE> <BR>
&nbsp;<BR>
Powered by <A href="http://atlassian.com/">Atlassian</A> <A href="http://atlassian.com/confluence/">Confluence</A>.
</SMALL>
</SPAN>
<P>
</P>
</TD>
<TD width="120" height="25" valign="top" align="left">&nbsp;</TD>
</TR>
</TABLE>
<!-- Needed for composition plugin -->
<!-- delay the loading of large javascript files to the end so that they don't interfere with the loading of page content -->
<SPAN style="display: none">
<SCRIPT type="text/javascript" language="JavaScript" src="http://cwiki.apache.org/confluence/labels-javascript"></SCRIPT>
<SCRIPT src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</SCRIPT>
<SCRIPT type="text/javascript">
_uacct = "UA-2717626-1";
urchinTracker();
</SCRIPT>
</SPAN>
</BODY>
</HTML>