How to implemen commons.digester in Servlet


Web tier: servlets, JSP, Web frameworks: How to implemen commons.digester in Servlet

  1. i am using Commons.Digester in java application with main().
    It works fine.
    but when i use commons.Digester in Servlet (because i need to send XML document as parameter to Servlet),
    It throws an error of
    Begin event threw exception
    java.lang.ClassNotFoundException: No ClassLoaders found for"

    i properly installed jar file.(It works in application).

    I have taken example from
    with modified XML document of

    <?xml version='1.0'?>
    <name>Java Boy</name>
    <name>Java Girl</name>
  2. hai
    i included digester jar files in Project using Eclipse.
    It works fine in Java Application with main();
    but when i implement within servlet t displays the error of

    java.lang.ClassNotFoundException: No ClassLoaders is thrown for java classes for CStudents,CStudent class needed for Parent & Child node.

    I am giving all Java files (All are in same web module) .

    Class files are:

    1) 2) 3)
    the xml file is send as reader object.

    public class CStudents {
        //dept variable for dept property
        private String dept;
        //private variable for child node student
        private CStudent student;
        // get & set method for dept property
        public String getDept()
            return dept;
        public void setDept(String dept)
            this.dept = dept;
        //get&set method for Child node property
        public CStudent getStudent()
            return student;
        public void setStudent(CStudent student)
            this.student = student;

    public class CStudent {
        //define two variable equivalent to no of properties to Student Node(child)
        private String name="";
        private String course="";
        //get & set method for Name property
        public String getName()
            return name;
        public void setName(String name)
   = name;
    // get & set method for Course property
        public String getCourse()
            return course;
        public void setCourse(String course)
            this.course = course;

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.commons.digester.Digester;
    public class StudentParserNew extends HttpServlet {
        protected void doGet(HttpServletRequest request,
                HttpServletResponse response) throws ServletException, IOException {
                Digester digester = new Digester();
     digester.setValidating( false );
                digester.addSetNext( "students/student","setStudent");
                 Reader reader = new StringReader(
                        "<?xml version='1.0'?><students><student><name>Java Boy</name><course>JSP</course>"+
                 "</student><dept>E-Learning</dept><student><name>Java Girl</name><course>EJB</course></student>"+
                CStudents cstudents = (CStudents)digester.parse( reader );
                System.out.println("Result is "+cstudents.toString() );
             catch( Exception exc )
  3. Looks to me like a classpath issue. Are you sure your servlet container has the jar file in it's classloader's classpath?

  4. I finally zeroed the error point

    the above line is throwing error.

    how to create class object in webmodule.
    I am placing all class files in webmodule using Eclipse in JBoss.

    I am not placing java/class files in web-inf dir .

    when i get classloader for class file it returns as


    please help me to know how to load classes in web module?

    thank you