⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cb6.html

📁 j2eePDF格式的电子书
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  <head>    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />    <meta http-equiv="Content-Style-Type" content="text/css" />    <title>Building, Packaging, Deploying, and Running the Application</title>    <link rel="StyleSheet" href="document.css" type="text/css" media="all" />    <link rel="StyleSheet" href="catalog.css" type="text/css" media="all" />    <link rel="Table of Contents" href="J2EETutorialTOC.html" />    <link rel="Previous" href="CB5.html" />    <link rel="Next" href="Ebank.html" />    <link rel="Index" href="J2EETutorialIX.html" />  </head>  <body>    <table width="550" summary="layout" id="SummaryNotReq1">      <tr>	<td align="left" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a>	</td>        <td align="center" valign="center"><a accesskey="p" href="CB5.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="Ebank.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a>        </td>	<td align="right" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font>	</font>	</td>      </tr>    </table>    <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider">    <blockquote><a name="wp66005"> </a><h2 class="pHeading1">Building, Packaging, Deploying, and Running the Application</h2><a name="wp87044"> </a><p class="pBody">The source code for the Coffee Break application is located in the directory <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/cb/</code>. Within the <code class="cCode">cb</code> directory are subdirectories for each Web application--<code class="cCode">saaj</code>, <code class="cCode">jaxrpc</code>, <code class="cCode">server</code>--and a directory, <code class="cCode">common</code>, for classes shared by the Web applications. Each subdirectory contains a <code class="cCode">build.xml</code> and <code class="cCode">build.properties</code> file. The Web application subdirectories in turn contain a <code class="cCode">src</code> subdirectory for Java classes and a <code class="cCode">web</code> subdirectory for Web resources.</p><a name="wp106221"> </a><h3 class="pHeading2">Setting Up the Registry Server</h3><a name="wp106222"> </a><p class="pBody">The Coffee Break server relies on a registry server to obtain information about the JAX-RPC endpoint. Since the J2EE 1.4 Application Server does not include a registry server, you must obtain one before you can run the application. </p><a name="wp106223"> </a><p class="pBody">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 <code class="cCode"><a  href="http://java.sun.com/webservices/download.html" target="_blank">http://java.sun.com/webservices/download.html</a></code>. </p><a name="wp106225"> </a><p class="pBody">The Registry Server application 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 J2EE 1.4 Application Server and Tomcat is 8080. To change the port for Tomcat and the Registry Server database to 8082:</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp106226"> </a><div class="pSmartList1"><li>Edit the port attribute of the Connector element of the Java Web Services Developer Pack Service in the file <code class="cCode">&lt;</code><code class="cVariable">JWSDP_HOME</code><code class="cCode">&gt;/conf/server.xml</code> as follows:</li></div><a name="wp106227"> </a><p class="pBodyRelative"><code class="cCode">&lt;Service name=&quot;Java Web Services Developer Pack&quot;&gt;<br />&nbsp;&nbsp;&lt;Connector className=&quot;org.apache.coyote.tomcat5.CoyoteConnector&quot; port=&quot;</code><b class="cBold">8082</b><code class="cCode">&quot; minProcessors=&quot;5&quot; maxProcessors=&quot;100&quot;<br />...</code></p><a name="wp106228"> </a><div class="pSmartList1"><li>Remove the comment around and set the Xindice host and port system properties in the file <code class="cCode">&lt;</code><code class="cVariable">JWSDP_HOME</code><code class="cCode">&gt;/jwsdp-shared/bin/launcher.xml</code> as follows:</li></div><a name="wp106229"> </a><p class="pBodyRelative"><code class="cCode">&lt;sysproperty key=&quot;org.apache.xindice.host&quot; value=&quot;</code><b class="cBold">localhost</b><code class="cCode">&quot;/&gt;<br />&lt;sysproperty key=&quot;org.apache.xindice.port&quot; value=&quot;</code><b class="cBold">8082</b><code class="cCode">&quot;/&gt;</code></p></ol></div><a name="wp106230"> </a><p class="pBody">Then, start the Registry Server:</p><div class="pSmartList1"><ul class="pSmartList1"><div class="pSmartList2"><ul class="pSmartList2"><a name="wp106231"> </a><div class="pSmartList2"><li>On the Unix platform, type the following at a terminal window:</li></div><a name="wp106232"> </a><p class="pBodyRelative"><code class="cCode">&nbsp;&nbsp;</code><code class="cVariable">&lt;JWSDP_HOME&gt;</code><code class="cCode">/bin/startup.sh</code></p><a name="wp106233"> </a><div class="pSmartList2"><li>On the Microsoft Windows platform, start Tomcat from the Start menu by selecting: Start<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>Programs<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>Java Web Services Developer Pack 1.3<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span> Start Tomcat.</li></div></ul></div></ul></div><a name="wp106234"> </a><p class="pBody">Finally, set the port of the Registry Server in the Coffee Break properties file <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/cb/common/src/com/sun/cb/CoffeeBreak.properties</code>:</p><a name="wp106235"> </a><p class="pBodyRelative"><code class="cCode">query.url=http://localhost:</code><b class="cBold">8082</b><code class="cCode">/RegistryServer/<br />publish.url=http://localhost:</code><b class="cBold">8082</b><code class="cCode">/RegistryServer/</code></p><a name="wp106236"> </a><p class="pBody">The instructions that follow for packaging and deploying the Coffee Break Web applications <em class="cEmphasis">assume that you are familiar with</em> 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 <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/cb/provided-wars/</code> to run the example. The provided WARs require that you run the J2EE 1.4 Application Server on port 8080 and the Registry Server (Tomcat) on port 8082.</p><a name="wp100331"> </a><h3 class="pHeading2">Building the Common Classes</h3><a name="wp66008"> </a><p class="pBody">The Coffee Break applications share a number of common utility classes. To build the common classes: </p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp66009"> </a><div class="pSmartList1"><li>In a terminal window, go to <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/cb/common/</code>.</li></div><a name="wp66010"> </a><div class="pSmartList1"><li>Run <code class="cCode">asant build</code>.</li></div></ol></div><a name="wp66011"> </a><h3 class="pHeading2">Building, Packaging, and Deploying the JAX-RPC Service</h3><a name="wp66012"> </a><p class="pBody">To build the JAX-RPC service and client library and package and deploy the JAX-RPC service: </p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp66013"> </a><div class="pSmartList1"><li>In a terminal window, go to <code class="cVariable">&lt;INSTALL&gt;</code><code class="cCode">/j2eetutorial14/examples/cb/jaxrpc/</code>.</li></div><a name="wp66014"> </a><div class="pSmartList1"><li>Run <code class="cCode">asant build-registry</code> and <code class="cCode">asant</code> <code class="cCode">build-service</code>. These tasks create the JAR file containing the JAXR routines and run <code class="cCode">wscompile</code> and compile the source files of the JAX-RPC service.</li></div><a name="wp88297"> </a><p class="pBodyRelative">If you get an error, make sure you edited the file <code class="cVariable">&lt;INSTALL&gt;</code><code class="cCode">/j2eetutorial14/examples/common/build.properties</code> as described in <a  href="About.html#wp67375">Building the Examples</a>.</p><a name="wp106311"> </a><div class="pSmartList1"><li>Start the J2EE application server.</li></div><a name="wp106316"> </a><div class="pSmartList1"><li>Start deploytool.</li></div><a name="wp106317"> </a><div class="pSmartList1"><li>Create a standalone Web module named <code class="cCode">jaxrpc-coffee-supplier</code> <code class="cCode">in &lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/cb/jaxrpc</code>/. </li></div><a name="wp106318"> </a><div class="pSmartList1"><li>Set the context root to <code class="cCode">/jaxrpc-coffee-supplier</code>.</li></div><a name="wp106319"> </a><div class="pSmartList1"><li>Add the content to the service.</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp106320"> </a><div class="pSmartList2"><li>Add the <code class="cCode">com</code> package, <code class="cCode">Supplier.wsdl</code>, and <code class="cCode">mapping.xml</code> under <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/cb/jaxrpc/build/server/ to the module.</code></li></div><a name="wp106321"> </a><div class="pSmartList2"><li>Navigate to <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/cb/jaxrpc/build/registry/dist/</code> and add <code class="cCode">registry-org.jar</code>.</li></div><a name="wp106322"> </a><div class="pSmartList2"><li>In the Web module contents editor, drag the <code class="cCode">com</code> directory (containing <code class="cCode">sun/cb/SupplierPrices.properties</code>) from the context root to <code class="cCode">WEB-INF/classes/</code>.</li></div></ol></div><a name="wp107445"> </a><div class="pSmartList1"><li>Specify Web Services Endpoint as the component type.</li></div><a name="wp107446"> </a><div class="pSmartList1"><li>Choose Service dialog box (Define New Service).</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp107447"> </a><div class="pSmartList2"><li>In the WSDL File combo box, select <code class="cCode">WEB-INF/wsdl/Supplier.wsdl</code>.</li></div><a name="wp106326"> </a><div class="pSmartList2"><li>In the Mapping File combo box, select <code class="cCode">mapping.xml</code>.</li></div></ol></div><a name="wp106327"> </a><div class="pSmartList1"><li>Component General Properties dialog box</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp106328"> </a><div class="pSmartList2"><li>In the Service Endpoint Implementation combo box, select <code class="cCode">com.sun.cb.SupplierImpl</code>.</li></div><a name="wp106329"> </a><div class="pSmartList2"><li>Click Next.</li></div></ol></div><a name="wp106330"> </a><div class="pSmartList1"><li>Web Service Endpoint dialog box</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp106331"> </a><div class="pSmartList2"><li>In the Service Endpoint Interface combo box, select <code class="cCode">com.sun.cb.SupplierIF</code>.</li></div><a name="wp106332"> </a><div class="pSmartList2"><li>In the Namespace combo box, select <code class="cCode">urn:Foo</code>.</li></div><a name="wp106333"> </a><div class="pSmartList2"><li>In the Local Part combo box, select <code class="cCode">SupplierIFPort</code>.</li></div><a name="wp106334"> </a><div class="pSmartList2"><li>Click Next.</li></div></ol></div><a name="wp106335"> </a><div class="pSmartList1"><li>Add the alias <code class="cCode">/jaxrpc</code> to the <code class="cCode">SupplierImpl</code> Web component.</li></div><a name="wp106336"> </a><div class="pSmartList1"><li>Select the Endpoint tab, then select <code class="cCode">jaxrpc</code> for the Endpoint Address in the Sun-specific Settings frame.</li></div><a name="wp106337"> </a><div class="pSmartList1"><li>Add an Event Listener that references the listener class <code class="cCode">com.sun.cb.ContextListener</code>. </li></div><a name="wp106338"> </a><div class="pSmartList1"><li>Add a resource reference of type <code class="cCode">javax.xml.registry.ConnectionFactory</code> named <code class="cCode">eis/JAXR</code> mapped to the JAXR connection factory <code class="cCode">eis/JAXR</code>. If you have not already created the connection factory, follow the instructions in <a  href="JAXR5.html#wp150812">Creating JAXR Resources</a>.</li></div><a name="wp106342"> </a><div class="pSmartList1"><li>Save the module.</li></div><a name="wp106343"> </a><div class="pSmartList1"><li>Deploy the module.</li></div><a name="wp75265"> </a><div class="pSmartList1"><li>Run <code class="cCode">asant</code> <code class="cCode">build-client</code>. This task creates the JAR file that contains the classes needed by JAX-RPC clients. The <code class="cCode">build-client</code> task runs <code class="cCode">wscompile</code> to generate the stubs and JavaBeans components.</li></div><a name="wp75017"> </a><div class="pSmartList1"><li>Test that the JAX-RPC service has been deployed correctly by running the test programs <code class="cCode">asant run-test-order</code> and <code class="cCode">asant</code> <code class="cCode">run-test-price</code></li></div><a name="wp72121"> </a><p class="pBodyRelative">Here is what you should see when you run <code class="cCode">asant</code> <code class="cCode">run-test-price</code>:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -