Version 3

    1. Load the entire JBoss Client Jar collection into  SCOTT.

     <project name="OracleLoadJavaExample" default="all"
     basedir=".">
          <taskdef name="OracleLoadJava"
     classname="org.apache.tools.ant.taskdefs.optional.oraclejava.OracleLoadJava"></taskdef>
          </target>
               <target name="all">
               <patternset id="all.jars">
                    <include name="**/*.jar"></include>
               </patternset>
               <OracleLoadJava oci="on" user="SCOTT/TIGER@NICK"
     resolve="on" debug="on" force="no" noverify="on"
     verbose="on" noserverside="on" schema="scott"
     synonym="on" time="on">
    
                    <fileset dir="C:/jboss-3.2.0_tomcat-4.1.24/client">
                         <patternset refid="all.jars"></patternset>
                    </fileset>
               </OracleLoadJava>
          </target>
     </project>
    

     

    2. Recompile all the invalid classes. To do this,  generate a script with this SQL logged in as SCOTT :

     

     select 'ALTER JAVA CLASS SCOTT."' || object_name || '"
     COMPILE;' from USER_OBJECTS where object_type in
     ('JAVA CLASS', 'JAVA SOURCE') and status = 'INVALID'
    

     

    Run the script that is generated.

     

    3. Grant the following rights to SCOTT:

     

     dbms_java.grant_permission( 'SCOTT',
     'SYS:java.net.SocketPermission', '<IP ADDRESS>:1024-',
     'listen,resolve' );
     dbms_java.grant_permission( 'SCOTT',
     'SYS:java.net.SocketPermission', '<IP ADDRESS>:3495',
     'connect,accept,resolve' );
         dbms_java.grant_permission(
    
    'SCOTT','SYS:java.lang.RuntimePermission','org.jboss.security.SecurityAssociation.getPrincipalInfo',
     '' );
         dbms_java.grant_permission(
     'SCOTT','SYS:java.io.SerializablePermission',
     'enableSubstitution', '' );
         dbms_java.grant_permission( 'SCOTT',
     'SYS:java.net.SocketPermission','<IP ADDRESS>:8093',
     'connect,resolve' );
    

     

    There may be some extra ones in there. I was also

    trying to communicate with some JMS processes, but

    generally, Oracle will tell you exactly which

    permissions you need in the error message if you fail

    to have one.

     

    4. Load EJB. Again, I used the Ant task and loaded the JAR I deployed to JBoss and a simple test client of a simple EJB:

     

    EJB:

     import javax.ejb.*;
     public class StringLibBean implements SessionBean {
       SessionContext sessionContext;
       public void ejbCreate() throws CreateException {
       }
       public void ejbRemove() {
       }
       public void ejbActivate() {
       }
       public void ejbPassivate() {
       }
       public void setSessionContext(SessionContext
     sessionContext) {
         this.sessionContext = sessionContext;
       }
       public String reverse(java.lang.String a) {
         return new StringBuffer(a).reverse().toString();
       }
     }
    

     

    Client Code:

     

       public static String reverse(String ejbName,  String
     message) {
         System.out.println("reverse(" + ejbName + "," +
     message + ");");
         try {
           if(ctx==null) {
             ctx = getJBossContext();
             System.out.println("Aha! Connnected To :" +
     ctx.getEnvironment().get(ctx.PROVIDER_URL));
           }
           if(home == null) {
             System.out.println("Looking Up:" + ejbName);
             Object obj = ctx.lookup(ejbName);
             System.out.println("Found Object Ref:" + obj);
             home = (StringLibHome)obj;
             System.out.println("Cast to Home");
           }
           remote = home.create();
           String tmp = remote.reverse(message);
           System.out.println("StringLib.reverse Result:" +
     tmp);
           return tmp;
         }
         catch (Exception ex) {
           System.err.println("Exception:" + ex);
           ex.printStackTrace();
           return null;
         }
       }
       public static Context getJBossContext() throws
     Exception {
         Properties p = new Properties();
         p.put(Context.PROVIDER_URL, "localhost:1099");
    
     p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
         return new InitialContext(p);
       }
    

     

    5. Recompiled invalid Java Classes again.

     

    6. Created test SQL Script  (testreverse.sql):

     

     connect scott/tiger@nick
     SET SERVEROUTPUT ON
     DECLARE
          AA VARCHAR2(30) := 'NULL';
     BEGIN
         dbms_java.set_output(10000);
         AA := REVERSE('StringLib', 'Calling JBoss From
     PLSQL');
         dbms_output.put_line('Reversed ='|| AA);
    
     END;
     /
     exit
     /
    

     

    7. Created test command file (reverse.cmd):

     

     @echo off
     cls
     sqlplus /NOLOG @testreverse.sql
    

     

     

    8. Ran the command file

     C:\test>reverse
    
     SQL*Plus: Release 9.2.0.1.0 - Production on Mon Jun 9
     06:07:03 2003
    
     Copyright (c) 1982, 2002, Oracle Corporation.  All
     rights reserved.
    
     Connected.
     reverse(StringLib,Calling JBoss From PLSQL);
     Aha! Connnected To :localhost:1099
     Looking Up:StringLib
     Found Object Ref:StringLibHome
     Cast to Home
     StringLib.reverse Result:LQSLP morF ssoBJ gnillaC
     Reversed =LQSLP morF ssoBJ gnillaC
    
     PL/SQL procedure successfully completed.
    
     Disconnected from Oracle9i Enterprise Edition Release
     9.2.0.1.0 - Production
     With the Partitioning, OLAP and Oracle Data Mining
     options
     JServer Release 9.2.0.1.0 - Production
    

     

     

    I found Oracle to be a little unstable when testing

    this, but once it is loaded and all the classes are

    fully compiled in Oracle, it is pretty snappy.