Don't know if this is the problem but its possible.

When you use the client the classes you reference are the ones on the server
with ejb.
When you use the other server you are referencing old version of the classes
and so you get a class cast exception.

Make sure the classes are the same.

Hope this helps.

Owen

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Cugier
(extern)
Sent: 10 October 2001 15:40
To: Orion-Interest
Subject: Error Accessing an EJB through a Bean


We created a Bean to access an EJB from JSPs. First we tested the Bean from
a Java Client and everything worked fine. Then we copied the Bean to the
Orion server and tried to acces the EJB by using a JSP that instanciates the
Bean that accesses the EJB. But we can not get it to work. The test with the
Java client still works properly. But using the Bean from JSP always creates
a ClassCastException.

Here's the sniplet from the Bean where the lookup is performed.

private static GUIServiceSBHome getHome(){
    GUIServiceSBHome toReturn = null;
    try
    {
      Hashtable env = new Hashtable();

      //ToDO if this bean runs inside a container this Env property will not
be
      //necessary
      env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.evermind.server.rmi.RMIInitialContextFactory");
      env.put(Context.SECURITY_PRINCIPAL, "admin");

      env.put(Context.SECURITY_CREDENTIALS, "xyz");
      env.put(Context.PROVIDER_URL,
"ormi://164.139.33.191:23791/bizDataNew");

      // Replace <EJB ModuleName> below with the EJB module name identified
      // in your deployment profile
      Context ctx = new InitialContext(env);
      Object ref = ctx.lookup("GUIServiceSB");
      logger.debug("> > > > > >>>>>>>   Got an Object.. Class = " +
ref.getClass());
      toReturn = (GUIServiceSBHome)PortableRemoteObject.narrow(ref,
GUIServiceSBHome.class);
      logger.debug("> > > > > >>>>>>>   Lookup........5");
    }
    catch(Throwable ex){
      logger.error( "Unable to perform lookup for GUIServiceBean Home
interface\nException = " + ex.toString() );
    }
    return toReturn;
  }

The logger.debug statements create the following output.

>From the Client:
de.mgi.frontend.GUIServiceProxyBean: > > > > > >>>>>>>   Got an Object..
Class = class __Proxy0
de.mgi.frontend.GUIServiceProxyBean: > > > > > >>>>>>>   Lookup........5

On the Server (Bean used by JSP):
de.mgi.frontend.GUIServiceProxyBean: > > > > > >>>>>>>   Got an Object..
Class = class GUIServiceSBHome_StatelessSessionHomeWrapper215
de.mgi.frontend.GUIServiceProxyBean: Unable to perform lookup for
GUIServiceBean Home interface Exception = java.lang.ClassCastException:
GUIServiceSBHome_StatelessSessionHomeWrapper215 was not an instance of
interface de.mgi.orca.business_data.ejb.session.gui.GUIServiceSBHome, the
interface it implements is
de.mgi.orca.business_data.ejb.session.gui.GUIServiceSBHome

Next to the relevant question why does the Bean get an exception when it is
executed on the server, there are also two more questions that I have when I
look at the ouput.

1. Why is the return value of ref.getClass() different? The client and the
JSP are accessing the same EJB on the same Orion server.
2. Why does it says the retrieved object is not an instance of the interface
...GUIServiceSBHome but an instance of ...GUIServiceSBHome? For me the two
interface classe names look the same.

And hint why the bean is not working on the server is greatly appreciated.

Peter Cugier

Database and Web Technology Consulting
Georg-Simon-Ohm-Str. 4, 45701 Herten (GERMANY)
Phone: +49(0)209 3593777 Fax: +49(0)209 3593766
E-Mail: [EMAIL PROTECTED]





Reply via email to