
March 1st, 2006, 05:19 AM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 4
Time spent in forums: 12 m
Reputation Power: 0
|
|
|
JSP session bean call error
Hi,
I am new to developing in J2EE and I am currently using JDeveloper 10g to create a shopping cart. I am having problems calling the addItem method from my JSP page. I receive the following error message:
Error(18,10): method addItem(java.lang.Integer) not found in interface businessLayer.cartBean
This is my session bean:
Code:
package businessLayer;
import businessLayer.ItemException;
import java.util.Vector;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class cartBeanBean implements SessionBean
{
private SessionContext context;
Vector contents;
public void ejbCreate()
{
Vector contents = new Vector();
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}
public void ejbRemove()
{
}
public void setSessionContext(SessionContext ctx)
{
this.context = ctx;
}
public void addItem(String itemID)
{
contents.add(itemID);
}
public void removeItem(Integer itemID) throws ItemException
{
boolean result = contents.remove(itemID);
if (result == false)
throw new ItemException("Item with the ID of "+itemID+" is not on the list");
}
public Vector getContents()
{
return contents;
}
}
This is part of my JSP page:
Code:
<%@ page import="java.util.Vector, javax.naming.*, javax.rmi.*, businessLayer.cartBeanHome, businessLayer.cartBean"%>
<%!
//declare a "global" reference to an instance of the home interface of the session bean
public void jspInit() {
//obtain an instance of the home interface
try {
InitialContext ic = new InitialContext();
Object objRef = ic.lookup("cartBean");
cartBeanHome home = (cartBeanHome)PortableRemoteObject.narrow(objRef,cartBeanHome.class);
cartBean cart = home.create();
int one = 1;
Integer oneI = new Integer(one);
cart.addItem(oneI);
}
catch (Exception ex){
System.err.println("Caught an unexpected exception: " + ex.getMessage());
System.exit(1);
}
}
%>
Thank you for your time. Any help would be most grateful.
|