-
1. Re: Help with lookng up a bean
radix_zero Nov 24, 2005 11:33 AM (in response to simonnunn)That Dynamic Proxy Class should implement the Local / LocalHome interface.
just make sure you use the PortableRemoteObject.narrow and you should be fine -
2. Re: Help with lookng up a bean
simonnunn Nov 24, 2005 4:45 PM (in response to simonnunn)Tried that...still didn't work. Is there something that I need to put into the WAR file? Some xml file?
-
3. Re: Help with lookng up a bean
darranl Nov 25, 2005 1:12 PM (in response to simonnunn)The PortableRemoteObject.narrow is only to be used for remote home interfaces. it should not be used for anything else.
You have missed off important information such as JBoss version, stack traces and details of how your application is packaged.
Can you execute the command 'jar -tf warname.war' against your war and post the output here. -
4. Re: Help with lookng up a bean
simonnunn Nov 25, 2005 4:38 PM (in response to simonnunn)Jboss version is 4.0.3.
I see the bean being bound:
14:34:43,265 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'Stegiuser' to jndi 'stegi/StegiuserLocalHome'
The following code always fails with a classcast exception in getLocalHome:
public static com.cei.stegi.server.beans.interfaces.StegiuserLocalHome getLocalHome() throws javax.naming.NamingException
{
return (com.cei.stegi.server.beans.interfaces.StegiuserLocalHome) lookupHome(null, com.cei.stegi.server.beans.interfaces.StegiuserLocalHome.JNDI_NAME, com.cei.stegi.server.beans.interfaces.StegiuserLocalHome.class);
}
private static Object lookupHome(java.util.Hashtable environment, String jndiName, Class narrowTo) throws javax.naming.NamingException {
// Obtain initial context
javax.naming.InitialContext initialContext = new javax.naming.InitialContext(environment);
try {
Object objRef = initialContext.lookup(jndiName);
// only narrow if necessary
System.out.println("The object ref is: " + objRef);
if (narrowTo.isInstance(java.rmi.Remote.class))
{
return javax.rmi.PortableRemoteObject.narrow(objRef, narrowTo);
}
else
return objRef;
} finally {
initialContext.close();
}
} -
5. Re: Help with lookng up a bean
simonnunn Nov 25, 2005 6:48 PM (in response to simonnunn)Problem solved. It was a classloader problem. I had the interfaces in the .war and the ejbs jar. Removed all interfaces from the war and it works now.