cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Addon bean cannot be extended from

bughunter_af
Explorer
0 Likes
969

Hello everyone

I'm trying to override the B2BAcceleratorAuthenticationProvider, but with no success. I'm getting following error:

 Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanInitializationException: Properties 'bruteForceAttackCounter', 'modelService', 'userDetailsService' and 'userService' are required for bean 'customB2BAcceleratorAuthenticationProvider'

It seems that the child bean doesn't inherited the injected properties of the parent bean.

The OOTB B2BAcceleratorAuthenticationProvider is configured like this:

 <!-- Note: There is no alias defined OOTB! -->
   <bean id="b2bAcceleratorAuthenticationProvider" parent="abstractAcceleratorAuthenticationProvider"
               class="de.hybris.platform.b2bacceleratoraddon.security.B2BAcceleratorAuthenticationProvider">
             <property name="preAuthenticationChecks" ref="b2bRejectUserPreAuthenticationChecks"/>
             <property name="b2bUserGroupProvider" ref="b2bUserGroupProvider"/>
             <aop:scoped-proxy/>
         </bean>

Normally I would expect this configuration to work:

 <alias name="customB2BAcceleratorAuthenticationProvider" alias="b2bAcceleratorAuthenticationProvider" />
         <bean id="customB2BAcceleratorAuthenticationProvider" parent="b2bAcceleratorAuthenticationProvider"
               class="package.CustomB2BAcceleratorAuthenticationProvider">
             <property name="customProperty" ref="customProperty"/>
             <aop:scoped-proxy/>
         </bean>

It sadly doesn't work. Does anyone have an idea why this is the case?

Workarounds I tried that didn't work:

  1. Defining an alias myself.

  2. Defining every property of the parent bean in the child bean.

What worked in the end, was to inherit from the abstractAcceleratorAuthenticationProvider instead. I'm not sure if this is considered safe though:

 <alias name="customB2BAcceleratorAuthenticationProvider" alias="b2bAcceleratorAuthenticationProvider" />
     <bean id="customB2BAcceleratorAuthenticationProvider" parent="abstractAcceleratorAuthenticationProvider"
           class="package.CustomB2BAcceleratorAuthenticationProvider">
         <property name="preAuthenticationChecks" ref="b2bRejectUserPreAuthenticationChecks"/>
         <property name="b2bUserGroupProvider" ref="b2bUserGroupProvider"/>
         <property name="customB2BCustomerAccountService" ref="customB2BCustomerAccountService"/>
         <aop:scoped-proxy/>
     </bean>

Any ideas or suggestions are welcome. Thank you!

Accepted Solutions (1)

Accepted Solutions (1)

arvind-kumar_avinash
Active Contributor
0 Likes

Hi - In the following configuration, customB2BAcceleratorAuthenticationProvider extends b2bAcceleratorAuthenticationProvider and you are trying to make it (the child) parent by using an alias. This will cause a circular reference and therefore it won't work.

 <alias name="customB2BAcceleratorAuthenticationProvider" alias="b2bAcceleratorAuthenticationProvider" />
 <bean id="customB2BAcceleratorAuthenticationProvider" 
         parent="b2bAcceleratorAuthenticationProvider" 
         class="package.CustomB2BAcceleratorAuthenticationProvider">
     <property name="customProperty" ref="customProperty"/>
     <aop:scoped-proxy/>
 </bean>

I hope it is clear. Please let me know if it requires more clarification.

bughunter_af
Explorer
0 Likes

Hello , thanks for your response!

That makes sense and would explain why the child couldn't inherit anything.

Hybris should have used "defaultB2bAcceleratorAuthenticationProvider" for the id instead and defined an alias named "b2bAcceleratorAuthenticationProvider". There seems to be no "right" way to handle the situation.

Options:

  1. Overwrite the bean "b2bAcceleratorAuthenticationProvider" with the drawback that we will have a problem if there are other child beans extending from B2BAcceleratorAuthenticationProvider.

  2. Don't define the alias for "customB2BAcceleratorAuthenticationProvider" with the drawback that "b2bAcceleratorAuthenticationProvider" can still be referenced somewhere.

  3. Use "abstractAcceleratorAuthenticationProvider" as parent even though it should be "b2bAcceleratorAuthenticationProvider". Unpredictable drawbacks.

Cheers

arvind-kumar_avinash
Active Contributor
0 Likes

You are most welcome.

Answers (0)