This example uses RMI/IIOP to connect to an EJB server.  The
enterprise bean is a stateful session bean which accepts pages which
are added to the document during the session.  The document should be
created when the PHP session starts and destroyed when the PHP session
terminates.  See the functions "createDocument($url, $jndiname)" and
"destroyDocument($doc)" in globals.php.


Installing the documentBean.jar
-------------------------------

It is assumed that you use the Sun J2EE application server and that
your server is already installed in some directory, for example in
~/SUNWappserver. 


1. Start your application server, for example with the command:

     $app_server/bin/asadmin start-domain domain1


2. Log into your application server, for example by visiting

     http://localhost:4848/asadmin

   and open

     Application Server -> Applications -> EJB Modules

   Click on  "Deploy..."  and deploy documentBean.jar.


3. Copy the documentBeanClient.jar from the (remote-) directory 
     
     $app_server/domains/domain1/applications/j2ee-modules/documentBean/

   and the j2ee.jar from the (remote-) directory

     $app_server/lib

   into the current directory. 

   Examine globals.php and change $app_url if necessary.


4. Start the PHP/Java Bridge if it is not already running.


5. Run documentClient.php, for example with the command:

     php documentClient.php

   It should return "This document has 2 pages."



Notes: 

For IBM WebSphere deploy under the JNDI name "RMIdocument", copy
$WAS_HOME/.../documentBean_jar.ear/documenBean.jar to ./documentBeanClient.jar,
require "$WAS_HOME/lib/;$here/documentBeanClient.jar" and change $app_url port#
from 3700 to 2809.

For Oracle you need to create a .ear file, for example with the command:
"deploytool". Make sure to require the correct documentBeanClient.jar
which includes the stub classes, otherwise you'll get a class cast
exception.
