Issues upgrading Play 2.4 to 2.5 - circular dependency play.api.Application

Hi everyone,

I’m upgrading a legacy application from Play 2.4 to 2.5. I’m having an issue with updating the controllers to use DI, particularly the controllers which used to rely on play.api.Play.current. I have added the Application to be injected, and now I end up with this error: Tried proxying play.api.Application to support a circular dependency, but circular proxies are disabled.

From the Googling I’ve done already, I know what is causing the issue, but the solutions provided don’t help. If I try and inject either Environment or Configuration I get: Error injecting constructor, java.lang.RuntimeException: There is no started application and I can’t seem to work out what to inject to get the current application if I can’t inject Application.

Any assistance would be great as I feel I’ve either missed something simple or am doing something silly!


It’s difficult to say without access to your code. You probably used to (still do) have a cyclic dependency and now, by adding run-time DI, it won’t let you maintain it. Is that the case? Ideally you should eliminate it first and then apply the injector.

Injecting Configuration or Environment should be fine. But as @andyczerwonka said, it would be best if you can share the code.

A stack trace would be helpful. If you use a Module you have access to the Environment and Configuration before the Application is even started. See the docs here.