• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Is this execution stops unexpectedly?

 
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the below code

EJB Object



EJB Home


Session Bean

import javax.ejb.*;
public class FortuneBean implements SessionBean
{
private String[] yourFortune = {"Fortune and glory, kid. Fortune and glory",
"You're gonna get killed chasing after your damn fortune and glory!",
"Feels like I stepped on a fortune cookie!",
"The fortune cookie will slip right through your fingers!",
"It's not a cookie, it's a bug!",
"It is your time to do research and dig up the treasure!",
"It is your year!",
"While looking for a fortune cookie, hold on to your potatoes!",
"You are in a position unsuitable to give orders!"};

String name = "No Name? " ;
public void ejbActivate()
{
System.out.println("From ejbActivate()");
}

public void ejbPassivate()
{
System.out.println("From ejbPassivate()");
}
public void ejbRemove()
{
System.out.println("From ejbRemove()");
}
SessionContext sc;
static int count;
public void setSessionContext(SessionContext ctx)
{
sc = ctx;
count++;
System.out.println("From setSessionContext()");
try
{
FortuneHome home = (FortuneHome)sc.getEJBHome();
Fortune fortuner = home.createMessagesWithName("Athulya " + count);
//Fortune fortuner = home.create();
System.out.println(fortuner.getNextFortune());
System.out.println(fortuner.getMyMessage());
}
catch (Exception e)
{
e.printStackTrace();
}

}

public String getNextFortune()
{
System.out.println("From getNextFortune(): ");
int randomNum = (int) (Math.random() * yourFortune.length);
return name + " -> " + yourFortune[randomNum];
}
public String getMyMessage()
{
System.out.println("From getMyMessage(): ");
return name + " -> " + " None but the brave deserves the fair.";
}
public void ejbCreate()
{
System.out.println("From ejbCreate()");
}
public void ejbCreateMessagesWithName(String name)
{
System.out.println("From ejbCreateMessagesWithName()");
this.name = name;
}
}



Inside the setSessionContext() method, i am creating another bean. So the creation of beans must go on infinitly. right?

But when i run the client code, it starting with continous creation of beans. But its stops automatically within some seconds.

Please anyone tell me why it is stoping the execution?
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic