Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 1st, 2006, 05:19 AM
c3008212 c3008212 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 4 c3008212 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #2  
Old March 1st, 2006, 06:40 AM
wsa1971's Avatar
wsa1971 wsa1971 is offline
AYBABTU
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Here or There
Posts: 1,256 wsa1971 User rank is Major (30000 - 40000 Reputation Level)wsa1971 User rank is Major (30000 - 40000 Reputation Level)wsa1971 User rank is Major (30000 - 40000 Reputation Level)wsa1971 User rank is Major (30000 - 40000 Reputation Level)wsa1971 User rank is Major (30000 - 40000 Reputation Level)wsa1971 User rank is Major (30000 - 40000 Reputation Level)wsa1971 User rank is Major (30000 - 40000 Reputation Level)wsa1971 User rank is Major (30000 - 40000 Reputation Level)wsa1971 User rank is Major (30000 - 40000 Reputation Level)wsa1971 User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 35206 Folding Title: Starter FolderFolding Points: 35206 Folding Title: Starter Folder
Time spent in forums: 1 Month 2 Days 1 h 4 m
Reputation Power: 374
The addItem() method in your bean takes a String as argument and you're trying to pass an Integer.
Comments on this post
Annie79 agrees!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > JSP session bean call error

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap