|
Download
FAQ History |
|
API
Search Feedback |
Building, Packaging, Deploying, and Running the Application
The source code for the Coffee Break application is located in the directory
<INSTALL>/j2eetutorial14/examples/cb/. Within thecbdirectory are subdirectories for each Web application--saaj,jaxrpc,server, andserver-jsf--and a directory,common, for classes shared by the Web applications. Each subdirectory contains abuild.xmlandbuild.propertiesfile. The Web application subdirectories in turn contain asrcsubdirectory for Java classes and awebsubdirectory for Web resources.Setting the Port
The JAX-RPC and SAAJ services in the Coffee Break application run at the port that you specified when you installed the Application Server. The tutorial examples assume that the Application Server runs on the default port, 8080. If you have changed the port, you must update the port number in the following files before building and running the examples:
Setting Up the Registry Server
The Coffee Break servers uses a registry server to obtain information about the JAX-RPC service endpoint. Since the Application Server does not include a registry server, you must obtain one before you can run the application.
We recommend that you use the Registry Server provided with the Java Web Services Developer Pack (Java WSDP) 1.3, which you can download from
http://java.sun.com/webservices/downloads/. The Registry Server is automatically loaded when you start the Java WSDP Tomcat server. You may need to modify the port that Tomcat runs on because the default port for both the Application Server and Tomcat is 8080. To change the port for Tomcat and the Registry Server database to 8082:
- Edit the port attribute of the Connector element of the Java Web Services Developer Pack Service in the file
<JWSDP_HOME>/conf/server.xmlas follows:
<Service name="Java Web Services Developer Pack">8082
<Connector className="org.apache.coyote.tomcat5.CoyoteConnector" port="" minProcessors="5" maxProcessors="100"
...- Remove the comment around and set the Xindice host and port system properties in the file
<JWSDP_HOME>/jwsdp-shared/bin/launcher.xmlas follows:
<sysproperty key="org.apache.xindice.host" value="localhost"/>8082
<sysproperty key="org.apache.xindice.port" value=""/>Then, start the Registry Server:
Using the Provided WARs
The instructions that follow for packaging and deploying the Coffee Break Web applications assume that you are familiar with the deploytool procedures for packaging Web services and presentation-oriented Web applications described in previous chapters of the tutorial. If after following these procedures you have trouble deploying or running the application, you can use the WARs provided in
<INSTALL>/j2eetutorial14/examples/cb/provided-wars/to run the example. The provided WARs assume that Coffee Break supplier services are running on port 8080 and the registry server is running on port 8082. If the services are not running on port 8080, you won't be able to use these WARs. If the registry server is not running on port 8082, you can use the WARs but you must update theregistryURLcontext parameter in the JAX-RPC service and Coffee Break server WARs.Building the Common Classes
The Coffee Break applications share a number of common utility classes. To build the common classes, do the following:
Building, Packaging, and Deploying the JAX-RPC Service
To build the JAX-RPC service and client library and to package and deploy the JAX-RPC service, follow these steps:
- In a terminal window, go to
<INSTALL>/j2eetutorial14/examples/cb/jaxrpc/.- Run
asant build-registryandasantbuild-service. These tasks create the JAR file containing the JAXR routines and runwscompileand compile the source files of the JAX-RPC service.If you get an error, make sure that you edited the file
<INSTALL>/j2eetutorial14/examples/common/build.propertiesas described in Building the Examples.- Make sure the Application Server and Registry Server are started.
- Start
deploytool.- Create a stand-alone Web module named
jaxrpc-coffee-supplierin<INSTALL>/j2eetutorial14/examples/cb/jaxrpc/.- Set the context root to
/jaxrpc-coffee-supplier.- Add the content to the service.
- Add the
compackage,Supplier.wsdl, andmapping.xmlunder<INSTALL>/j2eetutorial14/examples/cb/jaxrpc/build/server/to the module.- Navigate to
<INSTALL>/j2eetutorial14/examples/cb/jaxrpc/build/registry/dist/and addregistry-org.jar.- In the Web module contents editor, drag the
comdirectory (containingsun/cb/SupplierPrices.properties) from the context root toWEB-INF/classes/.- Specify Web Services Endpoint as the component type.
- In the Choose Service dialog box (Define New Service):
- In the Component General Properties dialog box:
- In the Web Service Endpoint dialog box:
- Add the alias
/jaxrpcto theSupplierImplWeb component.- Select the Endpoint tab, and then select
jaxrpcfrom the Endpoint Address combo box in the Sun-specific Settings frame.- Add an event listener that references the listener class
com.sun.cb.ContextListener.- Add a resource reference of type
javax.xml.registry.ConnectionFactorynamedeis/JAXRmapped to the JAXR connection factoryeis/JAXR. If you have not already created the connection factory, follow the instructions in Creating JAXR Resources.- Add the context parameter that specifies the URL of the registry server. The parameter is named
registryURLand the value ishttp://localhost:port/RegistryServer/, whereportis the port at which the registry server is running.- Save the module.
- Deploy the module.
- Run
asantbuild-client. This task creates the JAR file that contains the classes needed by JAX-RPC clients. Thebuild-clienttask runswscompileto generate the stubs and JavaBeans components.- Test that the JAX-RPC service has been deployed correctly by running the test programs
asant run-test-orderandasantrun-test-priceHere is what you should see when you run
asantrun-test-price:
run-test-price:
run-test-client:
[java] 07/21/03 08/20/03
[java] Kona 6.50
[java] French Roast 5.00
[java] Wake Up Call 5.50
[java] Mocca 4.00Building, Packaging, and Deploying the SAAJ Service
To build the SAAJ service and client library and to package and deploy the SAAJ service, follow these steps:
- In a terminal window, go to
<INSTALL>/j2eetutorial14/examples/cb/saaj/.- Run
asantbuild. This task creates the client library and compiles the server classes.- Make sure the Application Server is started.
- Start
deploytool.- Create a stand-alone Web module called
saaj-coffee-supplierin<INSTALL>/j2eetutorial14/examples/cb/saaj/.- Set the context root to
/saaj-coffee-supplier.- Add the
comdirectory under<INSTALL>/j2eetutorial14/examples/cb/saaj/build/server/to the module.- Add the
ConfirmationServletWeb component. Choose the Servlet component type.- Add the alias
/orderCoffeeto theConfirmationServletWeb component.- Add the
PriceListServletWeb component to the existingsaaj-coffee-supplierWAR.- Add the alias
/getPriceListto thePriceListServletWeb component.- Save the module.
- Deploy the module.
- Test that the SAAJ service has been deployed correctly by running one or both of the test programs
asantrun-test-priceandasantrun-test-order.Building, Packaging, and Deploying the Coffee Break Server
To build, package, and deploy the Coffee Break server:
- In a terminal window, go to
<INSTALL>/j2eetutorial14/examples/cb/server/.- Run
asantbuild. This task compiles the server classes and copies the classes, JSP pages, and tag libraries into the correct location for packaging.- Make sure the Application Server is started.
- Start
deploytool.- Create a stand-alone Web module called
cbserverin<INSTALL>/j2eetutorial14/examples/cb/server/.- Set the context root to
/cbserver.- Add the content to the Web module.
- Add all the JSP pages,
tutorial-template.tld, and thetemplateandcomdirectories under<INSTALL>/j2eetutorial14/examples/cb/server/build/to the module.- In the Web module contents editor, drag the
comdirectory (containingsun/cb/CoffeeBreak.properties) from the context root toWEB-INF/classes/.- Add the JAX-RPC client library in
<INSTALL>/j2eetutorial14/examples/cb/jaxrpc/dist/jaxrpc-client.jarto the module.- Add the SAAJ client library in
<INSTALL>/j2eetutorial14/examples/cb/saaj/dist/saaj-client.jarto the module.- Create a
DispatcherWeb component. Choose the Servlet component type.- Add the aliases
/orderForm,/checkoutForm, and/checkoutAckto theDispatchercomponent.- Add the
RetailPriceListServletWeb component to the existingcbserverWAR.- Add the alias
/loadPriceListto theRetailPriceListServletcomponent.- Add a resource reference of type
javax.xml.registry.ConnectionFactorynamedeis/JAXRmapped to the JAXR connection factoryeis/JAXR.- Add a JSP property group named
cbserver. The property group applies to the URL pattern*.jsp. Add the include prelude/template/prelude.jspf.- Add a context parameter named
javax.servlet.jsp.jstl.fmt.localizationContextand valuecom.sun.cb.messages.CBMessages.- Add the context parameter that specifies the URL of the registry server. The parameter is named
registryURLand the value ishttp://localhost:port/RegistryServer/, whereportis the port at which the registry server is running.- Specify a security constraint for
RetailPriceListServlet.
- Select Basic as the User Authentication Method.
- Click Settings and enter
filein the Realm Name field. Click OK.- Add a security constraint and a web resource collection. Use the default names provided by
deploytool.- Add the URL
/loadPriceListto the web resource collection.- Select the
GETHTTP method.- Add the security role
admin.- Map the
adminrole to theadminuser.- Save the module.
- Deploy the module.
Building, Packaging, and Deploying the JavaServer Faces Technology Version of the Coffee Break Server
To build, package, and deploy the JavaServer Faces technology version of the Coffee Break server, follow these steps:
- In a terminal window, go to
<INSTALL>/j2eetutorial14/examples/cb/server-jsf/.- Run
asantbuild. This task compiles the server classes and copies the classes, JSP pages, tag libraries, and other necessary files into the correct location for packaging.- Make sure the Application Server is started.
- Start
deploytool.- Create a stand-alone Web module called
cbserver-jsf in <INSTALL>/j2eetutorial14/examples/cb/server-jsf/.- Set the context root to
/cbserver-jsf.- Add the content to the Web module.
- Add all the JSP pages,
coffeebreak.css,faces-config.xml,index.html, and thetemplateandcomdirectories under<INSTALL>/j2eetutorial14/examples/cb/server-jsf/build/to the module.- In the Web module contents editor, drag the
comdirectory (containingsun/cb/CoffeeBreak.properties) from the context root toWEB-INF/classes.- Drag
faces-config.xmlto the root of theWEB-INFdirectory.- Add the JSF API library from
<J2EE_HOME>/lib/jsf-api.jarto the module.- Add the JAX-RPC client library in
<INSTALL>/j2eetutorial14/examples/cb/jaxrpc/dist/jaxrpc-client.jarto the module.- Add the SAAJ client library in
<INSTALL>/j2eetutorial14/examples/cb/saaj/dist/saaj-client.jarto the module.- Create a
FacesServletWeb component. Choose the Servlet component type.- In the Load Sequence Position field on the Component General Properties dialog, enter
1.- Add the aliases
/faces/*and*.jsfto theFacesServletcomponent.- Add a resource reference of type
javax.xml.registry.ConnectionFactorynamedeis/JAXRmapped to the JAXR connection factoryeis/JAXR.- Add a JSP property group named
cbserver-jsf. The property group applies to the URL pattern*.jsp. Add the include prelude/template/prelude.jspf.- Add the context parameter that specifies the URL of the registry server. The parameter is named
registryURLand the value ishttp://localhost:port/RegistryServer/, whereportis the port at which the registry server is running.- Save the module.
- Deploy the module.
Running the Coffee Break Client
After you have installed all the Web applications, check that all the applications are running in deploytool or the Admin Console. You should see
cbserver,jaxrpc-coffee-supplier, andsaaj-coffee-supplierin the list of applications.If you have installed the non-GUI framework version of the Coffee Break server, you can run the Coffee Break client by opening the Coffee Break server URL in a Web browser:
If you have installed the JavaServer Faces technology version of the Coffee Break server, you can run the JavaServer Faces version of the Coffee Break client by opening this URL in a Web browser:
You should see a page something like the one shown in Figure 35-2.
![]()
After you have gone through the application screens, you will get an order confirmation that looks like the one shown in Figure 35-3.
![]()
Figure 35-3 Order Confirmation
Removing the Coffee Break Application
To remove the Coffee Break application, perform the following steps:
If you want to remove the
buildanddistdirectories, runantcleanin each directory, including<INSTALL>/j2eetutorial14/examples/cb/common/.
|
Download
FAQ History |
|
API
Search Feedback |
All of the material in The J2EE(TM) 1.4 Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.