Remy Maucherat writes:
> Quoting [EMAIL PROTECTED]:
>
> >
> > Remy Maucherat writes:
> > > I've updated the object factory for the EJB references. It should now
> > > attempt to resolve ejb-links using a JNDI lookup.
> > > I can't really test the feature, so I'm waiting for your feedback and
> > stack
> > > traces, if it goes wrong ;-)
> > >
> > I finally got all pieces downloaded and compiled the change....
> > Now we get an exception on the correct class name...:
> >
> >
> > S_STRESS_31K [true] | org.apache.naming.EjbRef |
> > javax.naming.NamingException:
> > cool.models.coop07.java.S_STRESS_31KpsHome
> >
> > javax.naming.NamingException:
> > cool.models.coop07.java.S_STRESS_31KpsHome
>
> The exception isn't very clear. It can't load the home interface, right ?
> To debug that problem, the factory won't fail if loading of the home interface
> fails or if the type checking fails. If something like that happens, a message
> will be printed out on the console, but the bean instance will still be
> returned.
>
> However, if the factory can't load the home interface class, your servlet will
> probably not be able to either (which is a problem).
>
> Remy
Please do not test the class of the REMOTE OBJECT returned from the EJB
server.
The servlet has no problem loading or casting the remote object to the home
interface class because the servlet classes include the EJB client classes.
The actual object name of the remote object is $Proxy??? (where ??? is a
number between 0 and 999).
That proxy object represents the Home Interface and can be cast to the home
interface. But the remote object cannot be tested correctly with the
'Class' object.
Please use the following code snip, it includes the only test that actually
succeeds.
if (linkRefAddr != null) {
// Retrieving the EJB link
String ejbLink = linkRefAddr.getContent().toString();
Object beanObj = null;
try {
beanObj = (new InitialContext()).lookup(ejbLink);
String homeClassName = ref.getClassName();
if (!homeClassName.endsWith(beanObj.toString()))
System.out.println("EJB link \"" + ejbLink
+ "\" of EJB Object: " + beanObj
+ " is not castable to: " + homeClassName);
} catch (Exception e) {
System.out.println("EJB link \""+ejbLink+"\" failed: "+e);
}
return beanObj;
}
Tim