blob: 29d535c89de36a60fac11a51a4caf9b4e15393bf [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 - Details on openejb-jar</TITLE>
<LINK href="http://openejb.apache.org/all.css" rel="stylesheet" type="text/css">
<!--[if IE]><link rel="stylesheet" type="text/css" media="screen, projection" href="openejb.apache.org/ie.css"><![endif]-->
<LINK rel="SHORTCUT ICON" href="http://openejb.apache.org/images/favicon.ico">
<META http-equiv="Content-Type" content="text/html;charset=UTF-8">
<SCRIPT language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></SCRIPT>
<SCRIPT language="javascript" src="http://openejb.apache.org/tweet/jquery.tweet.js" type="text/javascript"></SCRIPT>
<SCRIPT type="text/javascript">
$(document).ready(function(){
$(".tweet").tweet({
avatar_size: 32,
count: 4,
fetch:25,
username: "openejb",
list: "contributors",
template:"{avatar}{text}",
filter: function(t){ return /openejb/i.test(t["tweet_raw_text"]); },
loading_text: "loading list..."
});
});
</SCRIPT>
</HEAD>
<BODY>
<!-- 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 class="frameTable" cellpadding="0" cellspacing="0" border="0">
<TR class="Row1">
<TD class="Col1"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD>
<TD class="Col2"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD>
<TD class="Col3"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD>
<TD class="Col4"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD>
<TD class="Col5"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD>
</TR>
<TR class="Row2">
<TD class="Col1"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD>
<TD class="Col2">&nbsp;</TD>
<TD class="Col3" id="breadcrumbs">
<!-- $TOP_NAV_BAR -->
<A href="index.html" title="Index">Home</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> | <A href="http://issues.apache.org/jira/browse/OPENEJB" class="external-link" rel="nofollow">Issues</A>
</TD>
<TD class="Col4"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD>
<TD class="Col5">&nbsp;</TD>
</TR>
<TR class="Row3">
<TD class="Col1"><IMG alt="" class="Row3Img" id="thinLine" src="http://openejb.apache.org/images/line_sm.gif"></TD>
<TD class="Col2"><IMG alt="" class="Row3Img" src="http://openejb.apache.org/images/dotTrans.gif"></TD>
<TD class="Col3"><IMG alt="" class="Row3Img" src="http://openejb.apache.org/images/dotTrans.gif"></TD>
<TD class="Col4"><IMG alt="" src="http://openejb.apache.org/images/dotTrans.gif"></TD>
<TD class="Col5"><IMG alt="" class="Row3Img" src="http://openejb.apache.org/images/dotTrans.gif"></TD>
</TR>
<TR class="Row4">
<TD class="Col1">
<SPAN id="Navigation">
<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="../OPENEJBx30/index.html" title="Index">Documentation</A></LI>
<LI><A href="examples.html" title="Examples">Examples</A></LI>
<LI><A href="http://cwiki.apache.org/confluence/display/OPENEJB/Lightening%20Demos" class="external-link" rel="nofollow">Lightning Demos</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>
<LI><A href="http://blogs.apache.org/openejb" class="external-link" rel="nofollow">Project Blog</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="../OPENEJBx30/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="http://webchat.freenode.net/?channels=openejb" class="external-link" rel="nofollow">IRC</A></LI>
</UL>
<H3><A name="Navigation-RelatedProjects"></A>Related Projects</H3>
<UL class="alternate" type="square">
<LI><A href="http://activemq.apache.org/" class="external-link" rel="nofollow">ActiveMQ</A></LI>
<LI><A href="http://openjpa.apache.org/" class="external-link" rel="nofollow">OpenJPA</A></LI>
<LI><A href="http://cxf.apache.org/" class="external-link" rel="nofollow">CXF</A></LI>
</UL>
<H3><A name="Navigation-Index"></A>Index</H3>
<UL class="alternate" type="square">
<LI><A href="space-index.html" title="Space Index">Site Index</A></LI>
<LI><A href="../OPENEJBx30/space-index.html" title="Space Index">Doc Index</A></LI>
</UL>
<H3>
<A name="Navigation-Feeds"></A>
Feeds
</H3>
<UL class="feeds">
<LI>
<A href="http://cwiki.apache.org/confluence/spaces/rss.action?key=OPENEJB&newPages=false">
<IMG src="http://openejb.apache.org/images/rss.gif"></A>
<A class="feedsText" href="http://cwiki.apache.org/confluence/spaces/rss.action?key=OPENEJB&newPages=false">Site</A>
</LI>
<LI><A href="http://cwiki.apache.org/confluence/spaces/blogrss.action?key=OPENEJB">
<IMG src="http://openejb.apache.org/images/rss.gif"></A>
<A class="feedsText" href="http://cwiki.apache.org/confluence/spaces/blogrss.action?key=OPENEJB">News</A>
</LI>
</UL>
</SPAN>
</TD>
<TD class="Col2">&nbsp;</TD>
<TD class="Col3">
<TABLE id="PageHeader" border="0" width="100%">
<TR>
<TD>
<A href="http://openejb.org/">
<IMG hspace="0" src="http://openejb.apache.org/images/logo_openejb.gif" vspace="0">
</A>
</TD>
<TD align="right">
<A href="http://www.apache.org/">
<IMG src="http://www.apache.org/images/asf-logo.gif" width="258" height="66">
</A>
</TD>
</TR>
<TR>
<TD id="page_title">
<!-- $TITLE -->
Details on openejb-jar
</TD>
<TD align="right">
<BR><BR>
<!-- Google CSE Search Box Begins -->
<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>
<!-- Google CSE Search Box Ends -->
</TD>
</TR>
</TABLE>
<P>
<!-- $BODY -->
<DIV id="PageContent">
<H1><A name="Detailsonopenejb-jar-Whatisanopenejbjar.xml%3F"></A>What is an openejb-jar.xml?</H1>
<P>This is the file created by the Deploy Tool that maps your bean's deployment descriptor (ejb-jar.xml) to actual containers and resources declared in your OpenEJB configuration (openejb.conf). In fact, the Deploy tool really does nothing more than create this file and put it in your jar, that's it.</P>
<H1><A name="Detailsonopenejb-jar-Whenistheopenejbjar.xmlused%3F"></A>When is the openejb-jar.xml used?</H1>
<P>At startup, any jar containing a openejb-jar.xml is loaded by the container system. The configuration tools will go looking in all the directories and jars you have declared in your openejb.conf with the &lt;Deployment&gt; element. For every jar file it finds, it will look inside for an openejb-jar.xml. If it finds one, it will attempt to load and deploy it into the container system.</P>
<H1><A name="Detailsonopenejb-jar-DoIevenneedthedeploytoolthen%3F"></A>Do I even need the deploy tool then?</H1>
<P>Nope. Typically you would only use the deploy tool to create your openejb-jar.xml, then just keep your openejb-jar.xml in your CVS (or other repository). If you learn how to maintain this openejb-jar.xml file, you'll never need the deploy tool again! You can do all your builds and deploys automatically.</P>
<H1><A name="Detailsonopenejb-jar-WheredoIputtheopenejbjar.xmlinmyjar%3F"></A>Where do I put the openejb-jar.xml in my jar?</H1>
<P>The openejb-jar.xml file just goes in the META-INF directory of your jar next to the ejb-jar.xml file.</P>
<H1><A name="Detailsonopenejb-jar-Isthefileformateasy%3F"></A>Is the file format easy?</H1>
<P>If you can understand the ejb-jar.xml, the openejb-jar.xml should be a breeze.</P>
<P>This is the openejb-jar.xml that is created by the Deploy tool in the Hello World example. As you can see, the file format is extremely simple.</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;"><B>openejb-jar.xml</B></DIV><DIV class="codeContent panelContent">
<PRE class="code-xml"><SPAN class="code-tag">&lt;?xml version=<SPAN class="code-quote">&quot;1.0&quot;</SPAN>?&gt;</SPAN>
<SPAN class="code-tag">&lt;openejb-jar xmlns=<SPAN class="code-quote">&quot;http://www.openejb.org/openejb-jar/1.1&quot;</SPAN>&gt;</SPAN>
&lt;ejb-deployment ejb-name=<SPAN class="code-quote">&quot;Hello&quot;</SPAN>
deployment-id=<SPAN class="code-quote">&quot;Hello&quot;</SPAN>
container-id=<SPAN class="code-quote">&quot;Default Stateless Container&quot;</SPAN>/&gt;
<SPAN class="code-tag">&lt;/openejb-jar&gt;</SPAN>
</PRE>
</DIV></DIV>
<P>The <B>ejb-name</B> attribute is the name you gave the bean in your ejb-jar.xml. The <B>deployment-id</B> is the name you want to use to lookup the bean in your client's JNDI namespace. The <B>container-id</B> is the name of the container in your openejb.conf file that you would like the bean to run in. There MUST be one <B>ejb-deployment</B> element for each EJB in your jar.</P>
<H1><A name="Detailsonopenejb-jar-WhatifmybeanusesaJDBCdatasource%3F"></A>What if my bean uses a JDBC datasource?</H1>
<P>Then you simply add a &lt;resource-link&gt; element to your &lt;ejb-deployment&gt; element like this</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;"><B>openejb-jar.xml</B></DIV><DIV class="codeContent panelContent">
<PRE class="code-xml"><SPAN class="code-tag">&lt;?xml version=<SPAN class="code-quote">&quot;1.0&quot;</SPAN>?&gt;</SPAN>
<SPAN class="code-tag">&lt;openejb-jar xmlns=<SPAN class="code-quote">&quot;http://www.openejb.org/openejb-jar/1.1&quot;</SPAN>&gt;</SPAN>
&lt;ejb-deployment ejb-name=<SPAN class="code-quote">&quot;Hello&quot;</SPAN>
deployment-id=<SPAN class="code-quote">&quot;Hello&quot;</SPAN>
container-id=<SPAN class="code-quote">&quot;Default Stateless Container&quot;</SPAN> &gt;
&lt;resource-link res-ref-name=<SPAN class="code-quote">&quot;jdbc/basic/entityDatabase&quot;</SPAN>
res-id=<SPAN class="code-quote">&quot;Default JDBC Database&quot;</SPAN>/&gt;
<SPAN class="code-tag">&lt;/ejb-deployment&gt;</SPAN>
<SPAN class="code-tag">&lt;/openejb-jar&gt;</SPAN>
</PRE>
</DIV></DIV>
<P>The <B>res-ref-name</B> attribute refers to the &lt;res-ref-name&gt; element of the bean's &lt;resource-ref&gt; declaration in the ejb-jar.xml. The <B>res-id</B> attribute refers to the id of the &lt;Connector&gt; declared in your openejb.conf that will handle the connections and provide access to the desired resource.</P>
<H1><A name="Detailsonopenejb-jar-HowmanyresourcelinkelementswillIneed%3F"></A>How many resource-link elements will I need?</H1>
<P>You will need one &lt;resource-link&gt; element for every &lt;resource-ref&gt; element in your ejb-jar.xml. So if you had an ejb-jar.xml like the following</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;"><B>ejb-jar.xml</B></DIV><DIV class="codeContent panelContent">
<PRE class="code-xml"><SPAN class="code-tag">&lt;?xml version=<SPAN class="code-quote">&quot;1.0&quot;</SPAN>?&gt;</SPAN>
<SPAN class="code-tag">&lt;ejb-jar&gt;</SPAN>
<SPAN class="code-tag">&lt;enterprise-beans&gt;</SPAN>
<SPAN class="code-tag">&lt;session&gt;</SPAN>
<SPAN class="code-tag">&lt;ejb-name&gt;</SPAN>MyExampleBean<SPAN class="code-tag">&lt;/ejb-name&gt;</SPAN>
<SPAN class="code-tag">&lt;home&gt;</SPAN>com.widget.ExampleHome<SPAN class="code-tag">&lt;/home&gt;</SPAN>
<SPAN class="code-tag">&lt;remote&gt;</SPAN>com.widget.ExampleObject<SPAN class="code-tag">&lt;/remote&gt;</SPAN>
<SPAN class="code-tag">&lt;ejb-class&gt;</SPAN>com.widget.ExampleBean<SPAN class="code-tag">&lt;/ejb-class&gt;</SPAN>
<SPAN class="code-tag">&lt;session-type&gt;</SPAN>Stateless<SPAN class="code-tag">&lt;/session-type&gt;</SPAN>
<SPAN class="code-tag">&lt;transaction-type&gt;</SPAN>Container<SPAN class="code-tag">&lt;/transaction-type&gt;</SPAN>
<SPAN class="code-tag">&lt;resource-ref&gt;</SPAN>
<SPAN class="code-tag">&lt;description&gt;</SPAN>
This is a reference to a JDBC database.
<SPAN class="code-tag">&lt;/description&gt;</SPAN>
<SPAN class="code-tag">&lt;res-ref-name&gt;</SPAN>jdbc/myFirstDatabase<SPAN class="code-tag">&lt;/res-ref-name&gt;</SPAN>
<SPAN class="code-tag">&lt;res-type&gt;</SPAN>javax.sql.DataSource<SPAN class="code-tag">&lt;/res-type&gt;</SPAN>
<SPAN class="code-tag">&lt;res-auth&gt;</SPAN>Container<SPAN class="code-tag">&lt;/res-auth&gt;</SPAN>
<SPAN class="code-tag">&lt;/resource-ref&gt;</SPAN>
<SPAN class="code-tag">&lt;resource-ref&gt;</SPAN>
<SPAN class="code-tag">&lt;description&gt;</SPAN>
This is another reference to a JDBC database.
<SPAN class="code-tag">&lt;/description&gt;</SPAN>
<SPAN class="code-tag">&lt;res-ref-name&gt;</SPAN>jdbc/anotherDatabase<SPAN class="code-tag">&lt;/res-ref-name&gt;</SPAN>
<SPAN class="code-tag">&lt;res-type&gt;</SPAN>javax.sql.DataSource<SPAN class="code-tag">&lt;/res-type&gt;</SPAN>
<SPAN class="code-tag">&lt;res-auth&gt;</SPAN>Container<SPAN class="code-tag">&lt;/res-auth&gt;</SPAN>
<SPAN class="code-tag">&lt;/resource-ref&gt;</SPAN>
<SPAN class="code-tag">&lt;/session&gt;</SPAN>
<SPAN class="code-tag">&lt;/enterprise-beans&gt;</SPAN>
<SPAN class="code-tag">&lt;/ejb-jar&gt;</SPAN>
</PRE>
</DIV></DIV>
<P>Then you would need two &lt;resource-link&gt; elements for that bean in your openejb-jar.xml file as such.</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;"><B>openejb-jar.xml</B></DIV><DIV class="codeContent panelContent">
<PRE class="code-xml"><SPAN class="code-tag">&lt;?xml version=<SPAN class="code-quote">&quot;1.0&quot;</SPAN>?&gt;</SPAN>
<SPAN class="code-tag">&lt;openejb-jar xmlns=<SPAN class="code-quote">&quot;http://www.openejb.org/openejb-jar/1.1&quot;</SPAN>&gt;</SPAN>
&lt;ejb-deployment ejb-name=<SPAN class="code-quote">&quot;MyExampleBean&quot;</SPAN>
deployment-id=<SPAN class="code-quote">&quot;MyExampleBean&quot;</SPAN>
container-id=<SPAN class="code-quote">&quot;Default Stateless Container&quot;</SPAN> &gt;
&lt;resource-link res-ref-name=<SPAN class="code-quote">&quot;jdbc/myFirstDatabase&quot;</SPAN>
res-id=<SPAN class="code-quote">&quot;My Oracle JDBC Database&quot;</SPAN>/&gt;
&lt;resource-link res-ref-name=<SPAN class="code-quote">&quot;jdbc/anotherDatabase&quot;</SPAN>
res-id=<SPAN class="code-quote">&quot;My PostgreSQL JDBC Database&quot;</SPAN>/&gt;
<SPAN class="code-tag">&lt;/ejb-deployment&gt;</SPAN>
<SPAN class="code-tag">&lt;/openejb-jar&gt;</SPAN>
</PRE>
</DIV></DIV>
<P>This would require two &lt;Connector&gt; declarations in your openejb.conf, one with the <B>id</B> attribute set to <EM>&quot;My Oracle JDBC Database&quot;</EM> , and another with it's <B>id</B> attribute set to <EM>&quot;My PostgreSQL JDBC Database&quot;</EM> </P>
</DIV>
</P>
</TD>
<TD class="Col4"><IMG src="http://openejb.apache.org/images/dotTrans.gif"></TD>
<TD class="Col5">
</TD>
</TR>
<TR class="Row5">
<TD class="Col1">&nbsp;</TD>
<TD class="Col2">&nbsp;</TD>
<TD class="Col3">
<BR>
<BR>
<IMG width="100%" height="1" src="http://openejb.apache.org/images/line_light.gif">
<TABLE width="100%">
<TR>
<TD>
<SPAN class="bodyGrey">
<SMALL>
<NOTICE><!-- $FOOTER -->
Apache OpenEJB is an project of The Apache Software Foundation (ASF)
</NOTICE>
<BR>
Site Powered by
<A href="http://atlassian.com/">Atlassian</A>
<A href="http://atlassian.com/confluence/">Confluence</A>
.
</SMALL>
</SPAN>
</TD>
<TD align="right">
<A style="color:#999;font-size:small;font-weight:normal;" href="https://cwiki.apache.org/confluence/pages/editpage.action?spaceKey=OPENEJB&title=Details%20on%20openejb-jar">[ edit ]</A>
</TD>
</TR>
</TABLE>
<BR>
</TD>
<TD class="Col4"><IMG src="http://openejb.apache.org/images/dotTrans.gif"></TD>
<TD class="Col5">&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>