com.google.inject.ProvisionException:Guice供应错误

时间:2013-09-02 15:01:11

标签: java guice

我写了一个样本课。

package org.openId.appengine;

import com.google.step2.xmlsimplesign.TrustRootsProvider;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.security.cert.X509Certificate;
import java.util.Collection;
import java.util.logging.Logger;

import org.ritesh.SampleGoogleAppServlet;

public class AppEngineTrustsRootProvider implements TrustRootsProvider {

  private static final String CERT_FILE = "cacerts.bin";

  private final Collection<X509Certificate> certs;
  private static final Logger log = Logger.getLogger(SampleGoogleAppServlet.class.getName()); 

  @SuppressWarnings("unchecked")
  public AppEngineTrustsRootProvider() {

    try {
      ObjectInputStream in =
          new ObjectInputStream(AppEngineTrustsRootProvider.class.getResourceAsStream(CERT_FILE));
      log.info("Coming here");
      certs = (Collection<X509Certificate>) in.readObject();
    } catch (IOException e) {
      throw new RuntimeException(e);
    } catch (ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }

  public Collection<X509Certificate> getTrustRoots() {
    return certs;
  }
}

当我在谷歌应用引擎上部署我的项目时,它给了我错误

2013-09-02 07:43:45.852
Uncaught exception from servlet
javax.servlet.UnavailableException: com.google.inject.ProvisionException: Guice provision errors:

1) Error injecting constructor, java.lang.NullPointerException
  at org.openId.appengine.AppEngineTrustsRootProvider.<init>(AppEngineTrustsRootProvider.java:21)
  while locating org.openId.appengine.AppEngineTrustsRootProvider
  while locating com.google.step2.xmlsimplesign.TrustRootsProvider
    for parameter 0 at com.google.step2.xmlsimplesign.CachedCertPathValidator.<init>(CachedCertPathValidator.java:61)
  while locating com.google.step2.xmlsimplesign.CachedCertPathValidator
    for parameter 0 at com.google.step2.xmlsimplesign.Verifier.<init>(Verifier.java:51)
  while locating com.google.step2.xmlsimplesign.Verifier
    for parameter 1 at com.google.step2.discovery.LegacyXrdsResolver.<init>(LegacyXrdsResolver.java:91)
  while locating com.google.step2.discovery.LegacyXrdsResolver
  while locating com.google.step2.discovery.XrdDiscoveryResolver
    for parameter 1 at com.google.step2.discovery.Discovery2.<init>(Discovery2.java:167)
  while locating com.google.step2.discovery.Discovery2
    for parameter 1 at com.google.step2.ConsumerHelper.<init>(ConsumerHelper.java:60)
  while locating com.google.step2.ConsumerHelper

1 error
    at org.mortbay.jetty.servlet.ServletHolder.makeUnavailable(ServletHolder.java:415)
    at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:458)
    at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    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:35)
    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:266)
    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:76)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:439)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:435)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:442)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:186)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:306)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:298)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:439)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:722)

为什么我面临此错误以及如何删除它。我在我的编码目录中添加了cacert.bin文件,该文件位于AppEngineTrustsRootProvider.java所在的同一个包中。任何人都可以帮助我为什么我面临这个错误以及如何删除它。

编辑:我没有从jar文件中获取目录列表的含义,关于哪个jar你正在谈论但是发布了一个截图,显示了我在eclipse中的项目目录结构 enter image description here

0 个答案:

没有答案