• Post Reply Bookmark Topic Watch Topic
  • New Topic

Erron on DataSource in EJB 2.1 with Weblogic 9.2 sever

 
Megan James
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some problem in BMP- EJB 2.1 ...

code for CutomerBean
=================
private Connection getConnection() throws NamingException, SQLException {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource)ic.lookup("java:comp/env/jdbc/SimpleDB");
// DataSource ds = (DataSource)ic.lookup("Customer");
return ds.getConnection();
}

ejb-jar.xml
=======
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>Customer</ejb-name>
<home>sjdavies.ejb.bmp.CustomerHome</home>
<remote>sjdavies.ejb.bmp.Customer</remote>
<ejb-class>sjdavies.ejb.bmp.CustomerBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>False</reentrant>
<resource-ref>
<description>Declare the reference to the DataSource.</description>
<res-ref-name>jdbc/SimpleDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Customer</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>

weblogic-ejb-jar.xml
=============
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>Customer</ejb-name>
<reference-descriptor>
<resource-description>
<res-ref-name>jdbc/SimpleDB</res-ref-name>
<jndi-name>SimpleDB</jndi-name>
</resource-description>
</reference-descriptor>
<jndi-name>SimpleDB</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>


index.jsp
======
CustomerHome cHome;
InitialContext ctx = new InitialContext();
Object objref=ctx.lookup("SimpleDB");
cHome = (CustomerHome) PortableRemoteObject.narrow(objref, CustomerHome.class);
cust = cHome.create(s);



Error:
====
java.lang.ClassCastException: sjdavies.ejb.bmp.Customer_7og5ho_HomeImpl
at sjdavies.ejb.bmp.CustomerBean.getConnection(CustomerBean.java:47)
at sjdavies.ejb.bmp.CustomerBean.ejbCreate(CustomerBean.java:73)
at sjdavies.ejb.bmp.Customer_7og5ho_Impl.ejbCreate(Customer_7og5ho_Impl.
java:285)
at sjdavies.ejb.bmp.CustomerBean.ejbCreate(CustomerBean.java:58)
at sjdavies.ejb.bmp.Customer_7og5ho_Impl.ejbCreate(Customer_7og5ho_Impl.
java:263)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at weblogic.ejb.container.manager.ExclusiveEntityManager.create(Exclusiv
eEntityManager.java:775)
at weblogic.ejb.container.manager.ExclusiveEntityManager.remoteCreate(Ex
clusiveEntityManager.java:746)
at weblogic.ejb.container.internal.EntityEJBHome.create(EntityEJBHome.ja



I got the error in the CutomerBean.java.can any one tell me how to solve this error.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!