jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
695 stars 125 forks source link

Circular reference when injecting SessionRegistry #1455

Closed khurry closed 2 weeks ago

khurry commented 1 year ago

Tested in jmix 1.4.1 and 1.4.4 Case:

  1. Create a jmix fullstack project
  2. Create a spring bean in "screen" package and inject SessionRegistry in it using constructor:
@Component
public class TestBean {
  private final SessionRegistry sessionRegistry;

  public TestBean(SessionRegistry sessionRegistry) {
    this.sessionRegistry = sessionRegistry
  }
}
  1. Run @SpringBooTest-test, for example, default JmixTestApplicationTests.
  2. Get an exception:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testBean' Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'io.jmix.security.SecurityConfiguration': Unsatisfied dependency expressed through field 'sessionRegistry'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sec_SessionRegistry': Requested bean is currently in creation: Is there an unresolvable circular reference?

Looks like SecurityConfiguration can't be instantiated because it contains sessionRegistry autowired itself.

gorbunkov commented 10 months ago

We need to check this after fixing the https://github.com/jmix-framework/jmix/issues/287

SergeiAksenov2 commented 2 weeks ago

Tested on Jmix version: 1.6.999-SNAPSHOT: 1) Jmix Studio plugin version: 2.4.SNAPSHOT6960-242 IntelliJ version: IntelliJ IDEA 2024.2.4 (Community Edition) 2) Jmix Studio plugin version: 2.5.SNAPSHOT6966-243 IntelliJ version: IntelliJ IDEA 2024.3 (Community Edition)