|
|
Step 4: packaging and deploying the Bean
reation of the Bean package involves building a JAR
archive containing the classes and the XML files. For the example Bean we have
been discussing, this is straightforward; at the top of the directory hierarchy
run jar like this:
jar cvf interest.jar com/web_tomorrow/interest/Interest.class \
com/web_tomorrow/interest/InterestHome.class \
com/web_tomorrow/interest/InterestBean.class \
META-INF
If you have `make' on your system, and you have unpacked the source code
arhive, you can get the same effect simply by executing `make package'. I
stronly recommend using Makefiles or shell scripts to do these operations
because in practice you will be repeating them many times during development
jar builds an archive containing the three classes, and the XML
files in the META-INF directory. If you list the contents of the archive you
should see something like this:
0 06-16-00 11:34 META-INF/
72 06-16-00 11:35 META-INF/MANIFEST.MF
248 06-16-00 10:12 com/web_tomorrow/interest/Interest.class
300 06-16-00 10:12 com/web_tomorrow/interest/InterestHome.class
877 06-16-00 10:12 com/web_tomorrow/interest/InterestBean.class
549 06-15-00 18:15 META-INF/ejb-jar.xml
3597 06-15-00 17:20 META-INF/jboss.xml
Note that the directory structure must be exactly like this, or it won't
work.
To deploy the Bean on the server, all that's necessary is to copy the .jar file
to the `deploy' directory on the server, e.g.,
cp interest.jar /usr/lib/jboss/deploy
You can do this as often as you like; the server will detect that the file has
changed and automatically re-deploy it. During deployment you should see the
following messages from the server:
[Auto deploy] Auto deploy of file:/usr/lib/jboss/deploy/interest.jar
[Container factory] Deploying:file:/usr/lib/jboss/deploy/interest.jar
[Container factory] Deploying Interest
[Container factory] Started: Interest
[Container factory] Bound Interest to interest/Interest
[Container factory] Deployed application:
file:/usr/lib/jboss/deploy/interest.jar
If you see a message like this:
[Container factory] Deploying:file:/usr/lib/jboss/deploy/interest.jar
[Container factory] Deployed application:
file:/usr/lib/jboss/deploy/interest.jar
then no Beans have been deployed -- the server always reports the Beans that it
detects. This usually means that the deployment descriptor
ejb-jar.xml is badly structured, or missing, or in the wrong
directory. Note that you can deploy without a jboss.xml
file; the server will use defaults for all its settings. In simple cases you
may get away with this.
If everything has gone according to plan, you should now have a Bean deployed
on the server. We will now create a simple test client that runs one of its
methods, just to prove that it's working.
|