我正在将我的spring项目从版本4.3.23升级到版本5.2.13
我在项目的ldap.xml文件中有以下代码,在4.3.23中运行良好,但在5.2.13中出错:
<bean id="contextSourceReadTarget" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="urls" value="ldap://localhost:12345" />
<property name="base" value="dc=memorynotfound,dc=com" />
<property name="userDn" value="uid=admin" />
<property name="password" value="secret" />
<property name="dirObjectFactory"
value="org.springframework.ldap.core.support.DefaultDirObjectFactory" />
<property name="pooled" value="false" />
<property name="referral" value="follow" />
</bean>
但是当我运行代码时 java.lang.NoClassDefFoundError: org/springframework/core/JdkVersion
在搜索之后,我发现jdkversion在Spring5.x中被删除了
我想知道如何修复我的代码,使之在Spring5.x上正常工作。
以下是错误的完整堆栈跟踪:
java.lang.NoClassDefFoundError: org/springframework/core/JdkVersion
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1799)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:719)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:344)
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:1929)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3191)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1864)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:919)
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.BasicDeployment.activate(BasicDeployment.java:274)
at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:507)
at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:53)
at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:202)
at weblogic.management.deploy.internal.AppTransition$2.transitionAppInternal(AppTransition.java:53)
at weblogic.management.deploy.internal.AppTransition.transitionApp(AppTransition.java:138)
at weblogic.management.deploy.internal.ConfiguredDeployments$2.doItem(ConfiguredDeployments.java:741)
at weblogic.management.deploy.internal.parallel.BucketInvoker$2.run(BucketInvoker.java:95)
at weblogic.work.ContextWrap.run(ContextWrap.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:681)
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:655)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:420)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:360)
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/JdkVersion
at org.springframework.ldap.core.support.AbstractContextSource.getJdkVersion(AbstractContextSource.java:485)
at org.springframework.ldap.core.support.AbstractContextSource.afterPropertiesSet(AbstractContextSource.java:342)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1858)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1795)
... 57 more
提前谢谢!
2条答案
按热度按时间r3i60tvu1#
我假设您没有使用springboot,我们讨论的是“纯spring”应用程序。
很明显,spring框架中试图使用丢失类的代码属于spring4生态系统(否则任何依赖spring5并使用ldap集成的应用程序都会失败,spring团队也会在这方面有一个主要的bug)
假设没有重大的bug,那么应用程序的类路径中肯定有一些spring4jar
所以我建议做以下几点:
检查类路径。因为我假设,你正在编译一个war-用winrar或者别的什么打开工件,看看它的内容
WEB-INF/lib
文件夹。如果你看到了属于Spring4的东西-修复你的pom.xml
具有正确的依赖关系。如果你编译ear-它可能有许多模块需要检查,但基本上过程是相同的,我相信你已经明白了要点weblogic在某些共享文件夹中可能有一些“共享”jar(包括spring)。我对这个应用服务器不是很熟悉,但这些jar很可能属于spring4生态系统,它们可能在运行时“找到”应用程序的类路径。Maven显然不会表现出来。
7xllpg7q2#
您应该一起更新所有spring依赖项(在本例中是springldap),检查是否所有spring依赖项都更新到spring5,因为spring是一个非常模块化的框架,所以定义一个关于其模块版本管理的变量总是很有帮助的