From: "Pierre Lupien" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
Subject: Problem with Jonas, loosing database connection
Date: Thu, 8 Jun 2000 11:09:33 -0400

I have a problem with Jonas...

    I have a stateful session bean usign a database connection to get data
for the client apps.  I can deploy the bean and start the server, everything
works for a while.  I access the bean from a client program and it works
perfectly. BUT, after 15-30 minutes (wheter or not I use the bean), I get
the following exception:

javax.naming.CommunicationException.  Root exception is
java.rmi.NoSuchObjectException: no such object in table
        at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Compiled
Code)
        at sun.rmi.transport.StreamRemoteCall.executeCall(Compiled Code)
        at sun.rmi.server.UnicastRef.invoke(Compiled Code)
        at
com.sun.jndi.rmi.registry.ReferenceWrapper_Stub.getReference(Compiled Code)
        at com.sun.jndi.rmi.registry.RegistryContext.decodeObject(Compiled
Code)        at com.sun.jndi.rmi.registry.RegistryContext.lookup(Compiled
Code)
        at com.sun.jndi.rmi.registry.RegistryContext.lookup(Compiled Code)
        at javax.naming.InitialContext.lookup(Compiled Code)
        at org.objectweb.jonas.naming.CompNamingContext.lookup(Compiled
Code)
        at org.objectweb.jonas.naming.CompNamingContext.lookup(Compiled
Code)
        at lup.ejbtest.ejb.InfoServerEJB.serverInit(Compiled Code)
        at lup.ejbtest.ejb.InfoServerEJB.ejbCreate(Compiled Code)
        at lup.ejbtest.ejb.JOnASInfoServerEJBInfoServerHome.create(Compiled
Code)
        at
lup.ejbtest.ejb.JOnASInfoServerEJBInfoServerHome_Skel.dispatch(Compiled
Code)
        at sun.rmi.server.UnicastServerRef.oldDispatch(Compiled Code)
        at sun.rmi.server.UnicastServerRef.dispatch(Compiled Code)
        at sun.rmi.transport.Transport$1.run(Compiled Code)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Compiled Code)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(Compiled Code)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Compiled
Code)
        at java.lang.Thread.run(Compiled Code)

Here is the code in my ejbCreate() method which throws the exception:

        Context     ctx = null;
        Context     env = null;

        try
        {
            ctx = new InitialContext();
            env = (Context)ctx.lookup("java:comp/env");
        }
        catch (Exception e)
        {
            throw new CreateException("Error creating bean: [" + e + "]");
        }

        // ---[ Get datasource ]---
        try
        {
            this.datassource = (DataSource)env.lookup("jdbc/LupDB");
<<<<<<****** Throws the exception after a while
        }
        catch (Exception e)
        {
            e.printStackTrace();
            throw new CreateException("Error: Cannot get the datasource: ["
+ e + "]");
        }
        ....

Here is the method which uses the database connection (no exception thrown
from this, I just put it there in case I do something wrong in it):

        Connection        conn = null;
        PreparedStatement ps = null;
        ResultSet         rs = null;
        String            sName = null;
        String            sDesc = null;

        try
        {
            conn = this.datasource.getConnection();
            ps = conn.prepareStatement("SELECT NAME FROM EMPLOYEES WHERE ID
= ?");
            ps.setInt(1, empId);

            rs = ps.executeQuery();

            if (rs.next())
            {
                sName = rs.getString("NAME");
            } else {
                sName = "Employee [" + empId + "] does not exists.";
            }
        }
        catch (SQLException e)
        {
            sName = "Error accessing database";
        }
        finally
        {
                try{rs.close();}catch(Exception e){}
                try{ps.close();}catch(Exception e){}
                try{conn.close();} catch(Exception e){}
        }
        ...

I am usign Jonas 2.0 w/ JDK1.2.2 on Linux.
I tried with Oracle 8.1.6 and PostgreSQL 7.0.1 and I get the same results.

Any idea on what could be wrong?

Thank you in advance for you help.
==================
Pierre Lupien
[EMAIL PROTECTED]
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to