NoClassDefFoundError: com/couchbase/client/java/error/TemporaryFailureException

huangapple go评论75阅读模式
英文:

NoClassDefFoundError: com/couchbase/client/java/error/TemporaryFailureException

问题

我使用的是 OpenJDK 11.0.5 版本的 Java 和 Couchbase Java 客户端版本为 2.6.0。当我通过主类调用时,它能正常工作,但是当我通过我的 API 调用时,它会抛出 NoClassDefFoundError 错误。完整的堆栈跟踪如下:

我只是从另一个 JAR 文件中调用了一个方法,没有任何修改。这个 JAR 文件单独运行时也能正常工作。我已经将我的代码与主分支进行了比对,没有任何更改。

我尝试将 Couchbase 客户端版本升级到最新的 3.x.x 版本,但是没有成功。请问有谁能够提供一些建议,我漏掉了什么吗?

java.lang.ClassNotFoundException: com.couchbase.client.java.error.TemporaryFailureException
在 java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) 中
在 java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) 中
在 java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) 中
在 com.tomtom.places.optimus.datastore.config.DataStoreConfiguration.getDefaultRetriableExceptions(DataStoreConfiguration.java:22) 中
在 com.tomtom.places.optimus.datastore.config.DataStoreConfiguration.<init>(DataStoreConfiguration.java:45) 中
在 com.tomtom.places.sourcing.readers.service.MDSReaderService.readMDSData(MDSReaderService.java:49) 中
在 com.tomtom.places.sourcing.readers.service.MDSReaderService$$FastClassBySpringCGLIB$$ce5a4062.invoke(<generated>) 中
在 org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) 中
在 org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) 中
在 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) 中
在 org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) 中
在 org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) 中
在 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) 中
在 org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) 中
在 org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) 中
在 com.tomtom.places.sourcing.readers.service.MDSReaderService$$EnhancerBySpringCGLIB$$b337e7bc.readMDSData(<generated>) 中
在 com.tomtom.places.sep.service.MdsRefreshService.refreshCountry(MdsRefreshService.java:47) 中
在 com.tomtom.places.sep.controller.MdsRefreshController.refreshCountry(MdsRefreshController.java:25) 中
在 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 中
在 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 中
在 java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 中
在 java.base/java.lang.reflect.Method.invoke(Method.java:566) 中
在 org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) 中
在 org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) 中
在 org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) 中
在 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879) 中
在 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) 中
在 org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) 中
在 org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) 中
在 org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) 中
在 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) 中
在 org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) 中
在 javax.servlet.http.HttpServlet.service(HttpServlet.java:634) 中
在 org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) 中
在 javax.servlet.http.HttpServlet.service(HttpServlet.java:741) 中
在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 中
在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 中
在 org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) 中
在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 中
在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 中
在 com.tomtom.places.sep.filter.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:77) 中
在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 中
在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 中
在 org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) 中
在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) 中
在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 中
在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 中
在 org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) 中
在 org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) 中
在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 中
在 org.apache.catalina
<details>
<summary>英文:</summary>
I am using OpenJDK 11.0.5 java version and couchbase java client version 2.6.0. It works when called through a main class but when I am hitting through my api, it throws NoClassDefFoundError. Full stack trace below : 
I am just calling a method from another jar, no modifications whatsoever. The jar works well separately. I checked my code against the master branch, no changes in that. 
I tried upgrading the couchbase client version to latest 3.x.x but in vain. Can anyone please suggest what I am missing?
```12:41:35.931 [http-nio-8080-exec-3] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/couchbase/client/java/error/TemporaryFailureException] with root cause
java.lang.ClassNotFoundException: com.couchbase.client.java.error.TemporaryFailureException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at com.tomtom.places.optimus.datastore.config.DataStoreConfiguration.getDefaultRetriableExceptions(DataStoreConfiguration.java:22)
at com.tomtom.places.optimus.datastore.config.DataStoreConfiguration.&lt;init&gt;(DataStoreConfiguration.java:45)
at com.tomtom.places.sourcing.readers.service.MDSReaderService.readMDSData(MDSReaderService.java:49)
at com.tomtom.places.sourcing.readers.service.MDSReaderService$$FastClassBySpringCGLIB$$ce5a4062.invoke(&lt;generated&gt;)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
at com.tomtom.places.sourcing.readers.service.MDSReaderService$$EnhancerBySpringCGLIB$$b337e7bc.readMDSData(&lt;generated&gt;)
at com.tomtom.places.sep.service.MdsRefreshService.refreshCountry(MdsRefreshService.java:47)
at com.tomtom.places.sep.controller.MdsRefreshController.refreshCountry(MdsRefreshController.java:25)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.tomtom.places.sep.filter.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)```
</details>
# 答案1
**得分**: 4
解决了。问题是由于多个版本的couchbase java-client引起的。主应用程序使用了一个版本,而jar包使用了另一个版本。统一了所有的java-client版本,问题得以解决。我使用了2.6.0作为java-client的版本。
<details>
<summary>英文:</summary>
Solved it. The problem was due to multiple versions of couchbase java-client. The main application has one version and the jar has other. Made all the java-client versions consistent and it worked. I used 2.6.0 as the java-client version.
</details>

huangapple
  • 本文由 发表于 2020年8月26日 16:15:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/63593394.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定