📄 ch14.html
字号:
</p></li><li><p><a name="d0e12152"></a>Compile the clients.</p><p> The clients from the examples perform a lookup on the java:comp/env namespace, which is not
currently supported by JBoss for the clients. You have to make the following edits: (CabinBean is the jndi
name under which the Cabin Bean is deployed, see the jndi howto)
In com/titan/cabin/Client_1.java replace
<pre class="programlisting">
Object obj = jndiContext.lookup("java:comp/env/ejb/CabinHome");</pre> by
<pre class="programlisting">
Object obj = jndiContext.lookup("CabinBean");</pre> In com/titan/cabin/Client_2.java replace
<pre class="programlisting">
Object obj = jndiContext.lookup("ejb/CabinHome");</pre> by
<pre class="programlisting">
Object obj = jndiContext.lookup("CabinBean");</pre> In com/titan/travelagent/Client_1.java replace
<pre class="programlisting">
Object obj = jndiContext.lookup("ejb/TravelAgentHome");</pre> by
<pre class="programlisting">
Object obj = jndiContext.lookup("TravelAgentBean");</pre> You can now use jBossMakeClients.sh to compile:
<div class="literallayout"> <br>
<b> #!/bin/sh <br>
<br>
javac -classpath $JBOSS_HOME/lib/ext/ejb.jar:. \<br>
com/titan/cabin/Client*.java \<br>
com/titan/travelagent/Client*.java<br>
<br>
</b> <br>
</div>
</p></li><li><p><a name="d0e12181"></a>Run the clients</p><p>
We don't use Sun's RI runclient tool, so RunIt.sh won't work. Instead, we provide the following script:
jBossRunClient.sh. This file includes all the jBoss libraries needed in the classpath.
<div class="literallayout"> <br>
<b> #!/bin/sh <br>
<br>
CP=$JBOSS_HOME/client/ejb.jar<br>
CP=$CP:$JBOSS_HOME/client/jndi.jar<br>
CP=$CP:$JBOSS_HOME/client/jta-spec1_0_1.jar<br>
CP=$CP:$JBOSS_HOME/client/jboss-client.jar<br>
CP=$CP:$JBOSS_HOME/client/jnp-client.jar<br>
<br>
CP=$CP:.<br>
<br>
java -cp $CP $1<br>
</b> <br>
</div> You also have to set the jndi properties to connect to the server. This is done in the jndi.properties file (this file
must be in the same directory as jBossRunClient.sh)
<pre class="programlisting">
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=localhost
java.naming.factory.url.pkgs=org.jboss.naming;
</pre>
You can now run the clients. The script take the name of the client as an argument, try
<div class="literallayout"> <br>
<br>
<b> ./jBossRunClient.sh com.titan.cabin.Client_1<br>
./jBossRunClient.sh com.titan.cabin.Client_2<br>
./jBossRunClient.sh com.titan.travelagent.Client_1<br>
</b><br>
</div>
</p><p> NOTES:
the clients will only run once, since they use the EJBHome.create() method: at second run, a
DuplicateKeyException will occur.
I recommend you to turn off debug logging for these examples. Edit $JBOSS_HOME/conf/jboss.conf, in
the ConsoleLogging section, set the first ARG to "Error".
</p></li></ul></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="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></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -