📄 ch13s72.html
字号:
<context-root>/myapp</context-root>
</web>
</module>
<module>
<ejb>ejb-app.jar</ejb>
</module>
</application>
</pre></div><p> This descriptor describes an application that contains a web application
package (JSPs/Servlets/HTML) and an ejb application (EJBs). The web applications war
package is located at the root of the .ear file and is named web-app.war. It will be
deployed under the webcontext /myapp. The ejb package also resides in the applications
root directory and is called ejb-app.jar.
</p><p>Understanding the shared classloader architecture in JBoss</p><p>When an application in JBoss gets deployed, every module will get deployed by
a separate container. Every container will get its own classloader - this means that a
call from one module to an other must be an remote call and all parameters must be serialized,
because the classes (even if they are loaded from the same physical file) are not compatible
across container boundaries. To allow optimized interaction across container boundaries (local
calls with parameter ... per reference) the classes that are involved in this communication
must be loaded by the same classloader.
</p><p>In JBoss we achieve this issue with the following classloader architecture:
</p><p>On deployment one common classloader is created. This classloader will get all archives in its
classpath that are referenced in MANIFEST.MF/Class-Path<sup>[<a href="#ftn.classpath.gotcha">1</a>]</sup> entries of the each individual module
contained in enclosing application. <a href="ch13s72.html#web-manifest-figure" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s72.html#web-manifest-figure" title="Figure 13.6. Example Manifest file of web module">Figure 13.6</a> shows such an entry
</p><p>When afterwards all modules become deployed in their containers, the
classloaders created by these containers are all children of the common classloader.
</p><p>Now on runtime the communication between modules across container
boundaries can be optimized when the classes used for the communication are
loaded by the common classloader.
</p><p>To allow our previous mentioned simple example to make use of the
optimization, we must provide the classes the web
module needs to communicate with the ejb module in an separate third package,
lets call it ejb-client.jar.
This ejb-client.jar archive contains the remote interfaces of the ejbs and
special method parameter types that are
needed for the communication (if any). Now we put this package in the
directory /lib of our application.
</p><p>To make sure that this package is now loaded by the common classloader, we
reference it from within the web package by adding a Class-Path entry to the web
packages MANIFEST.MF file<sup>[<a href="#ftn.classpath.gotcha2">2</a>]</sup>.
</p><div class="figure"><p><a name="web-manifest-figure"></a><b>Figure 13.6. Example Manifest file of web module</b></p><div class="literallayout"> <br>
<tt> Manifest-Version: 1.0<br>
Class-Path: ./lib/ejb-client.jar<br>
</tt> <br>
</div></div><p>Now you just jar your applications directory, name it <anyhow>.ear, and drop it in
one of JBoss' autodeploy directories.
</p><div class="figure"><p><a name="application-manifest-figure"></a><b>Figure 13.7. Example application archive contents</b></p><div class="literallayout"><br>
<tt> META-INF/<br>
META-INF/MANIFEST.MF<br>
META-INF/application.xml<br>
ejb-app.jar<br>
web-app.war<br>
lib/<br>
lib/ejb-client.jar<br>
</tt> <br>
</div></div><p>
Note:
<div class="orderedlist"><ol type="1"><li><p><a name="d0e10703"></a>The MANIFEST.MF as shown in <a href="ch13s72.html#web-manifest-figure" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s72.html#web-manifest-figure" title="Figure 13.6. Example Manifest file of web module">Figure 13.6</a> is inside of the ejb or the war
archive and NOT the one directly in the ear archive.
</p></li><li><p><a name="d0e10708"></a>There should be a carriage return after the Class-Path entry in the manifest file - otherwise it is not found.
</p></li></ol></div>
</p><p>
Some useful references are <a href="javascript:if(confirm('http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html'" tppabs="http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html" target="_top">Manifest tutorial</a>
and <a href="javascript:if(confirm('http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html'" tppabs="http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html" target="_top">Jar specification</a>
</p></div><div class="section"><a name="d0e10720"></a><div class="titlepage"><div><h3 class="title"><a name="d0e10720"></a>Notes</h3></div></div><p>
<div class="footnote"><p><sup>[<a name="ftn.classpath.gotcha" href="#classpath.gotcha">1</a>] </sup>The MANIFEST.MF referred to is the one inside the ejb or war archive and NOT the one directly in the ear archive.</p></div>
<div class="footnote"><p><sup>[<a name="ftn.classpath.gotcha2" href="#classpath.gotcha2">2</a>] </sup>There is a "feature" of the jdk jarfile reader that means that you need to have a carriage return after the Class-Path entry in the manifest file - otherwise it is not found.</p></div>
</p></div><div class="footnotes"><br><hr width="100" align="left"><div class="footnote"><p><sup>[<a name="ftn.classpath.gotcha" href="#classpath.gotcha">1</a>] </sup>The MANIFEST.MF referred to is the one inside the ejb or war archive and NOT the one directly in the ear archive.</p></div><div class="footnote"><p><sup>[<a name="ftn.classpath.gotcha2" href="#classpath.gotcha2">2</a>] </sup>There is a "feature" of the jdk jarfile reader that means that you need to have a carriage return after the Class-Path entry in the manifest file - otherwise it is not found.</p></div></div></div><table border="0" cellpadding="0" cellspacing="0" height="65"><tr height="65"><td rowspan="2"><img src="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="432" height="79"></td><td rowspan="2" background="gbar.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/gbar.gif" width="100%" align="right" valign="top"><a href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html"><img src="doc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/doc.gif" border="0"></a><a href="ch13.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13.html"><img src="toc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/toc.gif" border="0"></a><a href="ch13s58.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s58.html"><img src="prev.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/prev.gif" border="0"></a><a href="ch13s78.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s78.html"><img src="next.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/next.gif" border="0"></a></td></tr><tr></tr></table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -