缺少引用的库,ClassDefNotFound错误

时间:2016-03-11 08:53:07

标签: java google-app-engine

您好)最近我将我的应用程序部署到GAE并且在执行应用程序时遇到错误: ClassDefNotFound和ExceptionInInitializer错误 第一个错误引用了一行

  AdWordsServices services = new AdWordsServices();

完整堆栈跟踪:

    java.lang.ExceptionInInitializerError
    at com.akolchin.mfroiapp.server.dispatch.ga.GetGaCampaignsHandler.fillCampaigns(GetGaCampaignsHandler.java:81)
    at com.akolchin.mfroiapp.server.dispatch.ga.GetGaCampaignsHandler.execute(GetGaCampaignsHandler.java:65)
    at com.akolchin.mfroiapp.server.dispatch.ga.GetGaCampaignsHandler.execute(GetGaCampaignsHandler.java:1)
    at com.gwtplatform.dispatch.rpc.server.AbstractDispatchImpl.doExecute(AbstractDispatchImpl.java:154)
    at com.gwtplatform.dispatch.rpc.server.AbstractDispatchImpl.execute(AbstractDispatchImpl.java:110)
    at com.gwtplatform.dispatch.rpc.server.AbstractDispatchServiceImpl.execute(AbstractDispatchServiceImpl.java:87)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:44)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:587)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:333)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:303)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:373)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:263)
    at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:178)
    at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91)
    at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:62)
    at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
    at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
    at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
    at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
    at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:256)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
    ... 1 more
Caused by: com.google.inject.CreationException: Guice creation errors:

1) Multibinder is not initialized
  at com.google.api.ads.adwords.jaxws.AdWordsJaxWsModule.configure(AdWordsJaxWsModule.java:40)
  while locating java.util.Set<java.util.Map$Entry<com.google.api.ads.adwords.lib.client.AdWordsServiceDescriptor$AdWordsSubProduct, com.google.inject.Provider<com.google.api.ads.common.lib.client.HeaderHandler<com.google.api.ads.adwords.lib.client.AdWordsSession, com.google.api.ads.adwords.lib.client.AdWordsServiceDescriptor>>>>
  at com.google.inject.multibindings.MapBinder$RealMapBinder$RealProviderMapProvider.initialize(MapBinder.java:461)
  at com.google.api.ads.adwords.jaxws.AdWordsJaxWsModule.configure(AdWordsJaxWsModule.java:40)

2) Multibinder is not initialized
  at com.google.api.ads.adwords.jaxws.AdWordsJaxWsModule.configure(AdWordsJaxWsModule.java:50)
  while locating java.util.Set<java.util.Map$Entry<com.google.api.ads.adwords.lib.client.AdWordsServiceDescriptor$AdWordsSubProduct, com.google.inject.Provider<java.lang.String>>>
  at com.google.inject.multibindings.MapBinder$RealMapBinder$RealProviderMapProvider.initialize(MapBinder.java:461)
  at com.google.api.ads.adwords.jaxws.AdWordsJaxWsModule.configure(AdWordsJaxWsModule.java:50)

3) Error injecting method, java.lang.NoSuchMethodError: com.google.inject.spi.ProviderInstanceBinding.getUserSuppliedProvider()Ljavax/inject/Provider;
  at com.google.inject.multibindings.Multibinder$RealMultibinder.initialize(Multibinder.java:324)
  at com.google.api.ads.adwords.jaxws.AdWordsJaxWsModule.configure(AdWordsJaxWsModule.java:50)
  while locating java.util.Set<java.util.Map$Entry<com.google.api.ads.adwords.lib.client.AdWordsServiceDescriptor$AdWordsSubProduct, com.google.inject.Provider<java.lang.String>>>
  at com.google.inject.multibindings.MapBinder$RealMapBinder$RealProviderMapProvider.initialize(MapBinder.java:461)
  at com.google.api.ads.adwords.jaxws.AdWordsJaxWsModule.configure(AdWordsJaxWsModule.java:50)
