1. Introduction to this section
This chapter mainly introduces JBOSS (a free EJB server) and teaches you how to install Jboss and build your first EJB and client. About what EJB is and how to develop it. Many books on EJB are described here. The description information is run on the windows platform. Of course, you can apply the information on other supported platforms (such as Linux ).
2. About JBOSS
Jboss supports the EJB 1.1 and EJB2.0 specifications. It is a container and server for managing ejbs. Similar to Sun's J2SDK EnterpriseEdition (J2EE), Jboss core service only provides EJB servers. JBOSS does not include serverlers/JSP page WEB containers. Of course, JBOSS can be bound to Tomcat or Jetty. JBOSS requires relatively small memory and hard disk space. It can run well in 64 MB memory and several megabytes of space. Sun's J2EE requires a minimum of 128 MB of memory and 31 MB of hard disk space. The JBOSS startup speed is 10 times faster than that of J2EE. In addition, it can embed SQL database servers for persistent BEAN processing and will be automatically started at startup. (J2EE load separation CloudScape SQL Server ).
One of the very good features is that JBOSS can be "hot" deployed. The "hot" deployment means that the BEAN deployment simply copies the JAR file of the BEAN to the deployment path. If the BEAN has been loaded, uninstall JBOSS and LOAD a new BEAN version. If you need more JBOSS features, you can view the JBOSS Forum website. If yes, you can pay for JBossGroup LLC.
This chapter step by step helps you start distributed development with jboss: how to create a simple BEAN, and how to deploy and test on the jboss server.
3. Prerequisites
JBOSS is written in pure JAVA and requires a JAVA system compatible with JDK1.3. To make it cheaper and run all examples, you need Ant 1.4 or later. The following section describes how to obtain and install the SDK. Of course, you must have the foundation for developing ejbs.
4. Install ANT
We may have seen this name in many books and webpages. What is it used? Ant is a java-based build tool. Many build tools, such as make, gnumake, nmake, and jam, are available. Ant is a cross-platform Build tool. The reason why Ant can be cross-platform is that Ant no longer requires you to write shell commands. The Ant configuration file is an XML-based task tree that allows you to run various tasks, tasks are executed by objects that implement specific task interfaces.
Two versions of Binary and Source are available to download the latest version 1.5.2.
Http://ant.apache.org/old-releases/v1.5.2/binaries/ (Binary)
Source: http://ant.apache.org/old-releases/v1.5.2/source/
For the differences between these two versions, see http://ant.apache.org /. If you can not download can ask me QQ: 182244794, Email: amaryllis@163.net.
After downloading Ant, decompress the file and put all the files in the apache-ant-1.5.2 path. The Ant document will be released in the docs/manual directory. You can open the webpage docs/manual/index.html to view the ant document content. I released it in the c:/apache-ant-1.5.2 path in Windows.
1) set the ANT_HOME environment variable to point to your ANT directory.
2) You need to set the JAVA_HOME environment variable to point to your JDK directory.
3) add % ANT_HOME % in to the path environment variable.
4) When you run ant without any parameters, Ant will find a file named build. xml in the current directory. If not, the following message is displayed:
Buildfile: build. xml does not exist! Build failed
To test whether ANT has been installed successfully, I have created a new build. xml file and put it in the current directory % ANT_HOME % samples. The content of Build. xml is as follows:
<! -- Simple Ant build script to test an Ant installation --> <br/>
<Project name = "TestInstall" default = "run" basedir = "."> <br/>
<Target name = "init"> <br/>
<Available file = "ASimpleHelloObject. java" property = "ASimpleHelloObject"/> <br/>
</Target> <br/>
<Target name = "ASimpleHelloObject" unless = "ASimpleHelloObject" depends = "init"> <br/>
<Echo file = "ASimpleHelloObject. java"> <br/>
Public class ASimpleHelloObject <br/>
{<Br/>
Public static void main (String [] args) {<br/>
System. out. println ("ASimpleHelloObject. main was called") ;}< br/>
} <Br/>
</Echo> <br/>
<Echo message = "Wrote ASimpleHelloObject. java"/> <br/>
</Target> <br/>
<Target name = "compile" depends = "ASimpleHelloObject"> <br/>
<Javac destdir = "." srcdir = "." debug = "on" classpath = "."> <br/>
<Include name = "ASimpleHelloObject. java"/> <br/>
</Javac> <br/>
</Target> <br/>
<Target name = "run" depends = "compile"> <br/>
<Java classname = "ASimpleHelloObject" classpath = "."/> <br/>
<Echo message = "Ant appears to be successfully installed"/> <br/>
</Target> <br/>
</Project> <br/>
The result of running ant is as follows:
C: apache-ant-1.5.2samples> antBuildfile: build. xml
Init:
AsimpleHelloObject:
[Echo] Wrote AsimpleHelloObject. java
Compile:
[Javac] Compiling 1 source file to c: apache-ant-1.5.2samples
Run:
[Java] AsimpleHelloObject. main was called [echo] Ant appears to be successfully installed
BUILDE SUCCESSFUL
Total time: 11 seconds.
Now the ANT and environment you have installed have been set successfully. If the following warning is reported:
Warning: JAVA_HOME environmentvariable is not set. If build fails because sun. * classes cocould not befound you will need to set the JAVA_HOME environment variable to theinstallation directory of java.
Indicates that you need to set the JAVA_HOME environment and specify the JDK directory you have installed. How