Hello. INLINE. > 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 > {
This part with the Hashtable is not correct. You should avoid it. Better create a jndi.properties file in the root directory of your JAR, or the root rirectory of your classes. then just use "new InitialContext()" which will get the required properties from the jndi.properties file. > 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"); Let's see. > // Replace <EJB ModuleName> below with the EJB module name identified > // in your deployment profile As said... Especialy in a web-bean use "new InitialContext()" > 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. Ok. I had the same problem. It was, that I had one and the same class (the Home Interface) in two places. Both classes, though identical these classes were not compatible :(. It is possible (like in my case) that you have the home interface both in the ejb-jar and the web-app. Try removing it from the web-app. > > And hint why the bean is not working on the server is greatly appreciated. > > Peter Cugier Lachezar.