Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • 03:28
    spring-projects-issues labeled #27541
  • 03:25
    huifer commented #27541
  • 03:24
    huifer opened #27541
  • 01:25
    quaff commented #27534
  • Aug 01 23:39
    sivaprasadreddy commented #17089
  • Aug 01 23:28
    spring-projects-issues labeled #27540
  • Aug 01 23:25
    ghj1040110333 commented #27540
  • Aug 01 23:24
    ghj1040110333 opened #27540
  • Aug 01 19:18
    dreis2211 synchronize #27539
  • Aug 01 15:03
    spring-projects-issues labeled #27539
  • Aug 01 15:02
    dreis2211 opened #27539
  • Aug 01 06:38
    spring-projects-issues unlabeled #27530
  • Aug 01 06:38
    spring-projects-issues labeled #27530
  • Aug 01 06:36
    han1448 commented #27530
  • Aug 01 05:26
    wuwen5 edited #27538
  • Aug 01 05:18
    wuwen5 synchronize #27538
  • Aug 01 04:43
    spring-projects-issues labeled #27538
  • Aug 01 04:43
    wuwen5 opened #27538
  • Aug 01 01:28
    spring-projects-issues labeled #27537
  • Aug 01 01:27
    izeye opened #27537
Vyacheslav N. Boyko

Hello! I'm seeing some issues with a class (class A) marked with Configurable annotation autowiring another class. Class A is being manually instantiated by Class X that's not Spring managed. Class A is autowiring class B. There is a delay in the instantiation order of Class A and class B. As a result, we end up hitting an NPE in class A, when it tries to invoke a method in class B. I tried debugging the issue to see in what order the 2 classes are being instantiated. I'm seeing two issues here - 1) post construct method in class A is never called 2) post construct method in class B is being called 2-3 minutes after I see a log message from an init function in class A. I've tried setting @Configurable(preconstruct = true, autowire=Autowire.BY_NAME), but no luck. Any comments/suggestions?

@aghag10 1) try to instantiate your class A by Spring itself. 2) don't use @Autowire on property private ClassB classB, turn it out to ClassA's constructor param.

@bvn13 1) I can't make class A spring managed since class X that's instantiating class A can not be made Spring managed. 2) I don't follow. If that's the case, class B won't be autowired anymore?

1) I got it. 2) This way - yes. But I've found an example of how to get spring bean from outside of spring-managed zone https://confluence.jaytaala.com/display/TKB/Super+simple+approach+to+accessing+Spring+beans+from+non-Spring+managed+classes+and+POJOs

Witold Kupś
@boda2004 the problem is that that nginx is not mine - I am using this API, only. And pay for it...
20min ago it worked ...
Ibanga Enoobong Ime
use https?
Alexander Wilhelmer
apply plugin: 'wro4j' <--- how?
Stéphane Nicoll
@awilhelmer nothing to do with the plugin but rather the repositories you’ve defined in your build. Check the Gradle forum for more help on that
repo.spring.io does not service requests on http anymore
Hi! Does anybody know how can I force all nested transactions within a method to use its very same parent transactionManager? nested transactions com from dependencies annotated with @transactional, which ends up being binded to the @Primary TransactionManager, not the one declared in my parent method
The weird thing is that theres no propagation specified, so I would have guessed that Propagation=REQUIRED adopted by all means parent transaction, including its transactionmanager
Observing this, https://github.com/spring-projects/spring-framework/blame/cef4478b7b917033a8a01a6e633f6f59aab67e59/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java#L449, which hasnt been changed in 3 years, I assume that's the expected behavior:
evaluation of transactionmanager is done on each @Transactional and it's orthogonal to propagation type
James Howe
You need a primary transaction manager that understands multiple transaction managers
otherwise the individual managers have no way to know about each others' transactions
or make sure you always specify the right one in @Transactional
Konstantin Bläsi
can I make spring log the final configuration values (multiple sources, profiles merged) ?
James Howe
@konstantinblaesi probably one of the actuators will report what you want (configprops, env)
@OrangeDog The thing is I dont need to understand multiples, I always specify it, but I cannot modify the third-party lib, so I am looking for a way to specify the txManager for the dependency or either exclude it at all as a last resort
James Howe
What I said is still correct. Your primary manager will need some logic to decide which of the others it should delegate to (e.g. the one with a current transaction)
Konstantin Bläsi
@OrangeDog I checked configprops, very cool thanks :)
@OrangeDog sorry, I am having difficulties to understand what you describe but I am forgetting something for sure. If I go to the third-party library, delete or edit the @Transactional annotation to use same txmanager than mylib, then at what point theres delegation?
James Howe
I am assuming you don't want to or cannot edit the third-party library
exactly, but this is the behavior Id like to imitate, if i manage to do that, then do I need to do a composed manager?
if only I could do a @Transactional(propagation=ignoresubtransactions) or either something like @EnableTransactional(exclude=third-party.class)
and that is assuming that the current and expected behavior is that upon propagation=REQUIRED, transaction does support parent transaction but not parent's transactionmanager which I don't see it obvious at all
James Howe
You need a primary transaction manager that understands multiple transaction managers or make sure you always specify the right one in @Transactional
What the aspect does is determine what transaction manager to call around the method. It doesn't do any tracking of transactions or managers itself.
A third option is a custom aspect that looks at the method's class/package to decide which transaction manager to use, but IMO that's more messy.
none of which has anything to do with propagation
all the solutions seem no trivial for a hotfix then :'(...
Are we sure theres no mechanism for marking a bean as not qualifiable to support transactions? I mean something like @EnableTransactions(exclude=thirdparty.class). I need the bean to be managed, but I want the @Transactional to be ignored
Anyway, thanks for your help james
James Howe
there is not
perhaps you could do something really hacky with Bean(Definition)PostProcessors but the other solutions are all easier
@bvn13 Thanks. I'll give that a shot.
I have two models (kotlin data classes) linked through a manytomany relationship (pg database)
when I want to do A.allofB.size where allofB is the manytomany field that link A to B (through a join table)
I get in infinite recursion
I've dealt with infinite recursion when serializing my data (Json), but in that case I am not serializing anything…
(and the two manytomany sides are LAZY)
If I remove the manytomany field on the class B, then I can run that (but I cannot find all the A linked to an object B from an object of type B)
I can't find a way to have the both sides of that manytomany relation
(and I am NOT using serialization here)
I am wondering if it could be an issue with kotlin data classes that may want to hash the objects anyway
(as I am using sets)
(and that seem to be the case as turning them all into normal classes "solve" the issue)
choubani amir
Did anyone try to import multi maven spring boot project using intellij community edition ?
Unable to find find projects recursively
Konstantin Bläsi
any idea why /actuator/metrics/vm.threads.states gives me a 404 ? /actuator/metrics displays the list, but I cannot get the details for a metric?
Ingo Griebsch

Hi all, I want to test a special flyway migration step....

Me again, is someone maybe having an idea how I could solve my problem? Or is my question to special? Am I asking in the wrong channel? Would be nice to get some feedback! :)

James Howe
The 2.2.2 -> 2.2.3 update appears to have broken properties loading via @ActiveProfiles("test"). Maybe #19556 but there are no commas involved...