官术网_书友最值得收藏!

  • EJB 3 Developer Guide
  • Michael Sikora
  • 609字
  • 2021-07-02 11:34:53

Getting Started

For this book GlassFish was downloaded on Windows XP and all the examples were run on that platform. The instructions that follow assume a Windows platform is being used, however the installation instructions for other platforms such as Linux/Unix are almost the same.

Installing GlassFish

Before installing GlassFish check that version 5 or higher of the Java Development Kit (JDK) is present on your workstation. This can be downloaded from

http://java.sun.com/javase/downloads/index.jsp

For this book we used JDK 5.0 Update 12.

Set the environment variable JAVA_HOME to point to the directory in which the JDK is installed. Add %JAVA_HOME%\bin, to the PATH environment variable. This is done by clicking Control Panel from the Start menu. Then double-click the system icon. Select the Advanced tab on the System Properties box. Finally click the Environment Variables button.

Next download a version of GlassFish equal to or higher than V2b41d from:

https://glassfish.dev.java.net//

into the directory in which you want to install it. All the code examples in this book were tested with GlassFish version V2b41d. The actual name of the downloaded jar file will depend on the version and platform selected. For this book glassfish-installer-v2-b41d.jar was used. In the same directory as the downloaded jar file, run the jar file as follows:

java -Xmx256m -jar glassfish-installer-v2-b41d.jar

This will unzip the file and create the glassfish subdirectory.

Set the GLASSFISH_HOME environment variable to the directory where GlassFish was installed. Add %GLASSFISH_HOME%\bin to the PATH environment variable.

Set the environment variable ANT_HOME to the directory in which Ant is installed. GlassFish comes bundled with the Ant build tool and the installed Ant directory will be glassfish\lib\ant.

If you already have a version of Ant equal to higher than 1.6.5 then set ANT_HOME accordingly.

Add %ANT_HOME%\bin to the PATH environment variable.

Change the directory to the glassfish directory and complete the installation by running the Ant setup script:

ant -f setup.xml

The setup process may fail because of port conflicts with existing software you may have. If so you will need to edit the setup.xml file. Within the file you should see the following fragment setting up default properties:

.....
<property name="domain.name" value="domain1"/>
<property name="instance.name" value="server"/>
<property name="admin.user" value="admin"/>
<property name="admin.password" value="adminadmin"/>
<property name="admin.port" value="4848"/>
<property name="instance.port" value="8080"/>
<property name="orb.port" value="3700"/>
<property name="imq.port" value="7676"/>
<property name="https.port" value="8181"/>
<property name="glassfish.license" value="LICENSE.txt"/>
....

Change the value for the conflicting port, and run setup again.

Testing the Installation

GlassFish is started with the following command:

asadmin start-domain domain1

You should see the following messages:

Testing the Installation

In particular this shows the admin console URL and the URL for web applications. So enter the URL http://localhost:8080 from a browser. If GlassFish has started up correctly you should get the following page:

Testing the Installation

Accessing the Administrator Console

Enter the URL http://localhost:4848 from a browser. You should get the following page:

Accessing the Administrator Console

The default user name is admin and the default password is adminadmin. After you have entered these you should get the following page:

Accessing the Administrator Console

The administrator console is used for numerous tasks such as creating and configuring domains, monitoring performance, and deploying applications. An alternative for deploying applications is using the asadmin tool from the command line.

In the remainder of this book we have used the asadmin tool for deployment. By including it as an Ant target the whole process of compiling, packaging, and deploying is automated.

Shutting Down GlassFish

To stop GlassFish use the following command:

asadmin stop-domain domain1

Downloading Example Source Code

The source code for the examples can be found as a zip file on the book's web site. Download the file and unzip it into a drive and directory of your choice. The examples in the book assume the source code has been downloaded into the C:\ directory. Subdirectories correspond to individual chapters: C:\EJB3Chapter02, C:\EJB3Chapter03, and so on. You should consult the readme file before running any scripts.

主站蜘蛛池模板: 乡宁县| 图片| 宁明县| 朔州市| 陵水| 西乌| 连州市| 迭部县| 宣威市| 大渡口区| 忻州市| 石家庄市| 翁源县| 南开区| 镇远县| 津南区| 鹰潭市| 宁明县| 陕西省| 广平县| 海晏县| 讷河市| 德保县| 永清县| 县级市| 伊宁县| 章丘市| 南江县| 普格县| 桂林市| 呼图壁县| 沈阳市| 江津市| 五华县| 常德市| 平乐县| 静安区| 法库县| 闻喜县| 广河县| 合江县|