[scaldi-play 0.5.9] StackOverflowError When Injecting Application Or Mode

57 views
Skip to first unread message

Neil Chaudhuri

unread,
Oct 4, 2015, 9:23:35 AM10/4/15
to scaldi
I have a static asset resolver class that simply figures out whether to rely on Play to serve static assets in development or a CDN in production, I can inject a configuration string just fine. But when I inject Mode or Application, I get the StackOverflowError. If I inject Configuration, which I don't need but just thought I'd try, it works.

This code was working before upgrading to the latest version of Scaldi. Is it possible the new version might have an issue with loading Application? 

Thanks.

Oleg Ilyenko

unread,
Oct 4, 2015, 3:53:30 PM10/4/15
to scaldi
Hi Neil,

sorry for the late reply. It's possible that new scaldi version influenced this because the module loading order is now changed (application modules got priority over built-in play modules). `StackOverflowError` generally means that there are some circular dependencies. These can be indirect dependencies, so sometimes it can be challenging to figure these out. It's hard to suggest a solution based solely on the description you provided - it would be very helpful if you could make reduced example  of the code that reproduces the issue.

Cheers,
Oleg

Neil Chaudhuri

unread,
Oct 6, 2015, 9:23:47 PM10/6/15
to scaldi
I have been unable to reproduce the exact issue, but I did create a clean codebase here for you to look at. I find that I can't get the custom error handler MyErrorHandler to work. I get this:

scaldi.InjectException: No binding found with following identifiers:
  * TypeTagIdentifier(() => controllers.Mailer)

When I comment it out, everything works just fine. 

I discovered in my real app that commenting out the binding for my error handler makes everything work too. Granted I find a different error, but that is probably a function of other secondary complexities. I think it comes down to the error handler binding in both cases.

Take a look at my toy app, and let me know if I am doing something wrong. If so, I am probably doing the same wrong thing in both apps.

Thanks.

Neil Chaudhuri

unread,
Oct 10, 2015, 6:53:20 PM10/10/15
to scaldi
I added some more things and have reproduced my bug exactly in the toy application. Again, I can't say if it is a bug or something I'm doing wrong (which is, let's face it, far more likely), but at least you can see it more much more simply.

Again the toy application can be found here.

Thanks.

Neil Chaudhuri

unread,
Oct 10, 2015, 9:24:38 PM10/10/15
to scaldi
Just some diagnostic information. The StackOverflowError is centered on the StaticAssetResolver class. If I remove its binding or if I remove it from the constructor for MyErrorHandler, everything works fine. 

The really interesting thing is that if I simply remove the injection of Mode into StaticAssetResolver everything works fine. I am not sure how Mode can lead to a circular dependency.

Thanks.

Oleg Ilyenko

unread,
Oct 11, 2015, 1:01:39 PM10/11/15
to scaldi
Hi Neil,

Thanks a lot for you patience! I'm sorry such a big delays in my replies, It was a bit busy time recently for me. Thanks for the example app, it helped a lot! It turns out that the issue was with the `Mode` binding. It was depending on the play `Application` and this created a circular dependency. I just fixed it in v0.5.10, so soon it should be available from the central. I also created this small PR:


Cheers,
Oleg

Neil Chaudhuri

unread,
Oct 11, 2015, 8:51:46 PM10/11/15
to scaldi
Hey Oleg,

No worries on the delay. Coincidentally, I discovered that the Mailer binding in my toy app didn't match what I had in my real app, and then when I pushed that change, I saw your PR and your own comment on the same thing.

But I am glad that the toy app helped you figure out the issue with Mode. I upgraded to 0.5.10 and things work now.

Thanks for your help!
Reply all
Reply to author
Forward
0 new messages