Error: Injector is missing a rule........

Joe's Avatar

Joe

23 May, 2011 11:05 PM

I can't seem to figure out why I am getting the following error:

Error: Injector is missing a rule to handle injection into target [object IngredientInputMediator]. Target dependency: com.view.input::IngredientInput

The knowlege base states : "This error means that the injector has not been provided with an appropriate mapping to provide the dependency."

I have my view and mediator mapped in my context like so:
mediatorMap.mapView(IngredientInput, IngredientInputMediator);

and within my IngredientInputMediator I have the following:
[Inject] public var ingredient:IngredientInput;

I have does this several time throughout the rest of my app and all the others seem to work fine, does anyone have any possible ideas?

Thanks,

  1. Support Staff 2 Posted by Till Schneidereit on 23 May, 2011 11:36 PM

    Till Schneidereit's Avatar

    Hey Joe,

    that's weird. Are you perhaps creating the view in some other way than
    the others? Normally, the view is automatically mapped in the injector
    during creation of the mediator. Since I have no clue about how that
    could possibly go wrong, my best guess is that you're creating the
    mediator manually, but are still using the injector to do so.

    If that's not the case, could you perhaps post some code that shows
    the problem? If you don't feel like showing the code to everyone, you
    can either make the ticket private in Tender, which would cause only
    you and us members of the support-staff to be able to see it, or mail
    it to me directly at [email blocked].

    cheers,
    till

  2. 3 Posted by Joe on 24 May, 2011 03:49 PM

    Joe's Avatar

    I figured it was weird. I don't have anything special going on. I have no issue posting the code, it is just an app I am building to learn Robot legs.

    Context.as
    override public function startup():void

        {
            trace("\n", "Log - " + this);
    
            mapViews();
            mapModels();
            mapCommands();
            mapServices();
    
            trace("     :: Dispatching ContextEvent.STARTUP_COMPLETE");
            dispatchEvent(new ContextEvent(ContextEvent.STARTUP_COMPLETE));
        }
    
    
        // - PRIVATE METHODS - //
        private function mapViews():void
        {
            trace("     :: Mapping Views to Mediators");
            //Inputs
            mediatorMap.mapView(MealItemInput,MealItemMediator);
            mediatorMap.mapView(ServingSizeInput, ServingSizeMediator);
            mediatorMap.mapView(IngredientAmountInput, IngredientAmountMediator);
            mediatorMap.mapView(CalorieCountInput, CalorieCountMediator);
            mediatorMap.mapView(FatCountInput, FatCountMediator);
            mediatorMap.mapView(IngredientInput, IngredientInputMediator);
    
            //Dropdowns
            mediatorMap.mapView(FoodCategoryInput, FoodCategoryMediator);
            mediatorMap.mapView(ChooseIngredientInput,ChooseIngredientMediator);
    
            //Layouts
            mediatorMap.mapView(IngredientListLayout, IngredientListMediator);
            mediatorMap.mapView(IngredientLayout, IngredientInputMediator);
    
            //buttons
            mediatorMap.mapView(AddIngredientButton, AddIngredientMediator);
            mediatorMap.mapView(NewIngredientButton, NewIngredientMediator);
        }
    

    IngredientInput.mxml
    <s:HGroup xmlns:fx="http://ns.adobe.com/mxml/2009"

          xmlns:s="library://ns.adobe.com/flex/spark" 
          xmlns:mx="library://ns.adobe.com/flex/mx" 
          width="228" 
          height="30" 
          verticalAlign="middle" 
          paddingLeft="5" 
          paddingRight="5" 
          paddingTop="5" 
          paddingBottom="5">
    
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Label text="Ingredient"/>
    <s:TextInput width="152" id="Ingredient_TextFeild"/>
    

    </s:HGroup>

    ingredientInputMediator.as
    public class IngredientInputMediator extends Mediator

    {
        //- PROPERTIES - //
        [Inject] public var ingredientInput:IngredientInput;
    
    
        //- CONSTRUCTOR - //
        public function IngredientInputMediator()
        {
            super();
        }
    
        // - PUBLIC METHODS - //
        override public function onRegister():void
        {
            trace("\n", "Log - " + this + ".onRegister()");
            trace("     :: the Ingredient Input View object has been injected, we have reference to that object");
    
    
            // The event map lets us listen for events broadcasted by view elements
            trace("     :: listening for events broadcasted by the IngredientInput view component");
            eventMap.mapListener(ingredientInput.Ingredient_TextFeild,FocusEvent.FOCUS_OUT, onExitFocus);
        }
    
    
        // - PRIVATE METHODS - //
        private function onExitFocus(event:FocusEvent):void
        {
            trace("\n", "Log - " + this + ".onExitFocus()");
            trace("     :: Dispatching the IngredientInputEvent.ADD_INGREDIENT event");
            dispatch(new IngredientInputEvent(IngredientInputEvent.ADD_INGREDIENT, event.currentTarget.text));
        }
    
    }
    
  3. 4 Posted by Joe on 24 May, 2011 03:54 PM

    Joe's Avatar

    related files attached. Thanks,

  4. Support Staff 5 Posted by Till Schneidereit on 24 May, 2011 04:09 PM

    Till Schneidereit's Avatar

    Mmh, from these files I can't see any problems that would cause the
    symptoms you're experiencing.

    I'm afraid I still can't help you based on the information I currently
    have. I would still offer you to send me the entire project by private
    mail. If you don't want to do that, maybe I can tell you something
    useful if you post the entire stacktrace from the exception you're
    getting.

  5. 6 Posted by Stray on 24 May, 2011 04:18 PM

    Stray's Avatar

    I can't see anything here either (just as a sanity check for Till!)

    One question I have is whether the view is getting GC'd before the injection finishes... - though I'm not sure that's even possible, it depends whether Till has used his special weak references sauce in the injector at that point?

    Also willing to cast my eye over the stack trace here,

    Stray

  6. Support Staff 7 Posted by Till Schneidereit on 24 May, 2011 04:31 PM

    Till Schneidereit's Avatar

    Thanks, Stray!

    GC can't be the culprit: A mapping response is always strongly
    referenced: How else would value and singleton mappings guarantee
    their responses?

  7. 8 Posted by Stray on 24 May, 2011 04:39 PM

    Stray's Avatar

    I thought as much - and the mediatorMap is using a hard reference... so... where on earth is it going? The mystery of the missing view...

  8. 9 Posted by Joe on 24 May, 2011 06:20 PM

    Joe's Avatar

    All seems to be working now, I deleted the reference to the IngredientInput component from my application, saved it and put it back. No more error. I should have just done this from the beginning, however I do appreciate you guys taking the time to look at my files in order to help me out.

    Thanks again,
    Joe

  9. 10 Posted by Stray on 24 May, 2011 07:06 PM

    Stray's Avatar

    No worries Joe - and thank goodness it was just a corrupt file somewhere - I was really scratching my head there.

  10. Support Staff 11 Posted by Till Schneidereit on 24 May, 2011 07:53 PM

    Till Schneidereit's Avatar

    Thanks for the info - just as Stray, I'm glad you sorted it out and we
    didn't have to fix some odd corner-case.

  11. Ondina D.F. closed this discussion on 01 Nov, 2011 11:23 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac