Note that there are some explanatory texts on larger screens.

plurals
  1. POEclipse: Thrift inside Tomcat Servlet, ClassNotFoundException TException
    primarykey
    data
    text
    <p>I'm trying to make a Java servlet that can make Apache Thrift calls, but I'm having trouble starting the servlet.</p> <p>I have a <strong>thrift client</strong>, a Java class for making calls to the thrift server</p> <pre><code>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); } </code></pre> <p>and I have a <strong>java servlet</strong> which opens a socket through the thrift client</p> <pre><code>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(); </code></pre> <p>However, when I try to run this servlet (using eclipse and a tomcat server), I get an error like </p> <pre><code>SEVERE: A child container failed during start </code></pre> <p>and a <code>ClassNotFoundException</code> for <code>org.apache.thrift.TException</code></p> <p><strong>EDIT: All I had to do was include the thrift jars into the Tomcat Server's classpath. See my answer below</strong></p> <p>I have used the thrift client already without any ClassNotFoundExceptions, and the servlet works on its own as well. However, once I add <code>ThriftClient.openSocket();</code> into the servlet, it breaks, so I have a feeling Thrift and Tomcat are clashing somehow. Any ideas?</p> <p>Edit: The weird part is that I never call the method <code>startThrift()</code> but I still get the error.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload