Configuring Ports

When OC4J starts up, it begins listening for connections on a number of ports. In general, these port assignments are fine for development, but the following are several common cases in which you may want to change them:

  • When running more than one instance of OC4J on the same machine

  • When running other servers or services that conflict with OC4J's default ports

  • When setting up HTTP traffic to run over port 80 so that you don't need to include the port number in your URLs

  • When enabling HTTPS

Fortunately, each of the ports used by OC4J is configurable.

HTTP

By default, the built-in HTTP server accepts connections on port 8888, but you can edit http-web-site.xml to change this port. For example, to run your web application on port 7001, you might use a file like this:

 <web-site port="7001" display-name="Acme Web Site" >     <access-log path="../log/web-store.log" />     <web-app application="acmestore" name="AcmeStore" root="/store" /> </web-site> 

In either of these cases (port 8888 or port 7001), you must include the port number in the URL when accessing your web applications, like this:

 http://localhost:8888/store/ 

To allow users to access a web application over HTTP without having to specify a port number in the URL, set the port to 80, which is the standard HTTP port. Then your URL will instead look like this:

 http://localhost/store/ 

Of course, if you're using UNIX, you may require root access to be able to bind port 80.

Tip 

You can configure multiple websites with different ports and settings, each configured through its own *-web-site.xml file. Each of these files will follow this same format but should use a unique port to avoid conflicting with the others. For example, if you want to run an admin web application on a different port, you can add <web-site path="./admin-web-site.xml" /> , copy the http-web-site.xml file to admin-web-site.xml and edit the port and web application attributes.

HTTPS

OC4J doesn't include a default HTTPS configuration. However, you can easily create one by copying http-web-site.xml and adding a few security settings. Like HTTP, your HTTPS website can use any port.

Tip 

When running multiple sites on nondefault ports, many developers use consecutive port numbers for HTTP and HTTPS (for example, 8888 and 8889). Others use some variation of the standard HTTP/S port assignments (for example, 8080 and 8443).

For example, to allow secure access to your web application over port 7002, copy your basic http-web-site.xml file, add the secure attribute to the website element, and use the ssl-config element to tell OC4J where to find your keystore and which password to use, as shown here:

 <web-site port="7002" display-name="Acme Secure Web Site" secure="true" >     <web-app application="acmestore" name="AcmeStore" root="/store" />     <access-log path="../log/web-securestore.log" />     <ssl-config keystore="../keystore" keystore-password="->admin" /> </web-site> 
Tip 

This example uses password indirection for the keystore-password element instead of including it in plain text. The value ->admin tells OC4J to look up the admin user in the security UserManager and use its password to access the keystore .

To allow users to access a web application over HTTPS without having to specify a port number in the URL (for example, https://appserver.acme.com/securestore ), set the port to 443, which is the standard HTTPS port. As with port 80, you'll usually need root access to bind port 443 on a UNIX machine.

Java Message Service

JMS allows the use of asynchronous messaging between J2EE components , and with external message producers and consumers. Within jms.xml , you can easily configure the port on which JMS listens for incoming requests . In this case, the JMS server will listen on port 9127, as follows :

 <jms-server port="9127"> ... </jms-server> 

See Chapter 6 for greater detail on use of JMS in OC4J.

Tip 

The default ports in OC4J Standalone are different than the default ports in the full Oracle Application Server stack. Never hard-code these ports in client applications, but instead pull them out into properties files that can easily be changed as you move the code from server to server.

Remote Method Invocation

RMI is a technology and protocol used by Java applications to access other Java applications remotely. In particular, it's used by client applications to access EJBs across a network.

Within rmi.xml , you can easily configure the port that listens for RMI requests, like this:

 <rmi-server port="23791" > </rmi-server> 

See Chapter 13 for help more information about how to use RMI to access EJBs.

IIOP

Internet Inter-ORB Protocol (IIOP) is a protocol used by CORBA applications to access remote objects. In a J2EE server, you can make your remote EJBs available over IIOP (in addition to normal RMI) to allow easy integration with these CORBA applications. In OC4J, IIOP is disabled by default, so if you won't need it, you don't need to worry about port conflicts.

To enable access over IIOP, add the following line to your server.xml configuration file:

 <sep-config path="./internal-settings.xml" /> 

Then edit the internal-settings.xml file to customize the IIOP ports that your CORBA client applications will use to connect. In the following default example, IIOP will be available unsecured on port 5555, with SSL server authentication through port 5556 and with both client and server authentication on port 5557:

 <internal-settings>     <server-extension-provider name="IIOP"                     class="com.oracle.iiop.server.IIOPServerExtensionProvider">         <sep-property name="port" value="5555" />         <sep-property name="host" value="localhost" />         <sep-property name="ssl" value="false" />         <sep-property name="ssl-port" value="5556" />         <sep-property name="ssl-client-server-auth-port" value="5557" />         <sep-property name="keystore" value="keystore.jks" />         <sep-property name="keystore-password" value="->pwForSSL" />         <sep-property name="truststore" value="truststore.jks" />         <sep-property name="truststore-password" value="->pwForSSL" />         <sep-property name="trusted-clients" value="*" />      </server-extension-provider> </internal-settings> 

Once everything is configured, run the server with IIOP enabled by adding the GenerateIIOP system parameter to your OC4J startup command, like this:

 java -DGenerateIIOP=true -jar oc4j.jar 
Tip 

Any EJBs already deployed before IIOP was enabled will need to be redeployed to trigger the generation of client stubs.

See Chapter 13 for more information about configuring client applications to access EJBs over IIOP.



Oracle Application Server 10g. J2EE Deployment and Administration
Oracle Application Server 10g: J2EE Deployment and Administration
ISBN: 1590592352
EAN: 2147483647
Year: 2004
Pages: 150

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net