Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Trouble calling EJB from JWeb Cartridge

Trouble calling EJB from JWeb Cartridge

From: <jho_at_my-deja.com>
Date: Tue, 13 Jul 1999 21:25:34 GMT
Message-ID: <7mgas0$v45$1@nnrp1.deja.com>


I have installed on a SUN box the following:

Oracle Application Server 4.0.7
Apache and JServ 1.0b4
Jonas EJB Server 1.3
rmiregistry on 1199

when I run standalone clients to access the EJB deployed in the EJB server, all works as expected both
from another machine or locally. I add the client code to a servlet on Apache and it also works as
expected. I take the same bean code and build a JWeb cartridge and it throws the following exception:

[Root exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException:
hi.BullHelloHelloHome_Stub]javax.naming.CommunicationException

If I run the application (as per the debugging instructions):

java HelloWorld

it works fine as well. It only throws the exception when running in OAS. I have tried about everything I can think of:

- changed to JDK 1.1.7 ( yes I know it is not supported)
- changed classpath to match Apache configuration
- checked all permissions
- restarted many times

Does OAS have a sandbox type of mentality around the cartridges? It is like there is no access granted
on the port. Has anyone had any success with RMI or EJB from a JWeb cartridge?

Any help would be greatly appreciated. You will find the client side source below (sorry not pretty
stuff, it is prototype code :-).

Jeff Holt

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

import javax.ejb.*;
import javax.naming.*;

import java.rmi.*;
import java.util.*;
import java.util.Properties;

import hi.*;

import hi.HelloHome;
import hi.HelloRemote;

import oracle.html.*;

class HelloWorld {

    public static void main (String args[]) throws NamingException {

        HtmlHead hd = new HtmlHead("Hello World");
        HtmlBody bd = new HtmlBody();
        HtmlPage hp = new HtmlPage(hd, bd);

        System.err.println("test\n");
        bd.addItem("Hello, World<BR>\n");

        // Set the properties, usefull huh?
        Properties env = System.getProperties();
            env.put("java.naming.factory.initial",
"com.sun.jndi.rmi.registry.RegistryContextFactory");
            env.put("java.naming.provider.url",
"rmi://xxx.yyy.zzz.aaa:1199");
            bd.addItem( env.toString());

        // Get JNDI Context
            Context initialContext = null;

        try {
            initialContext = new InitialContext(env);
            System.err.println("<BR>\nCreated JNDI Context<BR>\n");
            bd.addItem("Created JNDI Context:<BR>\n");
            bd.addItem("<BR>");

}
catch (NamingException e){ bd.addItem("Cannot get initial context for JNDI: " + e + "<BR>\n"); //System.exit(2);
}
// Connect to helloHome the Home boy bean HelloHome home = null; bd.addItem( "looking up HelloHome<BR>\n" ); try{ home = (HelloHome) initialContext.lookup("HelloHome"); System.err.println("connected to HelloHome\n"); bd.addItem("Connected to HelloHome.<BR>\n");
}
catch (Exception e){ System.err.println("Cannot lookup HelloHome: " + e + "\n"); bd.addItem( "Cannot lookup HelloHome: " + e + "<BR>\n"); //System.exit(2);
}
// Create the Home bean HelloRemote homeBean = null; try{ bd.addItem("Create a bean<BR>\n"); homeBean = home.create();
}
catch (Exception e){ bd.addItem( "Cannot create HomeBean: " + e + "<BR>\n"); //System.exit(2);
}
try { // Say Hello bd.addItem(homeBean.sayHello());
}
catch (Exception e) { bd.addItem( "Can't say Hello today because: " + e + "<BR>\n");
}
hp.printHeader(); hp.print();
}

}

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Tue Jul 13 1999 - 16:25:34 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US