Injector is missing a rule to handle injection into target

jeremy.brooks's Avatar


26 Apr, 2012 03:43 PM

Hi, I am building a modular application using robotlegs 1.5 and the utilities-modular library.

I've come up against a weird issue where I think I've set up a rule for an injection, but this fails at runtime.

Here is some code snippets showing the rule and injection, hopefully I've missed something obvious?


override public function startup():void{
        //map view class type, required for correct injection of modules.

        mediatorMap.mapView(MapAPIModuleShell, MapAPIModuleShellMediator);


        moduleCommandMap.mapEvent(BoundingBoxEvent.BOUNDING_BOX_IN_LAT_LONG, SaveBoundingBoxCommand);

Command and injection:

    public var bbox:BoundingBox;

    public var event:BoundingBoxEvent;

     * Handles saving bounding box to model object.
     * TODO: handle metres.
     * */
    override public function execute():void{
        if (event.type == BoundingBoxEvent.BOUNDING_BOX_IN_LAT_LONG){
            bbox = event.boundingBox;
        } else if (event.type == BoundingBoxEvent.BOUNDING_BOX_IN_METRES){
            bbox = event.boundingBox;
        //TODO: dispatch that the bounding box state has been saved

Here is the top of the stack trace:

 Error: Injector is missing a rule to handle injection into target [class BoundingBox]. Target dependency: Number, method: constructor, parameter: 1
at org.swiftsuspenders.injectionpoints::MethodInjectionPoint/gatherParameterValues()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/injectionpoints/]
at org.swiftsuspenders.injectionpoints::ConstructorInjectionPoint/applyInjection()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/injectionpoints/]
at org.swiftsuspenders::Injector/instantiate()[/Development/Projects/SwiftSuspenders/src/org/swiftsuspenders/]

Any ideas?

  1. Support Staff 1 Posted by Shaun Smith on 26 Apr, 2012 03:55 PM

    Shaun Smith's Avatar


    What does constructor of BoundingBox look like? The injector is saying that it doesn't know how to provide the first constructor argument of BoundingBox (which is a Number) when it tries to construct it.

    Also, your command has a dependency on BoundingBox, yet it also maps BoundingBox as a singleton when it executes. Have you mapped the BoundingBox elsewhere, and are you intending to overwrite the mapping in the command?

  2. 2 Posted by jeremy.brooks on 26 Apr, 2012 03:58 PM

    jeremy.brooks's Avatar

    Just spotted that I left in the extra injection in the command, didn't mean to leave that in, I was experimenting, I've edited it now, thanks for the spot Shaun.

  3. 3 Posted by jeremy.brooks on 26 Apr, 2012 03:59 PM

    jeremy.brooks's Avatar

    The bounding box constructor looks like this;

      public function BoundingBox(minx:Number, miny:Number, maxx:Number, maxy:Number, srs:String = "EPSG:4326"){
        _minx = minx;
        _miny = miny;
        _maxx = maxx;
        _maxy = maxy;
        _srs = srs;
  4. 4 Posted by jeremy.brooks on 26 Apr, 2012 04:06 PM

    jeremy.brooks's Avatar

    Shaun, you sparked an idea there, so instead of using mapsingleton I've used mapValue, providing a default object, worked great, thanks!

    injector.mapValue(BoundingBox, new BoundingBox(0,0,0,0));

  5. Support Staff 5 Posted by Shaun Smith on 26 Apr, 2012 04:09 PM

    Shaun Smith's Avatar

    Aha, that's the problem right there :)

    The injector has no idea how to create an instance of BoundingBox - it doesn't know how to provide any of the constructor arguments. You have a couple of options:

    1. Make all the ctor arguments optional (with default values)
    2. Provide the instance yourself when doing the mapping: injector.mapValue(BoundingBox, new BoundingBox(7,5,90,90));
  6. Support Staff 6 Posted by Shaun Smith on 26 Apr, 2012 04:09 PM

    Shaun Smith's Avatar

    You beat me to it :)

  7. Shaun Smith closed this discussion on 26 Apr, 2012 04:09 PM.

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

Keyboard shortcuts


? 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