smitharai

Greenhorn
+ Follow
since Aug 20, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by smitharai

Hi Anup,
Thanks for your response. Would you please mail all the classes and xml files to my yahoo mail address please. My e-mail id is : learner_jsp@yahoo.com
Regards,
Smitha
Hi,
I am trying to generate a JAR file for a container managed persistence Entity Bean (for weblogic 5.1). I am in a strange situation and does not have any clue about the following error. There is no compilation error for the classes I used. I am giving the classes I used for this purpose. Can any one help me out please.............
C:\WINNT\Profiles\Administrator\.ejbdeployer\provider-projects\OrderEJB\ejb-jar\ejb\entityBean\containerManaged\testing\OrderBeanEOImpl.java:56: incompatible types
found : int
required: ejb.entityBean.containerManaged.testing.OrderPK
pk = bean.custid;
^
1 error
The database table used for this application contains three fields namely, cust_id(int), item_code(varchar2), item_quantity(int).

%%%%%%%%%%%%%%%%%%%%%% Home Interface %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
package ejb.entityBean.containerManaged.testing;
import java.rmi.RemoteException;
import java.sql.*;
import java.util.Collection;
import javax.ejb.*;

public interface OrderHome extends EJBHome {
public Order create(int custid, String itemcode, int quantity) throws RemoteException, CreateException;
public Order findByPrimaryKey(OrderPK pk) throws FinderException, RemoteException;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%% Remote Interface %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
package ejb.entityBean.containerManaged.testing;
import java.sql.*;
import java.rmi.RemoteException;
public interface Order extends javax.ejb.EJBObject {
public void setQuantity(int quantity) throws RemoteException;
public int getCustID() throws RemoteException;
public String getItemCode() throws RemoteException;
public int getQuantity() throws RemoteException;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%% Bean Class %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
package ejb.entityBean.containerManaged.testing;
import java.rmi.*;
import javax.ejb.*;
import java.sql.*;
public class OrderBean implements EntityBean {
public int custid;
public String itemcode;
public int quantity;
private boolean isModified = false;
public EntityContext entityContext;
public OrderPK ejbCreate(int custid, String itemcode, int quantity) throws CreateException {

this.custid = custid;
this.itemcode = itemcode;
this.quantity = quantity;

//return new OrderPK(custid);
return null;
}
public void ejbPostCreate(int custid, String itemcode, int quantity) throws CreateException {
}
public void ejbActivate() throws RemoteException {
}
public void ejbLoad() throws RemoteException {
}
public void ejbPassivate() throws RemoteException {
}
public void ejbRemove() throws RemoteException, RemoveException {

}
public void ejbStore() throws RemoteException {
if (isModified())
setModified(false);
}
public void setEntityContext(EntityContext context) throws RemoteException {
entityContext = context;
}
public void unsetEntityContext() throws RemoteException {
entityContext = null;
}
public boolean isModified() {
return this.isModified;
}
private void setModified(boolean modified) {
this.isModified = modified;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public int getCustID() {
return this.custid;
}
public String getItemCode() {
return this.itemcode;
}
public int getQuantity() {
return this.quantity;
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%% Primary Key Class %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
package ejb.entityBean.containerManaged.testing;
import java.sql.*;
public class OrderPK implements java.io.Serializable {
public int custid;
public OrderPK() {
}
public OrderPK(int custid) {
this.custid = custid;
}
public boolean equals(Object obj) {
if (obj==null | | !(obj instanceof OrderPK))
return false;
OrderPK pk = (OrderPK)obj;
if (this.custid != pk.custid)
return false;
return true;
}
public int hashCode() {
StringBuffer strB = new StringBuffer();
strB.append(custid);
return strB.toString().hashCode();
}
public String toString() {
String b = "OrderPK[custid=" + custid ;
return b;
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
------------------
Hi Mahesh,
Thanks for the reply. There is no compile ERROR when I changed the return type for the ejbCreate() method to "return new OrderPK(custid);". But when I tried to generate the JAR file, I am getting the ERROR like "Error in OrderBeanEOImpl.java:56: incompatible types found : int required: ejb.entityBean.containerManaged.testing.OrderPK, pk = bean.custid;
I could not understand this. Please correct my mistake.
Thanks,
Smitha
Hi, I am trying to use CMP for entity bean for a simple database table having three columns, namely, cust_id(int), item_code(varchar2), quantity(int). While I am genetrating the Jar file, I am getting the incompatible ERROR. I could not understand where exactly the error is: My code is as under:
Please help me out.
Smitha
=================================================================
REMOTE INTERFACE
<--------------->
package ejb.entityBean.containerManaged.testing;
import java.sql.*;
import java.rmi.RemoteException;
public interface Order extends javax.ejb.EJBObject {
public void setQuantity(int quantity) throws RemoteException;
public int getCustID() throws RemoteException;
public String getItemCode() throws RemoteException;
public int getQuantity() throws RemoteException;
}
_________________________________________________________________
HOME INTERFACE
<------------->
package ejb.entityBean.containerManaged.testing;
import java.rmi.RemoteException;
import java.sql.*;
import java.util.Collection;
import javax.ejb.*;

public interface OrderHome extends EJBHome {
public Order create(int custid, String itemcode, int quantity) throws RemoteException, CreateException;
public Order findByPrimaryKey(OrderPK pk) throws FinderException, RemoteException;
}
_________________________________________________________________
PRIMARY KEY CLASS
<--------------->
package ejb.entityBean.containerManaged.testing;
import java.sql.*;
public class OrderPK implements java.io.Serializable {
public int custid;
public OrderPK() {
}
public OrderPK(int custid) {
this.custid = custid;;
}
public boolean equals(Object obj) {
if (obj==null | | !(obj instanceof OrderPK))
return false;
OrderPK pk = (OrderPK)obj;
if (this.custid != pk.custid)
return false;
return true;
}
public int hashCode() {
StringBuffer strB = new StringBuffer();
strB.append(custid);
return strB.toString().hashCode();
}
public String toString() {
String b = "OrderPK[custid=" + custid ;
return b;
}
}
_________________________________________________________________
BEAN CLASS
<--------->
package ejb.entityBean.containerManaged.testing;
import java.rmi.*;
import javax.ejb.*;
import java.sql.*;
public class OrderBean implements EntityBean {
private boolean isModified = false;
public EntityContext entityContext;
public int custid;
public String itemcode;
public int quantity;

public OrderPK ejbCreate(int cust_id, String item_code, int quant) throws CreateException {

this.custid = cust_id;
this.itemcode=item_code;
this.quantity=quant;

return null;
}
public void ejbPostCreate(int cust_id, String item_code, int quant) throws CreateException {
}
public void ejbActivate() throws RemoteException {
}
public void ejbLoad() throws RemoteException {
}
public void ejbPassivate() throws RemoteException {
}
public void ejbRemove() throws RemoteException, RemoveException {

}
public void ejbStore() throws RemoteException {
if (isModified())
setModified(false);
}
public void setEntityContext(EntityContext context) throws RemoteException {
entityContext = context;
}
public void unsetEntityContext() throws RemoteException {
entityContext = null;
}
public boolean isModified() {
return this.isModified;
}
private void setModified(boolean modified) {
this.isModified = modified;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public int getCustID() {
return this.custid;
}
public String getItemCode() {
return this.itemcode;
}
public int getQuantity() {
return this.quantity;
}
}
_________________________________________________________________
ejb-jar.xml
<---------->
<?xml version="1.0"?>
< !DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>Order</ejb-name>
<home>ejb.entityBean.containerManaged.testing.OrderHome</home>
<remote>ejb.entityBean.containerManaged.testing.Order</remote>
<ejb-class>ejb.entityBean.containerManaged.testing.OrderBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>ejb.entityBean.containerManaged.testing.OrderPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-field>
<field-name>custid</field-name>
</cmp-field>
<cmp-field>
<field-name>itemcode</field-name>
</cmp-field>
<cmp-field>
<field-name>quantity</field-name>
</cmp-field>
<primkey-field>custid</primkey-field>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>Order</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
_________________________________________________________________
weblogic-cmp-rdbms-jar.xml
<------------------------->
< !DOCTYPE weblogic-rdbms-bean PUBLIC <br /> '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB RDBMS Persistence//EN'<br /> 'http://www.bea.com/servers/wls510/dtd/weblogic-rdbms-persistence.dtd'>
<weblogic-rdbms-bean>
<pool-name>ejbDemoPool</pool-name>
<table-name>orders</table-name>
<attribute-map>
<object-link>
<bean-field>custid</bean-field>
<dbms-column>cust_id</dbms-column>
</object-link>
<object-link>
<bean-field>itemcode</bean-field>
<dbms-column>itemcode</dbms-column>
</object-link>
<object-link>
<bean-field>quantity</bean-field>
<dbms-column>quantity</dbms-column>
</object-link>
</attribute-map>
<finder-list>
<finder>

</finder>
</finder-list>
<options>
<use-quoted-names>false</use-quoted-names>
</options>
</weblogic-rdbms-bean>
_________________________________________________________________
weblogic-ejb-jar
<-------------->
<?xml version="1.0"?>
< !DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB//EN' 'http://www.bea.com/servers/wls510/dtd/weblogic-ejb-jar.dtd'>
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>Order</ejb-name>
<caching-descriptor>
<max-beans-in-cache>1000</max-beans-in-cache>
</caching-descriptor>
<persistence-descriptor>
<is-modified-method-name>isModified</is-modified-method-name>
<persistence-type>
<type-identifier>WebLogic_CMP_RDBMS</type-identifier>
<type-version>5.1.0</type-version>
<type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
</persistence-type>
<persistence-use>
<type-identifier>WebLogic_CMP_RDBMS</type-identifier>
<type-version>5.1.0</type-version>
</persistence-use>
</persistence-descriptor>
<jndi-name>containerManaged.OrderHome</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>

------------------