2
votes

There's a project to upgrade Java, weblogic and as it eventually turned out spring in one of our web apps. Used to be java 6, weblogic 10 and spring 3. Moving to java 8, weblogic 12 and spring 5.

After a lot of dependency hell at compile time and having to refactor around some depreciated spring classes I've got it to build.

And this when the real issues started.

When deploying the app I'm getting the following exception.

<02-Apr-2019 10:14:56,294 o'clock IST> <[ACTIVE] ExecuteThread: '92' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <> <37efec1d-3b6b-481e-a623-5c66ebd12f27-0000005d> <1554196496294> <[severity-value: 16] [rid: 0] [partition-id: 0] [partition-name: DOMAIN] > ' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=healthPlanCheckoutFunnelStateHolderMapper)}.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'findAPlanCheckoutController': Unsatisfied dependency expressed through field 'funnelStateHolderMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.vhi.web.common.mappers.FunnelStateHolderMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=healthPlanCheckoutFunnelStateHolderMapper)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1395) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:400) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103) at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:705) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326) at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197) at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203) at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71) at weblogic.servlet.internal.EventsManager.executeContextListener(EventsManager.java:251) at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:204) at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:189) at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1921) at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3101) at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1843) at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:884) at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360) at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:356) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45) at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138) at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45) at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:78) at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:52) at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:752) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45) at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:262) at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:66) at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165) at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:90) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:631) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:171) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:121) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:348) at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:907) at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1468) at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:459) at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:181) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:217) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:14) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:69) at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:678) at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:352) at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:337) at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:57) at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41) at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:652) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:420) at weblogic.work.ExecuteThread.run(ExecuteThread.java:360) Caused By: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.vhi.web.common.mappers.FunnelStateHolderMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=healthPlanCheckoutFunnelStateHolderMapper)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1654) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1213) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1167) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1395) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:849) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:400) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103) at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:705) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326) at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197) at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203) at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71) at weblogic.servlet.internal.EventsManager.executeContextListener(EventsManager.java:251) at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:204) at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:189) at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1921) at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3101) at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1843) at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:884) at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360) at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:356) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45) at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138) at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45) at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:78) at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:52) at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:752) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45) at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:262) at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:66) at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165) at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:90) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:631) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:171) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:121) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:348) at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:907) at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1468) at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:459) at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:181) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:217) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:14) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:69) at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:678) at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:352) at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:337) at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:57) at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41) at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:652) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:420) at weblogic.work.ExecuteThread.run(ExecuteThread.java:360)

The component is:

@Component
@Qualifier("healthPlanCheckoutFunnelStateHolderMapper")
public class HealthPlanCheckoutFunnelStateHolderMapper extends CommonHealthCheckoutFunnelStateHolderMapper<HealthPlanCheckoutBean>
{
    @Override
    protected HealthPlanCheckoutBean createBean() {
        return new HealthPlanCheckoutBean();
    }
}

and the autowiring of that component is:

@Autowired
@Qualifier("healthPlanCheckoutFunnelStateHolderMapper")
private FunnelStateHolderMapper<HealthPlanCheckoutBean, HealthPlanFunnelStateHolder> funnelStateHolderMapper;

The FunnelStateHolderMapper interface

/**
 * Interface defines methods for mapping to and from a {@link FunnelStateHolder}. This is the top level mapper that
 * should be used by each controller for handling GET and POST requests. The implementation may delegate to other
 * underlying mappers but this should always be the interface to which the controller talks.
 */
public interface FunnelStateHolderMapper<B, F extends FunnelStateHolder> {

    B toScreenBean(F funnelStateHolder);

    F fromScreenBean(F funnelStateHolder, B screenBean);
}

There is a component-scan in the configuration that includes the package that this code is in.

This worked fine with spring 3 but since changing to spring 5 this issue is occurring. I suppose its possible that some refactoring I had to do to get it to compile has caused this issue but I don't think so. None of the files that the above code is in have been updated.

I haven't had to update any of the spring config either up to now. Is there a difference in how spring 3 and spring 5 search for components?

1
Try removing @Qualifier("healthPlanCheckoutFunnelStateHolderMapper") from HealthPlanCheckoutFunnelStateHolderMapper class.Abhijeet

1 Answers

0
votes

The field

private FunnelStateHolderMapper<...> funnelStateHolderMapper;

isn't of the same type of the @Component/@Qualifier annotated class

HealthPlanCheckoutFunnelStateHolderMapper

You cannot expect Spring to @Autowire something that would throw a compile/runtime error.


If HealthPlanCheckoutFunnelStateHolderMapper is part of a hierarchy, please show that.