wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Prolem in EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Prolem in EJB" Watch "Prolem in EJB" New topic
Author

Prolem in EJB

Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Hi all,
Am facing some probs while creating a jar file using weblogic5.1.

Here's my entire code
Remote Interface---
===========================================================================
package emp;
import java.rmi.*;
import javax.ejb.*;
public interface empRemote extends EJBObject {
public int getEmpno() throws RemoteException;
public double getSal() throws RemoteException;
public void setSal(double sal) throws RemoteException;
}
============================================================================
Home interface--
===========================================================================
package emp;
import java.rmi.*;
import javax.ejb.*;
import java.util.*;
public interface empHome extends EJBHome {
public empRemote create(int empno) throws RemoteException, CreateException;
public empRemote findByPrimaryKey(empPK primaryKey) throws RemoteException, FinderException;
public Enumeration findBigSal(double sal) throws RemoteException, FinderException;
}
==============================================================================
Bean class
============================================================================
package emp;
import java.rmi.*;
import javax.ejb.*;
public class empBean implements EntityBean {
EntityContext entityContext;
public int empno;
public double sal;
public empPK ejbCreate(int empno) throws CreateException {
this.empno = empno;
return new empPK(empno);
}
public void ejbPostCreate(int empno) throws CreateException {
}
public void ejbRemove() throws RemoveException {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void ejbLoad() {
}
public void ejbStore() {
}
public void setEntityContext(EntityContext entityContext) {
this.entityContext = entityContext;
}
public void unsetEntityContext() {
entityContext = null;
}
public int getEmpno()
{
return empno;
}
public double getSal()
{
return sal;
}
public void setSal(double sal)
{
this.sal = sal;
}

}
============================================================================
PK class
==========================================================================
package emp;
import java.io.*;
public class empPK implements Serializable {
public int empno;
public empPK() {
}
public empPK(int key) {
empno = key;
}
public boolean equals(Object obj) {
if (obj==null | | !(obj instanceof empPK))
return false;
else if (((empPK)obj).empno == empno)
return true;
else
return false;
}
public int hashCode() {
return empno;
}
public String toString()
{
return String.valueOf(empno);
}
}
=============================================================================
So pl tell me where am wrong( this is a CMP bean)
Waiting for your reply



[This message has been edited by Mary, Cole (edited March 07, 2001).]
Saran Vel
Ranch Hand

Joined: Nov 03, 2000
Posts: 111
Hi,
It's better if u say the error u getting.. but still u can check the following things..
#. U haven't declared any business methods, which can be accessed by clients, in the remote interface..
like getEmpno() getSal() setSal(double sal)..
# The ejbCreate method shud return null..
HTH
Saran


Saran
Sun Certified Java2 Programmer
Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Hi saran,
Am sorry that I haven't included the business methods in my remote interface.
Am getting this error in weblogic deployer tool on the messages tab
================================================================
Compiler failed executable.exec([Ljava.lang.String;[D:/JBuilder4/jdk1.3/bin/javac.exe, -classpath, F:\jdk1.3\jre\lib\rt.jar;F:\jdk1.3\jre\lib\i18n.jar;F:\jdk1.3\jre\lib\sunrsasign.jar;F:\jdk1.3\jre\classes;G:/weblogic/classes;G:/weblogic/license;G:/weblogic/lib/weblogicaux.jar;G :/weblogic/myserver/serverclasses;;G:\weblogic\emp\emp.jar;G:\weblogic\lib\persistence\WebLogic_RDBMS.jar;E:\WINNT\Profiles\Administrator\.ejbdeployer\deployer-projects\Emp\ejb-jar ;;E:\WINNT\Profiles\Administrator\.ejbdeployer\deployer-projects\emp\ejb-jar;;E:\WINNT\Profiles\Administrator\.ejbdeployer\deployer-projects\emp\ejb-jar, -d, E:\WINNT\Profiles\Administrator\.ejbdeployer\deployer-projects\emp\ejb-jar, E:\WINNT\Profiles\Administrator\.ejbdeployer\deployer-projects\emp\ejb-jar\emp\empBeanHomeImpl.java, E:\WINNT\Profiles\Administrator\.ejbdeployer\deployer-projects\emp\ejb-jar\emp\empBeanEOImpl.java, E:\WINNT\Profiles\Administrator\.ejbdeployer\deployer-projects\emp\ejb-jar\emp\empPS.java])
===============================================================
and in the other tab( console tab) of the deployer tool, it says
==============================================================
E:\WINNT\Profiles\Administrator\.ejbdeployer\deployer-projects\emp\ejb-jar\emp\empBeanEOImpl.java:56: incompatible types
found : int
required: emp.empPK
pk = bean.empno;
^
1 error
===============================================================
I tried it by returning null in the ejbCreate method of the bean, but got the same error.
Pl tell me where am going wrong.
Saran Vel
Ranch Hand

Joined: Nov 03, 2000
Posts: 111
Hi,
In u'r ejb-jar.xml remove the <primkey-field> declaration..and
have only <prim-key-class> delaration.
Hope this Helps..
Saran
Saran Vel
Ranch Hand

Joined: Nov 03, 2000
Posts: 111
Oops.. where the xml tags have gone..!!!???
Ok.. remove the primkey-field definition from ejb-jar.xml
have only the prim-key-class definition..
Hope now i got it right..!!
Saran
Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Hi Saran,

Thanx for your advice.I got it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Prolem in EJB
 
Similar Threads
Container Managed Persistence PROBLEM for Entity Bean
Strange Behavior of Hibernate - NOT RESPONDING
BMP question,Help me!
Fetch Exception In Entity Bean
resin-cmp error "Unknown Source" - what does this mean????