0

Currently seeing the exception listed below:

org.picocontainer.injectors.AbstractInjector$CyclicDependencyException: Cyclic dependency: [class pageObjects.accounts.login.ForgotPassword_PO, class pageObjects.tutors.Tutors_PO, class pageObjects.accounts.login.Login_PO, class pageObjects.accounts.login.ForgotPassword_PO, class stepDefinitions.accounts.SignUp_Steps]
    at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:265)
    at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
    at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
    at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
    at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
    at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)

I have inspected the recommended areas (Classes) related to the issue but cannot locate any repeated injected classes etc: Cyclic dependency:

[class pageObjects.accounts.login.ForgotPassword_PO, class pageObjects.tutors.Tutors_PO, class pageObjects.accounts.login.Login_PO, class pageObjects.accounts.login.ForgotPassword_PO, class stepDefinitions.accounts.SignUp_Steps]

Any ideas?

Gbru
  • 1,065
  • 3
  • 24
  • 56
  • Please add more information to the question. – AndiCover Sep 30 '19 at 13:03
  • The classes listed in the the exception form the cycle. – M.P. Korstanje Sep 30 '19 at 15:30
  • thank you for the comment @mpkorstanje do you know whether there is a way to further debug the issue in intelij? I have tried to break down the issue really minutely but still cant find any resolution – Gbru Sep 30 '19 at 15:39
  • I'd recommend pen and paper or a whiteboard to draw out the dependencies between all involved classes. – M.P. Korstanje Sep 30 '19 at 15:42
  • ok thanks @mpkorstanje its odd because I have never experienced this issue before, my understandings was you shoudnt experience any issues injecting classes into another as long as a given class doesnt try to inject the same class more than once? – Gbru Sep 30 '19 at 15:48
  • For example Class A can have class B injected into it and Class B can have class A injected into it. – Gbru Sep 30 '19 at 15:50
  • Some DI containers support that. Pico container does not. – M.P. Korstanje Sep 30 '19 at 16:24
  • ok thanks again @mpkorstanje can you recomend another replacement rather than using pico container, or do you feel its best suited with Java and cucumber? – Gbru Sep 30 '19 at 16:32
  • 1
    It's better to fix your cycle. Do the pen and paper thing. It really helps. – M.P. Korstanje Sep 30 '19 at 16:40
  • @mpkorstanje ok thank you, appreciate the help, hope you have a great evening. – Gbru Sep 30 '19 at 17:08
  • Circular dependency is a bad thing regardless of the container used. It means poor separation of responsibilities inside the app, maybe you need to move some functions between your A & B or introduce third class, that will be dependent on A or/and B, but not backward etc – xeye Oct 01 '19 at 11:50
  • thanks @xeye looks like I will need need to create a third entity to handle both A and B and ensure there is also separation between A and B so they do not become connected. – Gbru Oct 01 '19 at 12:57

0 Answers0