Hi,
I want to print a table using a
JSP page. I am using a DAO from a session bean to access the table and send the ResultSet back to the bean.
This is the code of the DAO interface:
public interface DataEJBDAO
{
public void init();
public java.sql.ResultSet giveResults() ;
}
This is the code of my stateless Bean:
public abstract class DataEJBBean implements SessionBean {
protected SessionContext ctx;
/**
* @ejb.interface-method
*view-type="remote"
* @dao.call name="giveResults"
**/
public java.sql.ResultSet giveResults(){
System.out.println("Entering DataEJBBean.giveResults");
System.out.println("Exiting DataEJBBean.giveResults");
return null;
}
public void setSessionContext(javax.ejb.SessionContext ctx)
{
this.ctx=ctx;
}
public void unsetSessionContext()
{
this.ctx=null;
}
}
And this is the Implementation of the DAO Interface:
public class DataEJBDAOImpl implements DataEJBDAO{
private DataSource jdbcFactory;
public void init(){
System.out.println("Entering DataEJBDAOImpl.init()");
InitialContext c=null;
if(this.jdbcFactory==null){
try{
c=new InitialContext();
this.jdbcFactory=(DataSource)c.lookup("java:comp/env/jdbc/OracleDS");
}catch(Exception e){
System.out.println("Error in DataEJBDAOImpl.init()");
System.out.println(e);
}
}
System.out.println("Leaving DataEJBDAOImpl.init()");
}
public java.sql.ResultSet giveResults()
{
Connection con=null;
PreparedStatement ps=null;
ResultSet rs=null;
try{
con=jdbcFactory.getConnection();
String query="select employeeName from employeePersonelDetails";
ps=con.prepareStatement(query);
rs=ps.executeQuery();
}catch(SQLException e){
e.printStackTrace();
System.out.println("Inside DataEJBDAOImpl.giveResults()"+e);
}
finally{
try{
rs.close();
ps.close();
con.close();
}catch(Exception e){
}
System.out.println("Leaving DataEJBDAOImpl.giveResults()");
return(rs);
}
}
}
But I am getting this error:
java.lang.reflect.UndeclaredThrowableException
at $Proxy1.giveResults(Unknown Source)
at myDAO.client.DAOClient.testBean(DAOClient.java:48)
at myDAO.client.DAOClient.main(DAOClient.java:67)
Caused by: java.io.NotSerializableException: oracle.jdbc.driver.OracleResultSetImpl
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
at java.rmi.MarshalledObject.<init>(MarshalledObject.java:92)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:363)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
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:534)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:135)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:87)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
... 3 more
Exception in
thread "main"
I am using
JBoss 3.2.1
Can anyone please help me.
Thanks,
IJ