I think I had ClassCastExceptions back when I first started with these pools
and datasource lookups and the first fix I found was to use the Minerva
specific class, but I just changed my code to this and it works fine:
public class UPRBean implements SessionBean
{
transient DataSource ds = null;
public void aMethod()
{
InitialContext jndiContext = new InitialContext();
ds = (DataSource) jndiContext.lookup("java:/OracleDS");
}
}
of course, as Toby said:
> Also, you should use java:comp/env/ lookups
----- Original Message -----
From: "Dovan Nguyen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 15, 2001 3:53 PM
Subject: Re: [JBoss-user] RE: Error 'closing' a pooled connection (addendum)
> > > 2) *** CONNECTION CREATION
> > > InitialContext jndiContext = new InitialContext();
> > > XAPoolDataSource ds = (XAPoolDataSource)
> > > jndiContext.lookup("java:/OracleDS");
> > > Connection conn = ds.getConnection();
> >
> > Don't reference Minerva classes in your code. Just use
javax.sql.DataSource.
>
> If you don't reference to Minerva class, could you tell us what is the
alternative to
> cast the objref in PortableRemoteObject.narrow( objref, ? ) method ?
>
> dovan
>
>
> >
> >
> > Also, you should use java:comp/env/ lookups, but that's not relevent
here.
> >
> > > 3) *** static methods for closing rs/conn/stmt ( I will place the
entire
> > > class here -- sorry if the readability is a little bad, tried to
crunch it
> > > all in )
> > > import java.sql.*;
> > > public class DatabaseUtility {
> >
> > Looks fine.
> >
> > > 4) *** RMI ServerException Stack Trace ( this is thrown and the
connection
> > > is NOT returned to the pool )
> > > This is thrown when I try to call DatabaseUtility.closeConnection(
> > > connection ); (notice I catch _everything_ in that method) and is
_not_
> > > thrown in the DatabaseUtility, but seems like it is thrown on the
attempt to
> > > call the method.
> > > java.rmi.ServerException: Transaction rolled
> > > back:com/bebee/recommender/utility/DatabaseUtility
> > > at
org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:300)
> >
> > Ok, you're missing out some details. Are you calling an EJB from a
servlet?
> >
> > You haven't mentioned anything about what this EJB is doing. What are
you
> > doing with transactions? Are you getting the connection in the servlet
> > and trying to close it from the EJB or something?
> >
> > > 5) *** NullPointerException stack trace (sorry for the log format)
this is
> > > thrown on the preparedStatement.close() call inside the bean at the
end of
> > > the transaction (which is directly after the call to
connection.close() --
> > > when I change the order of the calls, i.e. first close the prepared
> > > statement then close the connection it works fine)
> >
> > This is a bug. I'll look at this kind of fragility at some point.
> >
> > Toby.
> >
> > _______________________________________________
> > JBoss-user mailing list
> > [EMAIL PROTECTED]
> > http://lists.sourceforge.net/lists/listinfo/jboss-user
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user