1 Reply Latest reply on Mar 24, 2009 11:54 PM by pmuir

    Ambiguous Class Hierarchy

    scotthernandez

      I am trying to convert an existing application (http://subethamail.org/) over to webbeans (beta1) using JBossAS 5.0.1.


      The existing application has a few components and I am starting the conversion with the front-end, and moving back (into the ejbs and queues).


      I have converted the frontend framework to work with webbeans (by hacking support using jndi on the servlet side to get the manager for action class instantiation) but I keep getting AmbiguousDependencyException because of the inheritance of our actions.


      It goes something like this (all webbeans):


      - AuthAction
         - AuthAction
         - AutoLogin
           - AuthRedirect
           - AuthRequired
             - Create*
             - Delete*
             - (some 20 other actions)
         - ForgotPassword
         - (some 20/30 more actions)
      



      So when I want to get an instance of AutoLogin there are 19 beans that satisfy that api. And I get the expected AmbiguousDependencyException.


      Here is the relevant code in the servlet:


      Class actionClassType = Class.forName(type);
      Object o = wbManager.getInstanceByType(actionClassType);
      



      Is this expected or is there something more I need to do? Since the creation of the action classes is all in code I'm a little stumped. Do I need to write my own resolver? Or will this simply not work at all without refactoring the class hierarchy?