ClassCastException Problem


EJB programming & troubleshooting: ClassCastException Problem

  1. ClassCastException Problem (2 messages)

    I have a question on Entity Beans. I have two entity beans StudentEJB and CourseEJB which implement a M:N relationship. The beans implement local interfaces. StudentEJB has a method
    called getCoursesOfStudent() which returns as the list of courses a student is
    involved in as an ArrayList. The code snippet is as follows:

     public ArrayList getCoursesOfStudent() {

            ArrayList courseList = new ArrayList();
            Collection courses = getCourses();

            Iterator i = courses.iterator();
            while (i.hasNext()) {
                LocalCourse courselocal = (LocalCourse);
                String course_name = courselocal.getCourseName();
                courseList.add( course_name );

            return courseList;

    when i try to save the ear file containing StudentEJB and CourseEJB i get the following error

    ERROR: [DeployToolWindow.saveAction:1049]
    java.lang.ClassCastException: com.sun.enterprise.deployment.EjbExternalDescriptor
    java.lang.ClassCastException: com.sun.enterprise.deployment.EjbExternalDescriptor
            at com.sun.enterprise.deployment.EjbReferenceDescriptor.getValue(

    Is this something to do with ArrayList data structure that i return

    Could some please help me with this regard


  2. ClassCastException Problem[ Go to top ]

  3. From ur code it seems method getCourses() as a private method in studentEJB it returning collection of objects from coursesEJB.whether this CourseEJB local bean.i think problem arise in getting objects.