2 Replies Latest reply on Aug 28, 2003 6:58 AM by shanker

    Pl help me I am not able to view the table using findAll BMP

    shanker

      Hi, I am new to jboss and EJB. I am not able to view the records using find all. Please help me. Thanks in advance. I have marked problematic line. Thanks again.

      This is the error I am getting (class cast exception)
      Error
      18:48:11,656 INFO [Engine] StandardWrapper[/ums:default]: Loading container ser
      vlet default
      18:48:11,718 INFO [Engine] StandardWrapper[/ums:invoker]: Loading container ser
      vlet invoker
      18:48:11,812 INFO [MainDeployer] Deployed package: file:/G:/uma/jboss/jboss-3.2
      .0_tomcat-4.1.24/server/default/deploy/output.ear
      18:48:27,890 INFO [STDOUT] lookup success Employee
      18:48:27,906 ERROR [STDERR] java.lang.ClassCastException
      18:48:27,906 ERROR [STDERR] at org.apache.jsp.EmployeeView_jsp._jspService(E
      mployeeView_jsp.java:76)
      18:48:27,906 ERROR [STDERR] at org.apache.jasper.runtime.HttpJspBase.service
      (HttpJspBase.java:137)
      18:48:27,906 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpSe
      rvlet.java:853)
      18:48:27,906 ERROR [STDERR] at org.apache.jasper.servlet.JspServletWrapper.s
      ervice(JspServletWrapper.java:210)
      18:48:27,906 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.serviceJ
      spFile(JspServlet.java:295)
      18:48:27,906 ERROR [STDERR] at org.apache.jasper.servlet.JspServlet.service(
      JspServlet.java:241)
      18:48:27,906 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpSe
      rvlet.java:853)

      This is my Bean code

      public Collection ejbFindAll() throws FinderException
      {
      Connection con = null;
      PreparedStatement ps = null;
      ResultSet result = null;
      ArrayList objectList = new ArrayList();
      Integer employeeId;
      try
      {
      con = this.getConnection();
      ps = con.prepareStatement("select * from Employee "); result = ps.executeQuery();

      while(result.next())
      {
      employeeId = (Integer) result.getObject("employeeId");
      objectList.add(employeeId);
      }
      return objectList;
      }
      catch(SQLException se)
      {
      throw new EJBException(se);
      }
      finally
      {
      try
      {
      if(result != null) result.close();
      if(ps != null) ps.close();
      if(con != null) con.close();
      }
      catch(SQLException se)
      {
      se.printStackTrace();
      }
      }
      }

      }


      My jsp is below.

      <%@ page import="java.sql.Date,java.io.*,java.sql.*,javax.naming.InitialContext,
      javax.naming.Context,java.util.Properties, javax.rmi.PortableRemoteObject, java.text.SimpleDateFormat,javax.ejb.EJBHome,
      java.util.Collection, java.util.*, com.ami.amihr.EmployeeHomeLocal, com.ami.amihr.EmployeeLocal,
      com.ami.amihr.EmployeeVO;" %>



      <h2 align='center'> Employee Details </h2>
      <%
      EmployeeHomeLocal localHome;
      EmployeeLocal employeeLocal;
      try
      {
      Object object;
      Context jndiContext = new InitialContext();
      localHome = (EmployeeHomeLocal) jndiContext.lookup("java:comp/env/ejb/EmployeeHomeLocal");
      System.out.println("lookup success Employee");
      Collection tempEmployeeValueObjects;
      try
      {
      tempEmployeeValueObjects = localHome.findAll();
      Iterator iterator=tempEmployeeValueObjects.iterator();
      while(iterator.hasNext())
      {
      THIS Line has problem->Integer tempEmployeeId= (Integer) iterator.next();
      try
      {
      employeeLocal = localHome.findByPrimaryKey(tempEmployeeId);
      System.out.println (
      "employeeId" + employeeLocal.getEmployeeId() +
      "employeeFirstName" + employeeLocal.getEmployeeFirstName() +
      "employeeLastName" + employeeLocal.getEmployeeLastName() +
      "employeeEmailId" + employeeLocal.getEmployeeEmailId() +
      "dateOfJoining" + employeeLocal.getDateOfJoining() +
      "dateOfBirth" + employeeLocal.getDateOfBirth() +
      "isEmployeeNow" + employeeLocal.getIsEmployeeNow() +
      "isPermanent" + employeeLocal.getIsPermanent() +
      "isOnContract" + employeeLocal.getIsOnContract() +
      "isOnProbation" + employeeLocal.getIsOnProbation());
      }
      catch(javax.ejb.FinderException fe)
      {
      fe.printStackTrace();
      }
      }
      }
      catch(javax.ejb.FinderException fe)
      {
      fe.printStackTrace();
      System.out.println("Object not found for view");
      }
      }
      catch (Exception e)
      {
      e.printStackTrace();
      System.out.println("unable to get handle for Employee");
      }
      %>




      Please help me Thanks again.