2 Replies Latest reply on Nov 3, 2003 7:12 AM by julian_hu

    How to use RowSet in Session Bean to get data for mysql?

    julian_hu Newbie

      made a Session Bean. In this session bean i used CachedRowSet to return some data from database.
      I succeeded deploying it to jboss 3.2.1. But when i used my client to call the session bean,the jboss gave a ClassNotFoundException. it told me class sun.jdbc.rowset.CachedRowSet is not found. I have already copied rowset.jar to server/all/lib/. How can I resolve this problem. Thanks a lot.

      there are Exception message

      java.lang.NoClassDefFoundError: sun/jdbc/rowset/CachedRowSet
      at com.Intelliprise.Test2.EJB.GetDataBean.doGetData(GetDataBean.java:49)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionConta
      iner.java:629)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionI
      nterceptor.java:186)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstance
      Interceptor.java:72)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.
      java:122)
      at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322
      )
      at org.jboss.ejb.Container.invoke(Container.java:674)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284
      )
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:359)
      at java.lang.reflect.Method.invoke(Native Method)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:236)
      at sun.rmi.transport.Transport$1.run(Transport.java:147)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:143)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:479)

      there is my remote method
      public RowSet doGetData(String sql){
      Connection conn=null;
      ResultSet rs;
      CachedRowSet crs;
      CachedRowSet result;
      try{
      Hashtable env=new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
      //env.put("java.naming.factory.url.pkgs","org.jboss.naming rg.jnp.interfaces");
      InitialContext jndiCntx = new InitialContext(env);

      DataSource ds=(DataSource)jndiCntx.lookup("java:/MySqlDS");

      conn=ds.getConnection();

      Statement st=conn.createStatement();

      rs=st.executeQuery("Select * from sm_opuser");
      crs=new CachedRowSet();
      crs.populate(rs);
      crs.setTableName(sql);
      rs.close();
      st.close();
      result=crs;


      }catch(Exception e){
      e.printStackTrace();
      result=null;
      }
      return result;
      }