Can anybody please take a look at following code and help me to figure out
what are we doing wrong?

We are using Entity Beans with container managed persistence. To speed up
our application and get around the default implementation of finders which
returns always full set of beans instead of user defined "page size", we
want our session beans go directly against database to retrieve primary keys
and the let app server retrieve individual beans using findByPrimaryKey.

Recently we ported our server to Jonas 2.0 and we are having problems to
retrieve DataSource

Our base class session bean tries to resolve DataSource in ejbCreate

   /**
    * Method required by EJB.
    */
   public void ejbCreate(
   ) throws RemoteException, CreateException
   {
      Context ctcContext = null;

      try
      {
         ctcContext  = new InitialContext();

         // Lookup data source for this bean
         Object obj = ctcContext.lookup("java:comp/env/jdbc/AQPDataSource");
         System.out.println("Looked up object " + obj);
         System.out.println("Class " + obj.getClass());
         m_dsDataSource = (DataSource)obj;
      }
      catch(NamingException neExc)
      {
          throw new RemoteException("JDNI error. Original message: "
                                    +  neExc.getMessage(),
                                    neExc);
      }
      finally
      {
         try
         {
            if (ctcContext != null)
            {
               ctcContext.close();
            }
         }
         catch(NamingException neExc)
         {
            neExc.printStackTrace();
         }
      }
   }

The DDs looks like this

<!DOCTYPE ejb-jar SYSTEM "ejb-jar_1_1.dtd">
<ejb-jar>
   <enterprise-beans>
      <session>
         <description>Deployment descriptor for
aqp.beans.user.UserController bean</description>
         <ejb-name>aqp.beans.user.UserController</ejb-name>
         <home>aqp.beans.user.UserControllerHome</home>
         <remote>aqp.beans.user.UserController</remote>
         <ejb-class>aqp.beans.user.UserControllerBean</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>
         <resource-ref>
            <res-ref-name>jdbc/AQPDataSource</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
         </resource-ref>
      </session>
   </enterprise-beans>
   <assembly-descriptor>
      <container-transaction>
         <method>
            <ejb-name>aqp.beans.user.UserController</ejb-name>
            <method-name>*</method-name>
         </method>
         <trans-attribute>Required</trans-attribute>
      </container-transaction>
   </assembly-descriptor>
</ejb-jar>

<!DOCTYPE jonas-ejb-jar SYSTEM "jonas-ejb-jar.dtd">
<jonas-ejb-jar>
   <jonas-session>
      <ejb-name>aqp.beans.user.UserController</ejb-name>
      <jndi-name>aqp.beans.user.UserController</jndi-name>
      <jonas-resource>
         <res-ref-name>jdbc/AQPDataSource</res-ref-name>
         <jndi-name>aqpjdbc</jndi-name>
       </jonas-resource>
   </jonas-session>
</jonas-ejb-jar>

When we run this, we get ClassCastException

Looked up object org.objectweb.jonas.jtm.Current@7ba64c90
Class class org.objectweb.jonas.jtm.Current
System Exception in create or finder method:java.lang.ClassCastException:
org.jectweb.jonas.jtm.Current
java.rmi.RemoteException: RuntimeException thrown by an enterprise Bean;
nesteexception is:
        java.lang.ClassCastException: org.objectweb.jonas.jtm.Current
java.lang.ClassCastException: org.objectweb.jonas.jtm.Current
        at
aqp.beans.core.CoreDocumentStatelessControllerBean.ejbCreate(CoreDomentState
lessControllerBean.java:88)
        at
aqp.beans.user.JOnASUserControllerBeanUserControllerHome.create(JOnUserContr
ollerBeanUserControllerHome.java:42)
        at
aqp.servlets.session.LoginServlet.getController(LoginServlet.java:4)
        at
aqp.servlets.session.LoginServlet.verifyLogin(LoginServlet.java:358
        at
aqp.servlets.session.SessionServlet.service(SessionServlet.java:169
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
        at
com.mortbay.HTTP.Handler.ServletHolder.service(ServletHolder.java,mpiled
Code)
        at
com.mortbay.HTTP.Handler.ServletHandler.handle(ServletHandler.java:4)
        at com.mortbay.HTTP.HttpServer.handle(HttpServer.java, Compiled
Code)
        at com.mortbay.HTTP.HttpListener.handleConnection(HttpListener.java,
Cpiled Code)
        at com.mortbay.Util.ThreadedServer.run(ThreadedServer.java, Compiled
Ce)
        at java.lang.Thread.run(Thread.java:479)

It looks like the datasource was resolved to instance of
org.objectweb.jonas.jtm.Current which doesn't implement DataSource
interface. 

Does anybody have idea what is wrong with this code? Any help is greatly
appreciated.

Miroslav Halas
Software Engineer
Compuware Corp.
15305 Dallas Parkway
Suite 900
Addison, TX 75001
phone 9720-960-0960 x 1333
fax 972-960-8489

----
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