Hi


I have implemented TServlet for the java sample given the Thrift
website).



But I am getting the below exception when I call from client:



java.lang.InstantiationException: com.cts.course.thrift.CourseServlet

      at java.lang.Class.newInstance0(Unknown Source)

      at java.lang.Class.newInstance(Unknown Source)

      at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.jav
a:1104)

      at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:8
06)

      at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:129)

      at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:175)

      at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:128)

      at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:102)

      at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:109)

      at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:2
86)

      at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:84
4)

      at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
Http11Protocol.java:583)

      at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

      at java.lang.Thread.run(Unknown Source)





Source Code:



package com.cts.course.thrift;



import java.util.List;



import org.apache.thrift.TException;

import org.apache.thrift.TProcessor;

import org.apache.thrift.protocol.TBinaryProtocol;

import org.apache.thrift.protocol.TProtocolFactory;

import org.apache.thrift.server.TServlet;



import com.cts.course.thrift.gen.Course;

import com.cts.course.thrift.gen.CourseNotFound;

import com.cts.course.thrift.gen.CourseService;

import com.cts.course.thrift.gen.UnacceptableCourse;

import com.ociweb.jnb.db.Database;



public class CourseServlet extends TServlet {



      /**

      *

       */

      private static final long serialVersionUID =
-6700299292172345870L;



      public CourseServlet(TProcessor processor,

                  TProtocolFactory inProtocolFactory,

                  TProtocolFactory outProtocolFactory) {



            super(new CourseService.Processor(new CourseHandler()),

                        new TBinaryProtocol.Factory(), new
TBinaryProtocol.Factory());

      }



      public CourseServlet(TProcessor processor, TProtocolFactory
protocolFactory) {

            super(new CourseService.Processor(new CourseHandler()),

                        new TBinaryProtocol.Factory());

      }



      public static class CourseHandler implements CourseService.Iface {

            public Database db = new Database();



            @Override

            public List<String> getCourseInventory() throws TException {

                  return db.getCourseList();

            }



            @Override

            public Course getCourse(String courseNumber) throws
CourseNotFound,

                        TException {

                  final com.ociweb.jnb.db.Course dbCourse = db

                              .getCourse(courseNumber);

                  if (dbCourse != null) {

                        return ConversionHelper.fromDbCourse(dbCourse);

                  }



                  return null;

            }



            @Override

            public void addCourse(Course course) throws
UnacceptableCourse,

                        TException {

                  com.ociweb.jnb.db.Course dbCourse = ConversionHelper

                              .toDbCourse(course);

                  db.addCourse(dbCourse);

            }



            @Override

            public void deleteCourse(String courseNumber) throws
CourseNotFound,

                        TException {

                  if (db.getCourse(courseNumber) != null) {

                        db.deleteCourse(courseNumber);

                  }

            }

      }



}





Thanks and Regards

Prabakaran.N

Architect - Technology, GTO - SOA CoE

Cognizant Technology Solutions, BTP, Bangalore

Mobile:+91-9739386923; Vnet: 58157; Direct: +91-80-30748157




This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply 
e-mail and destroy all copies of the original message.
Any unauthorized review, use, disclosure, dissemination, forwarding, printing 
or copying of this email or any action taken in reliance on this e-mail is 
strictly prohibited and may be unlawful.

Reply via email to