Meaningless Drivel is fun!
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Need Help  while running  stateless session bean with Servelet bean client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Need Help  while running  stateless session bean with Servelet bean client" Watch "Need Help  while running  stateless session bean with Servelet bean client" New topic

Need Help while running stateless session bean with Servelet bean client

rachna jain
Ranch Hand

Joined: Jul 14, 2009
Posts: 76
Hi All

I have made one EJB project and one Dynamic web project in eclipse IDE on JBOSS.

I have run stateless sesison bean code with normal java class client.

But now i am using servelet as a client.

Please let me know what i am missing as after i deployed project having bean and run servelet on server it says can not find servelet

Stateless bean
package ejb3inaction.example.buslogic;

import javax.ejb.Stateless;
import ejb3inaction.example.persistence.Bid;
* Session Bean implementation class PlaceBidBean
public class PlaceBidBean implements PlaceBidBeanLocal {

* Default constructor.
public PlaceBidBean() {
// TODO Auto-generated constructor stub

public Bid addBid(Bid bid) {
// TODO Auto-generated method stub
System.out.println("Adding bid, bidder ID=" +
+ ", item ID=" + bid.getItemID() + ","
+ ", bid amount=" + bid.getBidAmount() + ".");

return save(bid);


private Bid save(Bid bid) {
// TODO Auto-generated method stub
return null;



package ejb3inaction.example.buslogic;
import javax.ejb.Local;
import ejb3inaction.example.persistence.Bid;
public interface PlaceBidBeanLocal {
Bid addBid(Bid bid);


package ejb3inaction.example.buslogic;


import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ejb3inaction.example.persistence.Bid;

* Servlet implementation class PlaceBidServlet
public class PlaceBidServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

* @see HttpServlet#HttpServlet()
public PlaceBidServlet() {
// TODO Auto-generated constructor stub

private PlaceBidBeanLocal placeBid;

* @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
// TODO Auto-generated method stub

int bidderID = 2;
int itemID = 1;

double bidAmount = 100;

Bid bid = new Bid();




package ejb3inaction.example.persistence;

public class Bid {

private int bidderID;
private int itemID;
private double bidAmount;

public int getBidderID() {
return bidderID;
public void setBidderID(int bidderID) {
this.bidderID = bidderID;
public int getItemID() {
return itemID;
public void setItemID(int itemID) {
this.itemID = itemID;
public double getBidAmount() {
return bidAmount;
public void setBidAmount(double bidAmount) {
this.bidAmount = bidAmount;


Rachna Jain
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
Unless you are using servlet 3 and the @WebServlet annotation, you need to use the web.xml deployment descriptor to define the servlet.
See example at this web page:
Note that the above example page contains a lot of things you do not need. Just look at the servlet section!
Best wishes!

My free books and tutorials:
I agree. Here's the link:
subject: Need Help while running stateless session bean with Servelet bean client
It's not a secret anymore!