Apache Thrift 呼び出しを行うことができる Java サーブレットを作成しようとしていますが、サーブレットの起動に問題があります。
中古サーバーを呼び出すためのJavaクラスである中古クライアントがあります
public class ThriftClient {
static TTransport transport;
static TProtocol protocol;
static MyService.Client client;
static long xtk_pointer;
public static void openSocket() throws TException {
transport = new TSocket("localhost", 9090);
transport.open();
protocol = new TBinaryProtocol(transport);
client = new MyService.Client(protocol);
}
リサイクルクライアントを介してソケットを開くJavaサーブレットがあります
public class MyServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
out.println("Hello World");
}
void startThrift(String [] args) {
try {
ThriftClient.openSocket();
ただし、このサーブレットを (Eclipse と Tomcat サーバーを使用して) 実行しようとすると、次のようなエラーが発生します。
SEVERE: A child container failed during start
とClassNotFoundException
_org.apache.thrift.TException
編集: 私がしなければならなかったのは、thrift jar を Tomcat サーバーのクラスパスに含めることだけでした。以下の私の答えを見てください
私は既に ClassNotFoundExceptions なしで thrift クライアントを使用しており、サーブレットも単独で動作します。ただ、サーブレットに追加ThriftClient.openSocket();
すると壊れてしまうので、ThriftとTomcatがなんとなくぶつかり合っているような気がします。何か案は?
編集:奇妙な部分は、メソッドを呼び出すことはありませんが、startThrift()
それでもエラーが発生することです。