Caused by: java.lang.NoSuchMethodError: com.google.inject.spi.ProviderInstanceBinding.getUserSuppliedProvider()Ljavax/inject/Provider;
    at com.google.inject.multibindings.Indexer.visit(Indexer.java:139)
    at com.google.inject.multibindings.Indexer.visit(Indexer.java:43)
    at com.google.inject.internal.ProviderInstanceBindingImpl.acceptTargetVisitor(ProviderInstanceBindingImpl.java:62)
    at com.google.inject.multibindings.Multibinder$RealMultibinder.initialize(Multibinder.java:332)
    at com.google.inject.multibindings.Multibinder$RealMultibinder$$FastClassByGuice$$94efefc8.invoke(<generated>)
    at com.google.inject.internal.cglib.reflect.$FastMethod.invoke(FastMethod.java:53)
    at com.google.inject.internal.SingleMethodInjector$1.invoke(SingleMethodInjector.java:56)
    at com.google.inject.internal.SingleMethodInjector.inject(SingleMethodInjector.java:90)
    at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110)
    at com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:75)
    at com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:73)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
    at com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:73)
    at com.google.inject.internal.Initializer$InjectableReference.get(Initializer.java:147)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
    at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
    at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)
    at com.google.inject.spi.ProviderLookup$1.get(ProviderLookup.java:89)
    at com.google.inject.multibindings.MapBinder$RealMapBinder$RealProviderMapProvider.initialize(MapBinder.java:469)
    at com.google.inject.multibindings.MapBinder$RealMapBinder$RealProviderMapProvider$$FastClassByGuice$$7fff4848.invoke(<generated>)
    at com.google.inject.internal.cglib.reflect.$FastMethod.invoke(FastMethod.java:53)
    at com.google.inject.internal.SingleMethodInjector$1.invoke(SingleMethodInjector.java:56)
    at com.google.inject.internal.SingleMethodInjector.inject(SingleMethodInjector.java:90)
    at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110)
    at com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:75)
    at com.google.inject.internal.MembersInjectorImpl$1.call(MembersInjectorImpl.java:73)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
    at com.google.inject.internal.MembersInjectorImpl.injectAndNotify(MembersInjectorImpl.java:73)
    at com.google.inject.internal.Initializer$InjectableReference.get(Initializer.java:147)
    at com.google.inject.internal.Initializer.injectAll(Initializer.java:92)
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:173)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:109)
    at com.google.inject.Guice.createInjector(Guice.java:95)
    at com.google.inject.Guice.createInjector(Guice.java:72)
    at com.google.inject.Guice.createInjector(Guice.java:62)
    at com.google.api.ads.adwords.jaxws.factory.AdWordsServices.<clinit>(AdWordsServices.java:44)
    at com.akolchin.mfroiapp.server.dispatch.ga.GetGaCampaignsHandler.fillCampaigns(GetGaCampaignsHandler.java:81)
    at com.akolchin.mfroiapp.server.dispatch.ga.GetGaCampaignsHandler.execute(GetGaCampaignsHandler.java:65)
    at com.akolchin.mfroiapp.server.dispatch.ga.GetGaCampaignsHandler.execute(GetGaCampaignsHandler.java:1)
    at com.gwtplatform.dispatch.rpc.server.AbstractDispatchImpl.doExecute(AbstractDispatchImpl.java:154)
    at com.gwtplatform.dispatch.rpc.server.AbstractDispatchImpl.execute(AbstractDispatchImpl.java:110)
    at com.gwtplatform.dispatch.rpc.server.AbstractDispatchServiceImpl.execute(AbstractDispatchServiceImpl.java:87)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_$1.run(Method_.java:171)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.privilegedInvoke(Method_.java:167)
    at com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.invoke_(Method_.java:125)
    at com.google.apphosting.runtime.security.shared.intercept.java.lang.reflect.Method_.invoke(Method_.java:44)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:587)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:333)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:303)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:373)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

java.lang.NoClassDefFoundError: Could not initialize class com.google.api.ads.adwords.jaxws.factory.AdWordsServices
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:415)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:605)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:333)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:303)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:373)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:263)
at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:178)
at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:62)
at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:37)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:260)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:78)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:148)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:468)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:256)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:235)
at java.lang.Thread.run(Thread.java:745)

并在构造函数内部发生。本地所有工作正常但不适用于部署的版本。

我认为原因是部署版本缺少引用的libs部分... 我想GAE会根据Java EE标准自动获取war / WEB-INF / lib文件夹中的所有库。

这是我用来显示类路径的代码的和平......

URL[] urls = ((URLClassLoader) (Thread.currentThread().getContextClassLoader())).getURLs();
 for(URL url : urls)
 res+= url.toString() + "\n";

如果您知道显示类路径的最佳方式..请告诉我plz) 那么......你的想法是什么?我需要做什么?

2 个答案:

答案 0 :(得分:0)

您需要将缺少的jar添加到war / WEB-INF / lib文件夹中。请注意,将jar添加到构建路径是不够的 - 它将使应用程序在本地运行,但您仍然必须将其复制到该文件夹​​。

如果您使用Eclipse,请选择您的项目并查看“问题”选项卡。您可能会看到一个警告,即构建路径中的jar将无法在服务器上使用。右键单击此警告,选择“快速修复”,然后选择“复制...”选项。

注意:您不需要类路径。如果类路径中缺少某些内容,则您的应用程序将无法编译,并且根本无法运行 - 无论是本地还是其他方式。

答案 1 :(得分:0)

ClassDefNotFound在无法找到或已加载的类时发生 - 在您的情况下,此类或其依赖的类中的某些静态初始化可能会失败。

查看实际导致任何静态字段或块的异常的类 - 其中一个可能由于沙箱环境而失败。

完整堆栈跟踪应该显示导致异常的行。如果我不得不猜测,这个类使用工厂或管理器来访问文件系统或打开套接字或具有类似限制的东西。