Hi,
Has any body tried ejbSelectMethods on Weblogic
6.1.
I always get the ClassCastException when I try to
cast the LocateRemote return from the collection.
Here is the section of
ejb-jar.xml file which declares the ejbSelect method
<entity>
<ejb-name>CutomerEJB-one2many</ejb-name>
<local-home>examples.relations.one_many.CustomerHome1</local-home>
<local>examples.relations.one_many.Customer1</local>
<ejb-class>examples.relations.one_many.CustomerBean1</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>CustBean</abstract-schema-name>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<field-name>id</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
<!-- Select methods -->
<query>
<query-method>
<method-name>ejbSelectAboveGivenID</method-name>
<method-params>
<method-param>int</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(a) FROM CustBean AS a WHERE a.id > ?1]]>
</ejb-ql>
</query>
<ejb-name>CutomerEJB-one2many</ejb-name>
<local-home>examples.relations.one_many.CustomerHome1</local-home>
<local>examples.relations.one_many.Customer1</local>
<ejb-class>examples.relations.one_many.CustomerBean1</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>CustBean</abstract-schema-name>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<field-name>id</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
<!-- Select methods -->
<query>
<query-method>
<method-name>ejbSelectAboveGivenID</method-name>
<method-params>
<method-param>int</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(a) FROM CustBean AS a WHERE a.id > ?1]]>
</ejb-ql>
</query>
</entity>
below is the declaration of this fn
in the bean class
public abstract Collection
ejbSelectAboveGivenID(int id) throws javax.ejb.FinderException;
Here is the bean
code(CustomerBean1.java) where I am executing it.
CustomerHome1
h=(CustomerHome1)ctx.getEJBLocalHome();
Collection cust=ejbSelectAboveGivenID(1);
System.out.println("Records ="+ cust.size()); // Correctly prints the no of records returned
Iterator it=cust.iterator();
while(it.hasNext() )
{
examples.relations.one_many.Customer1 c=(examples.relations.one_many.Customer1)it.next(); // here comes the exception
Collection cust=ejbSelectAboveGivenID(1);
System.out.println("Records ="+ cust.size()); // Correctly prints the no of records returned
Iterator it=cust.iterator();
while(it.hasNext() )
{
examples.relations.one_many.Customer1 c=(examples.relations.one_many.Customer1)it.next(); // here comes the exception
System.out.println("CustomerBean>>"+c.GetCustomerDetails());
}
}
Exception coming at the red line. Any Idea
why ??
TIA
Ashwani
