Java Firebase错误“NoClassDefFoundError:org / apache / http / conn / ssl / StrictHostnameVerifier”

时间:2016-01-27 18:27:43

标签: java google-app-engine servlets firebase

我有一个非常简单的servlet程序在谷歌应用程序引擎上正常运行。现在,当我添加firebase对象以进行子值更新调用时,它会在appengine和本地apache tomcat上显示服务器错误500,它也会显示一些错误。 这是我的代码

package com.example.appengine.helloworld;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.firebase.client.Firebase;
import com.firebase.client.FirebaseException;

@SuppressWarnings("serial")
public class HelloServlet extends HttpServlet {

  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException,FirebaseException  {


    PrintWriter out = resp.getWriter();
    out.println("Hello, world");
    Firebase fire = new Firebase("https://fiery-fire-0.firebaseio.com/");
    fire.child("hello").setValue("Nothing is in here");   
  }
}

这是在apache tomcat上运行它时的错误

    Exception in thread "TubeSockReader-1" java.lang.NoClassDefFoundError: org/apache/http/conn/ssl/StrictHostnameVerifier
    at com.firebase.tubesock.WebSocket.verifyHost(WebSocket.java:287)
    at com.firebase.tubesock.WebSocket.createSocket(WebSocket.java:271)
    at com.firebase.tubesock.WebSocket.runReader(WebSocket.java:306)
    at com.firebase.tubesock.WebSocket.access$000(WebSocket.java:30)
    at com.firebase.tubesock.WebSocket$2.run(WebSocket.java:108)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.ssl.StrictHostnameVerifier
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1854)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1703)
    ... 6 more

在谷歌应用引擎上运行它只是说

Error: Server Error

The server encountered an error and could not complete your request.
Please try again in 30 seconds.

请帮帮我!

1 个答案:

答案 0 :(得分:2)

看起来您的http客户端库的版本没有(现已弃用)类StrictHostnameVerifier。

https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/ssl/StrictHostnameVerifier.html

尝试手动包括httpclient 4.0.1而不是“latest”(尽管它应该根据文档显示在4.5.1中)。