Skip to content

AlreadyBuiltException: This object has already been built #3916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rwinch opened this issue Jun 6, 2016 · 9 comments
Closed

AlreadyBuiltException: This object has already been built #3916

rwinch opened this issue Jun 6, 2016 · 9 comments
Assignees
Labels
in: config An issue in spring-security-config type: bug A general bug
Milestone

Comments

@rwinch
Copy link
Member

rwinch commented Jun 6, 2016

From #3825 (comment)

I had the same issue.

I was wiring a custom AuthenticationSuccessHandler into my security configuration that indirectly referenced a @service bean with an @Autowired reference to AuthenticationManager. After some thought, I'm surprised it worked - but no problems at all at runtime! Perhaps some sort of wiring order / race condition helped me out? However, while running the same vacuous test mentioned by @whittle, I encountered the dreaded AlreadyBuiltException.

Note that in a very stripped down version of my application I was debugging this issue with, I did receive a BeanCurrentlyInCreationException on AuthenticationManager but only during testing - not at runtime. Not exactly the same issue, but could be related behavior. See here: https://github.com/davidkey/SecurityTestErrorPOC.

My fix was to add @lazy to my AuthenticationSuccessHandler in my security configuration while I rethink my architecture a bit.

HTH.

@rwinch rwinch added in: config An issue in spring-security-config type: bug A general bug labels Jun 6, 2016
@rwinch rwinch added this to the 4.1.1 milestone Jun 6, 2016
@rwinch rwinch self-assigned this Jun 6, 2016
@Turbots
Copy link

Turbots commented Jun 7, 2016

Hey @rwinch as I already mentioned on Gitter, here's my example of the problem, the latest commit is failing while the commit before that works: https://github.com/Turbots/data-jpa-preautorize-sample

@rwinch
Copy link
Member Author

rwinch commented Jun 17, 2016

@davidkey Thanks for the comment. I'm trying to reproduce this and unable to. Can you provide exact steps for reproducing the issue?

@rwinch
Copy link
Member Author

rwinch commented Jun 17, 2016

@Turbots Thanks for creating your sample. I was able to reproduce the issue using your sample. I'm going to break this out into a separate issue since I'd like to confirm your case separately.

@rwinch
Copy link
Member Author

rwinch commented Jun 17, 2016

@Turbots Turns out your issue is very related to #3934 so I am not going to create a specific issue for it. However, I did add a test case to ensure that your problem is resolved.

@davidkey
Copy link

@rwinch Here's a gist with a full dump of what I'm seeing. Oddly, I was NOT able to reproduce the issue on travis-ci.

Going to give it a shot on a seperate (windows) install on the same machine and see if I see the same behavior. Will report back shortly.

@davidkey
Copy link

Same PC, running Windows 10 (vs Ubuntu 16) and I do not experience the issue. Same versions of source code / dependencies / maven / java (if that even makes a difference?).

Very strange. Perhaps some weird thread / prioritization issue? Let me know if there's anything else you'd like me to try.

@rwinch
Copy link
Member Author

rwinch commented Jun 17, 2016

@davidkey Thanks for the fast response! I just pushed some fixes into master that may have fixed your issue.

Perhaps the easiest thing would be for you to try running against the latest SNAPSHOT yourself? To do so you have two options:

  • Wait until the build completes and add https://repo.spring.io/libs-snapshot to your maven repositories.
  • Alternatively, you can clone master and do a "./gradlew install" which will install the code into your local maven repository.

In your project you can then define a property of:

<properties>
    <spring-security.version>4.1.1.BUILD-SNAPSHOT</spring-security.version>
</properties>

If you could respond that your issue is fixed or not, that would be greatly appreciated! If it is not, we can continue to hunt for the issue.

@davidkey
Copy link

@rwinch Using the latest SNAPSHOT fixed it! Awesome - thanks!

@rwinch
Copy link
Member Author

rwinch commented Jun 17, 2016

@davidkey Thanks for the fast report! Given your feedback I'm going to close this as fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: config An issue in spring-security-config type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants