📄 ch01s14.html
字号:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Packaging and deploying the bean</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="ch01.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01.html" title="Chapter 1. First steps"><link rel="previous" href="ch01s12.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01s12.html" title="The deployment descriptor"><link rel="next" href="ch01s15.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01s15.html" title="Coding and compiling the test client"></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="ch01.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01.html"><img src="toc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/toc.gif" border="0"></a><a href="ch01s12.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01s12.html"><img src="prev.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/prev.gif" border="0"></a><a href="ch01s15.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01s15.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="section"><a name="d0e338"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="d0e338"></a>Packaging and deploying the bean</h2></div></div><p>Creation of the EJB jar package involves building a JAR archive containing
the EJB classes and deployment descriptors. To build the EJB jar for the
Interest example simply cd to the examples/build directory of the documentation examples
source tree and execute the following ant command:</p><div class="literallayout"><br>
<tt>bash-2.04$ ant intro-interest-jar <br>
Buildfile: build.xml<br>
<br>
validate:<br>
<br>
fail_if_not_valid:<br>
<br>
init:<br>
[echo] Using JBoss directory=/tmp/JBoss-2.2.2<br>
[echo] Using classpath=/tmp/JBoss-2.2.2/client/ejb.jar:/tmp/JBoss-2.2.2/client/jaas.jar:/tmp/JBoss-2.2.2/client/jbosssx-client.jar:/tmp/JBoss-2.2.2/client/jboss-client.jar:/tmp/JBoss-2.2.2/client/jnp-client.jar:/tmp/tomcat/lib/servlet.jar:/tmp/examples/${build.classes.dir}<br>
[echo] Using Source directory=/tmp/examples<br>
[echo] Using Build directory=/tmp/examples/build-examples<br>
<br>
intro-interest-jar:<br>
<br>
compile:<br>
[javac] Compiling 4 source files to /tmp/examples/build-examples/interest/classes<br>
<br>
ejb-jar:<br>
[mkdir] Created dir: /tmp/examples/build-examples/interest/META-INF<br>
[copy] Copying 1 file to /tmp/examples/build-examples/interest/META-INF<br>
[copy] Copying 1 file to /tmp/examples/build-examples/interest/META-INF<br>
[jar] Building jar: /tmp/examples/build-examples/interest/interest.jar<br>
<br>
BUILD SUCCESSFUL<br>
<br>
Total time: 2 seconds</tt><br>
</div><p>This has compiled the EJB classes and created the ejb-jar for deployment.
If got a java.lang.NoClassDefFoundError here instead of a successful created jar file try clearing your classpath.
The contents of the
interest.jar include the structure we discussed previously as shown by running the jar -tvf
command:</p><div class="literallayout"><br>
<tt>bash-2.04$ jar -tvf /tmp/examples/build-examples/interest/interest.jar<br>
0 Sun Jun 24 22:55:52 PDT 2001 META-INF/<br>
46 Sun Jun 24 22:55:52 PDT 2001 META-INF/MANIFEST.MF<br>
0 Sun Jun 24 22:55:52 PDT 2001 org/<br>
0 Sun Jun 24 22:55:52 PDT 2001 org/jboss/<br>
0 Sun Jun 24 22:55:52 PDT 2001 org/jboss/docs/<br>
0 Sun Jun 24 22:55:52 PDT 2001 org/jboss/docs/interest/<br>
246 Sun Jun 24 22:55:52 PDT 2001 org/jboss/docs/interest/Interest.class<br>
1177 Sun Jun 24 22:55:52 PDT 2001 org/jboss/docs/interest/InterestBean.class<br>
296 Sun Jun 24 22:55:52 PDT 2001 org/jboss/docs/interest/InterestHome.class<br>
599 Sun Jun 24 22:55:52 PDT 2001 META-INF/ejb-jar.xml<br>
220 Sun Jun 24 22:55:52 PDT 2001 META-INF/jboss.xml</tt><br>
</div><p>To deploy the Bean on the server, all that's necessary is to copy the
interest.jar file to the JBOSS_DIST/deploy directory of your JBoss installation.
You can do this as often as you like. The server will detect that the
file has changed and automatically re-deploy it. With the JBoss server running, deploy
the jar by running <b>ant intro-interest-deploy</b> from the examples/build
directory. During deployment you should see messages similar to the following on the server console:</p><div class="literallayout"><br>
<tt>[Auto deploy] Auto deploy of file:/tmp/JBoss-2.2.2/deploy/interest.jar<br>
[J2EE Deployer Default] Deploy J2EE application: file:/tmp/JBoss-2.2.2/deploy/interest.jar<br>
[J2EE Deployer Default] Create application interest.jar<br>
[J2EE Deployer Default] install module interest.jar<br>
[Container factory] Deploying:file:/tmp/JBoss-2.2.2/tmp/deploy/Default/interest.jar<br>
[Verifier] Verifying file:/tmp/JBoss-2.2.2/tmp/deploy/Default/interest.jar/ejb1001.jar<br>
[Container factory] Deploying Interest<br>
[Container factory] Deployed application: file:/tmp/JBoss-2.2.2/tmp/deploy/Default/interest.jar<br>
[J2EE Deployer Default] J2EE application: file:/tmp/JBoss-2.2.2/deploy/interest.jar is deployed.</tt><br>
</div><p>If you see a message like this: </p><div class="literallayout"><br>
<tt>[Auto deploy] Auto deploy of file:/tmp/JBoss-2.2.2/deploy/interest.jar<br>
[J2EE Deployer Default] Deploy J2EE application: file:/tmp/JBoss-2.2.2/deploy/interest.jar <br>
...<br>
[Auto deploy] Deployment failed:file:/tmp/JBoss-2.2.2/deploy/interest.jar</tt><br>
</div><p>then no EJBs have been deployed -- the server always reports the EJBs
that it detects. This usually means that the deployment descriptor ejb-jar.xml
is badly structured, or missing, or in the wrong directory. </p><p>You should now have the Interest EJB deployed on the server. We will now go over a
simple test client that runs one of its methods, just to verify that it's working.</p></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="ch01.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01.html"><img src="toc.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/toc.gif" border="0"></a><a href="ch01s12.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01s12.html"><img src="prev.gif" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/prev.gif" border="0"></a><a href="ch01s15.html" tppabs="http://www.huihoo.org/jboss/online_manual/3.0/ch01s15.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 + -