Hello,

I see I misunderstood. The stacktrace I posted earlier was for unmodified 
code.

Attached is another stacktrace, obtained after replacing all* 
@Transactional(**readOnly = true**)* with
*@Transactional(transactionManager = "transactionManagerEvents", readOnly = 
true)*. The transaction manager seems to be selected
correctly this time, *JpaCasEventRepository:getEventsOfTypeForPrincipal()* 
executes and returns a stream without throwing an exception,
but a new one is thrown in 
*BaseAuthenticationRequestRiskCalculator:calculate()*, when the results are 
to be collected in this line:

*val events = 
getCasTicketGrantingTicketCreatedEventsFor(principal.getId()).collect(Collectors.toList());*

This also seems to happen when I delete the *@Transactional(**readOnly = 
true**)* lines altogether.
I suspected I configured jpa wrongly, but when I drop tables *cas_event* 
and *events_properties*, 
add *ddlAuto=create* and run again, these tables get created. I have no 
idea for this one.

Kind regards,
Michał Nowakowski

czwartek, 30 listopada 2023 o 10:29:16 UTC+1 Mohamed Amdouni napisał(a):

> Hello,
>
> Your case is different from mine. Don't find an explanation why it 
> returns 2 transactionManagers especially if you annotated the methods with 
> the Qualifier...
>
> What if you add a @Primary TransactionManager bean, so it will be called 
> if there are more than one TransactionManager retreived...
>
> Best regards. 
>
> Le mer. 29 nov. 2023 à 16:06, Michał Nowakowski <mjnowa...@gmail.com> a 
> écrit :
>
>> Hello,
>>
>> The stacktrace doesn't get printed to logs, but I got it with a debugger. 
>> Please see the attachment.
>>
>> Also, I simplified my example a bit too much, there has to be at least 
>> one risk calculator enabled for error to occur. I use:
>>
>> *cas.authn.adaptive.risk.ip.enabled=true*
>>
>>
>> Kind regards,
>>
>> Michał Nowakowski
>>
>> wtorek, 28 listopada 2023 o 15:46:09 UTC+1 Mohamed Amdouni napisał(a):
>>
>>> Hello,
>>>
>>> Would you please share the whole trace with caused by etc.
>>>
>>> I think it’s similar to what I have encountered using two jpa module : 
>>> see my question about a similar error.
>>>
>>> I think that it’s a bug in cas because it should use a default Primary 
>>> transaction manager when a spring integration default class uses 
>>> @Transactional without qualifier.
>>>  But better share your complete trace to check.
>>>
>>> Best regards.
>>>
>>> Le mar. 28 nov. 2023 à 14:25, Michał Nowakowski <mjnowa...@gmail.com> a 
>>> écrit :
>>>
>>>> I seem to have an issue with 7.0.0-RC9 when combining
>>>> cas-server-support-electrofence with cas-server-support-events-jpa.
>>>>
>>>> Example build: here 
>>>> <https://casinit.herokuapp.com/ui?artifactId=cas&casVersion=7.0.0-RC9&commandlineShellSupported=true&dependencies=webapp-tomcat,support-electrofence,support-events-jpa,support-json-service-registry&deploymentType=executable&description=WAR%20overlay%20to%20use%20as%20a%20starting%20template%20for%20Apereo%20CAS%20deployments.&dockerSupported=true&githubActionsSupported=true&groupId=org.apereo.cas&helmSupported=false&herokuSupported=false&javaVersion=11&language=java&name=cas&nativeImageSupported=false&openRewriteSupported=true&packageName=org.apereo&packaging=war&puppeteerSupported=true&type=cas-overlay&version=1.0.0>
>>>> ;
>>>>
>>>> Example configuration:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *cas.events.jpa.driverClass=org.postgresql.Drivercas.events.jpa.dialect=org.hibernate.community.dialect.PostgreSQL95Dialectcas.events.jpa.url=jdbc:postgresql://localhost/cas7cas.events.jpa.user=CONFIGUREcas.events.jpa.password=CONFIGUREcas.service-registry.json.location=file:///etc/cas/config/services*
>>>>
>>>> At specified json location, there needs to be a JSON service,
>>>> I used the example one from 
>>>> https://apereo.github.io/cas/development/services/JSON-Service-Management.html
>>>>
>>>> When I log in with default user and password, I get thrown back to 
>>>> login page. In logs, I can see WARN messages:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *2023-11-28 09:44:29,314 WARN 
>>>> [org.apereo.cas.web.flow.resolver.impl.DefaultCasDelegatingWebflowEventResolver]
>>>>  
>>>> - <No qualifying bean of type 
>>>> 'org.springframework.transaction.TransactionManager' available: expected 
>>>> single matching bean but found 2: 
>>>> ticketTransactionManager,transactionManagerEvents 
>>>> DefaultListableBeanFactory.java:resolveNamedBean:1310 
>>>> DefaultListableBeanFactory.java:resolveBean:484 
>>>> DefaultListableBeanFactory.java:getBean:3392023-11-28 09:44:29,314 WARN 
>>>> [org.apereo.cas.web.flow.resolver.impl.DefaultCasDelegatingWebflowEventResolver]
>>>>  
>>>> - <No qualifying bean of type 
>>>> 'org.springframework.transaction.TransactionManager' available: expected 
>>>> single matching bean but found 2: 
>>>> ticketTransactionManager,transactionManagerEvents 
>>>> DefaultListableBeanFactory.java:resolveNamedBean:1310 
>>>> DefaultListableBeanFactory.java:resolveBean:484 
>>>> DefaultListableBeanFactory.java:getBean:339*
>>>>
>>>> This seems to happen in the last line of 
>>>> BaseAuthenticationRequestRiskCalculator:getCasTicketGrantingTicketCreatedEventsFor().
>>>> When I remove electrofence from gradle file, I get the expected result, 
>>>> which is a "service not allowed" message.
>>>>
>>>> It seemed to me like `@Transactional(readOnly = true)` annotations in 
>>>> JpaCasEventRepository (it's the only place I can
>>>> see this exact form of them) do not cooperate transactionManager 
>>>> parameter from @Transactional at the top of the class.
>>>> Hovewer, adding transactionManager to every @Transactional there 
>>>> doesn't fix the issue, only messages differ:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *2023-11-28 11:26:44,019 WARN 
>>>> [org.apereo.cas.web.flow.resolver.impl.DefaultCasDelegatingWebflowEventResolver]
>>>>  
>>>> - 
>>>> <org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl@21eae802
>>>>  
>>>> is closed AbstractLogicalConnectionImplementor.java:errorIfClosed:37 
>>>> LogicalConnectionManagedImpl.java:getPhysicalConnection:142 
>>>> StatementPreparerImpl.java:connection:542023-11-28 11:26:44,019 WARN 
>>>> [org.apereo.cas.web.flow.resolver.impl.DefaultCasDelegatingWebflowEventResolver]
>>>>  
>>>> - 
>>>> <org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl@21eae802
>>>>  
>>>> is closed AbstractLogicalConnectionImplementor.java:errorIfClosed:37 
>>>> LogicalConnectionManagedImpl.java:getPhysicalConnection:142 
>>>> StatementPreparerImpl.java:connection:54*
>>>>
>>>> What am I doing wrong?
>>>>
>>>> Kind regards,
>>>> Michał Nowakowski
>>>>
>>>> -- 
>>>> - Website: https://apereo.github.io/cas
>>>> - Gitter Chatroom: https://gitter.im/apereo/cas
>>>> - List Guidelines: https://goo.gl/1VRrw7
>>>> - Contributions: https://goo.gl/mh7qDG
>>>> --- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "CAS Community" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to cas-user+u...@apereo.org.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/a/apereo.org/d/msgid/cas-user/6a4a70cc-80fd-4836-beb0-029dd70a2807n%40apereo.org
>>>>  
>>>> <https://groups.google.com/a/apereo.org/d/msgid/cas-user/6a4a70cc-80fd-4836-beb0-029dd70a2807n%40apereo.org?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>> - Website: https://apereo.github.io/cas
>> - Gitter Chatroom: https://gitter.im/apereo/cas
>> - List Guidelines: https://goo.gl/1VRrw7
>> - Contributions: https://goo.gl/mh7qDG
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CAS Community" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to cas-user+u...@apereo.org.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/a/apereo.org/d/msgid/cas-user/677322a1-242e-47d8-ab6e-2921c49448can%40apereo.org
>>  
>> <https://groups.google.com/a/apereo.org/d/msgid/cas-user/677322a1-242e-47d8-ab6e-2921c49448can%40apereo.org?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cas-user+unsubscr...@apereo.org.
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/3d1f6222-9982-4896-a1a7-f8cc172fafcdn%40apereo.org.

<<attachment: stacktrace2.txt.zip>>

Reply via email to