cancel
Showing results for 
Search instead for 
Did you mean: 

registerEmployee

Former Member
0 Kudos

Trying to deploy it and receiving this error message. Can someone help me resolve? Thanks

Error in the remote interface com.sap.demo.EmployeeServices of bean EmployeeServicesBean: No corresponding business method in the bean class com.sap.demo.EmployeeServicesBean was found for method registerEmployee.

Error in the local interface com.sap.demo.EmployeeServicesLocal of bean EmployeeServicesBean: No corresponding business method in the bean class was found for method registerEmployee.

Here is the code:

Bean Class

Bean Class

package com.sap.demo;

import java.util.Collection;

import javax.ejb.CreateException;

import javax.ejb.EJBException;

import javax.ejb.FinderException;

import javax.ejb.SessionBean;

import javax.ejb.SessionContext;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingException;

/**

  • @ejbHome <{com.sap.demo.EmployeeServicesHome}>

  • @ejbLocal <{com.sap.demo.EmployeeServicesLocal}>

  • @ejbLocalHome <{com.sap.demo.EmployeeServicesLocalHome}>

  • @ejbRemote <{com.sap.demo.EmployeeServices}>

  • @stateless

  • @transactionType Container

*/

public class EmployeeServicesBean implements SessionBean {

public void ejbRemove() {

}

public void ejbActivate() {

}

public void ejbPassivate() {

}

private EmployeeLocalHome employeeHome = null;

public void setSessionContext(SessionContext context) {

myContext = context;

try {

Context jndiContext = new InitialContext();

employeeHome =

(EmployeeLocalHome) jndiContext.lookup(

"java:comp/env/ejb/Employee");

} catch (NamingException ex) {

throw new EJBException(ex.getMessage(), ex);

}

}

private SessionContext myContext;

/**

  • Business Method.

*/

public long registerEmployee(

String firstname,

String lastname,

String department) {

long result = 0;

try {

EmployeeLocal employee = employeeHome.create();

employee.setFirstname(firstname);

employee.setLastname(lastname);

employee.setDepartment(department);

result = employee.getId().longValue();

} catch (CreateException ex) {

throw new EJBException(ex.getMessage(), ex);

}

return result;

}

/**

  • Business Method.

*/

public EmployeeDTO[] getAllEmployees() {

EmployeeDTO[] result = new EmployeeDTO[0];

try {

Collection col = employeeHome.findAllEmployees();

Object[] obj = col.toArray();

result = new EmployeeDTO[obj.length];

for (int i = 0; i < obj.length; i++) {

EmployeeLocal employee = (EmployeeLocal) obj<i>;

EmployeeDTO temp = new EmployeeDTO();

temp.setFirstname(employee.getFirstname());

temp.setLastname(employee.getLastname());

temp.setDepartment(employee.getDepartment());

temp.setEmployeeId(employee.getId().longValue());

result<i> = temp;

}

} catch (FinderException ex) {

throw new EJBException(ex.getMessage(), ex);

}

return null;

}

/**

  • Create Method.

*/

public void ejbCreate() throws CreateException {

// TODO : Implement

}

}

Remote Interface

package com.sap.demo;

import javax.ejb.EJBObject;

import java.rmi.RemoteException;

public interface EmployeeServices extends EJBObject {

/**

  • Business Method.

*/

public long registerEmployee(

String firstname,

String lastname,

String department)

throws RemoteException;

/**

  • Business Method.

*/

public EmployeeDTO[] getAllEmployees() throws RemoteException;

}

Home Interface

package com.sap.demo;

import javax.ejb.EJBHome;

import java.rmi.RemoteException;

import javax.ejb.CreateException;

public interface EmployeeServicesHome extends EJBHome {

/**

  • Create Method.

*/

public EmployeeServices create() throws CreateException, RemoteException;

}

Local Interface

package com.sap.demo;

import javax.ejb.EJBLocalObject;

public interface EmployeeServicesLocal extends EJBLocalObject {

/**

  • Business Method.

*/

public Long registerEmployee(

String firstname,

String lastname,

String department);

/**

  • Business Method.

*/

public EmployeeDTO[] getAllEmployees();

}

Local Home interface

package com.sap.demo;

import javax.ejb.EJBLocalHome;

import javax.ejb.CreateException;

public interface EmployeeServicesLocalHome extends EJBLocalHome {

/**

  • Create Method.

*/

public EmployeeServicesLocal create() throws CreateException;

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

In Local Interface, you have declared the method as

public Long registerEmployee(

String firstname,

String lastname,

String department);

But, the return type should be long and not Long.

So change the method declaration in Local Interface as

public long registerEmployee(

String firstname,

String lastname,

String department);

Regards,

Uma

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Is your problem solved? Let us know about the status of your error.

Regards,

Uma