📄 ch14.html
字号:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter 14. Third Party Examples</title><link rel="stylesheet" href="styles.css" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/styles.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets Vimages/callouts/"><link rel="home" href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html" title="JBoss 3.0 Documentation"><link rel="up" href="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html" title="JBoss 3.0 Documentation"><link rel="previous" href="ch13s144.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s144.html" title="Clustering in JBoss 3.0 alpha"><link rel="next" href="ch14s02.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch14s02.html" title="Deploying the Pet Store 1.1.2 Demo in JBoss"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table border="0" cellpadding="0" cellspacing="0" height="65"><tr height="65"><td rowspan="2"><img src="jboss.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/jboss.gif" border="0"></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="index.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/index.html"><img src="toc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/toc.gif" border="0"></a><a href="ch13s144.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch13s144.html"><img src="prev.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/prev.gif" border="0"></a><a href="ch14s02.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch14s02.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><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="d0e12085"></a>Chapter 14. Third Party Examples</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="ch14.html#d0e12088" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch14.html#d0e12088">Running the Examples from Enterprise JavaBeans, by Richard Monson-Haefel (Unix) </a></dt><dt><a href="ch14s02.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch14s02.html">Deploying the Pet Store 1.1.2 Demo in JBoss</a></dt><dt><a href="ch14s07.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch14s07.html">Deploying Cocoon 2 in JBoss</a></dt><dt><a href="ch14s12.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch14s12.html">Using SSL with JBoss</a></dt></dl></div><div class="section"><a name="d0e12088"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="d0e12088"></a>Running the Examples from Enterprise JavaBeans, by Richard Monson-Haefel (Unix) </h2></div></div><p>Author:<span class="author">Sebastien Alborini</span>
<tt><<a href="mailto:sebastien.alborini@m4x.org">sebastien.alborini@m4x.org</a>></tt>
</p><p>This page describes how to run the examples from Richard Monson-Haefel's book Enterprise JavaBeans, 2nd Edition
(Chapter 4) in JBoss.</p><p>You can download <a href="javascript:if(confirm('http://www.oreilly.com/catalog/entjbeans2/chapter/examples.zip \n\nThis file was not retrieved by Teleport Pro, because it did not meet the project\'s file type specifications. \n\nDo you want to open it from the server?'))window.location='http://www.oreilly.com/catalog/entjbeans2/chapter/examples.zip'" tppabs="http://www.oreilly.com/catalog/entjbeans2/chapter/examples.zip" target="_top">the examples</a> (zip file) from O'Reilly's site. I will assume you have unzipped this file and you work in
the chapter4/EJB11 directory.</p><p>These examples need to be slightly modified to run with JBoss. You can download the modified version <a href="javascript:if(confirm('http://www.jboss.org/documentation/rmh_jboss.zip \n\nThis file was not retrieved by Teleport Pro, because it did not meet the project\'s file type specifications. \n\nDo you want to open it from the server?'))window.location='http://www.jboss.org/documentation/rmh_jboss.zip'" tppabs="http://www.jboss.org/documentation/rmh_jboss.zip" target="_top">here</a>, but I
recommend you to follow these instructions which tell exactly what has to be modified.</p><div class="itemizedlist"><ul><li><p><a name="d0e12115"></a>Setup your environment.</p><p>JBoss libraries will be needed to compile and run the examples, so you have to set the environment variable
JBOSS_HOME to your JBoss installation. For example:
<div class="itemizedlist"><ul><li><p><a name="d0e12121"></a>export JBOSS_HOME=$HOME/jboss_pr4 if you have the binary version in your home directory </p></li><li><p><a name="d0e12124"></a>export JBOSS_HOME=$HOME/jboss/dist if you have the CVS version.</p></li></ul></div>
</p></li><li><p><a name="d0e12128"></a>Compile and deploy the beans.</p><p>The beans are almost ok for JBoss, the only difference is about the reference made by TravelAgentBean to
CabinBean: a bean must lookup in the java:comp/env namespace. Edit
com/titan/travelagent/TravelAgentBean.java, and replace
<pre class="programlisting"> Object obj = jndiContext.lookup("ejb/CabinHome");</pre>
with
<pre class="programlisting"> Object obj = jndiContext.lookup("java:comp/env/ejb/CabinHome"); </pre>
</p><p> This ejb-reference from TravelAgentBean (in travelagent.jar) to CabinBean (in cabin.jar) is an external
reference (different ejb-jar file). You must then provide the full jndi name for CabinBean in a jboss.xml for
TravelAgentBean: create and edit com/titan/travelagent/jboss.xml
<pre class="programlisting">
<?xml version="1.0"?>
<jboss>
<enterprise-beans>
<session>
<ejb-name>TravelAgentBean</ejb-name>
<ejb-ref>
<ejb-ref-name>ejb/CabinHome</ejb-ref-name>
<jndi-name>CabinBean</jndi-name>
</ejb-ref>
</session>
</enterprise-beans>
</jboss>
</pre>
</p><p>
You don't jave to change anything in ejb-jar.xml. You can now use the following script jbossMakeIt.sh to
compile and deploy:
<div class="literallayout"> <br>
<br>
<b><br>
#!/bin/sh <br>
<br>
# make cabin bean<br>
<br>
javac -classpath $JBOSS_HOME/lib/ext/ejb.jar:. \<br>
com/titan/cabin/Cabin*.java<br>
<br>
cp com/titan/cabin/ejb-jar.xml META-INF/ejb-jar.xml<br>
jar cvf cabin.jar com/titan/cabin/Cabin*.class META-INF/ejb-jar.xml<br>
<br>
<br>
# make travelagent bean<br>
<br>
javac -classpath $JBOSS_HOME/lib/ext/ejb.jar:. \<br>
com/titan/travelagent/TravelAgent*.java<br>
<br>
cp com/titan/travelagent/ejb-jar.xml \<br>
com/titan/travelagent/jboss.xml \<br>
META-INF/<br>
<br>
# JBoss needs the Home, Remote and primary key (PK) classes<br>
# of the Cabin in travelagent.jar so that TravelAgent*.class<br>
# can access the Cabin bean<br>
<br>
jar cvf travelagent.jar \<br>
com/titan/cabin/CabinHome.class \<br>
com/titan/cabin/Cabin.class \<br>
com/titan/cabin/CabinPK.class \<br>
com/titan/travelagent/TravelAgent*.class \<br>
META-INF/ejb-jar.xml META-INF/jboss.xml<br>
<br>
rm -f META-INF/ejb-jar.xml<br>
rm -f META-INF/jboss.xml<br>
<br>
# deploy<br>
cp cabin.jar travelagent.jar $JBOSS_HOME/deploy<br>
</b><br>
</div>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -