I'm trying to instantiate a simple bean:

The class object for the bean as looked up says it implements my home 
interface, but in reality it does not (see jsp code below):

  |       Object theBean =
  |         ctx.lookup("DemoBean");
  |       out.write("<hr /><h3>looked up DemoBean</h3><hr />");
  |       
  |       Method!! methods = theBean.getClass().getDeclaredMethods();
  |       out.write("<p>Methods:<ul>");
  |       for (int i = 0; i < methods.length; i++) {
  |         out.write("<li>" + methods!i!.getName() + "</li>");
  |       }
  |       out.write("</ul></p>");
  | 
  |       Class!! interfaces = theBean.getClass().getInterfaces();
  |       out.write("<p>Interfaces:<ul>");
  |       for (int i = 0; i < interfaces.length; i++) {
  |         out.write("<li>" + interfaces!i!.getName() + "</li>");
  |       }
  |       out.write("</ul></p>");
  | // list includes my home interface: ejb.demo.DemoHome
  |       
  |       out.write("<hr />" + 
  |               ((theBean instanceof ejb.demo.DemoHome) ? 
  |                   " is " : " is not " ) +
  |               "an instance of DemoHome");
  |   // note: it is not
  | 
  |       out.write("<hr />" + 
  |               ((theBean.getClass().
  |                     isAssignableFrom(ejb.demo.DemoHome.class) ) ?
  |                 " is " : " is not " ) +
  |               "assignable from DemoHome");
  |   // note: it is not
  | 
  |       out.write("<hr />about to try cast");
  |       ejb.demo.DemoHome dhome = (ejb.demo.DemoHome) theBean;
  | //fails with ClassCastException
  | 
Is this a some sort of scoping issue?  (Note that I created this thru NetBeans 
5.0, which wanted me to have two separate projects within the same application 
-- the above file is in the WebModule, while the EJB classes are in the 
EJBModule)


Note that in the above code ! are used for array brackets, because, try as I 
might, I could not get bbCode to be disabled, at least in the preview (ditto  
for HTML actually, but in bbCode mode that didn't seem to matter)


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957821#3957821

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957821
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to