This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Create EJB from J2SE console app  RSS feed

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I it possible to remotely call a bean method from a J2SE console App?

The two are running on the same server.
 
author & internet detective
Marshal
Posts: 38508
653
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephen,
You could use a J2EE application client or make remote EJB calls by looking up the initial context.
 
Stephen Hanley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,

Thanks for your reply.

That's the approach I had thought I would be able to take. It's obviously not as easy as it seems. The following is a snippet of the code i was trying:


ie.spraoi.jambo.stateful.MessageManagerHome.JNDI_NAME is my MessageManagerBean stateful session bean's home interface. Eclipse is underlining red and saying it cannot resolve it?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 38508
653
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephen,
Sounds like a compiler error. Check you have a jar with the EJB stubs and skeletons in your classpath.
 
Stephen Hanley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,

Thanks again for your help.

I was just discussing this with a colleague on the phone.

I am new to J2EE, RMI-IIOP, JNDI and the rest.

Do you mean I have to have the files in the folder 'ejbsrc' available to my console app?

Do I have to import my EJB Module (.jar) into the consoles class path or is that overkill?

(Or am I just out of my depth? :eek

Kind regards,

Stephen Hanley.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 38508
653
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephen,
You aren't out of your depth Either of those is a viable solution.

If you are just testing, either of those options is fine. I recommend putting the ejb jar in your classpath (option #2.) It's overkill, but it's also the easiest. And it is generally a good practice not to include the source where it isn't needed.

If you are actually distributing this console app to others, you will want to create a jar with just the stubs and skeletons. That way callers won't have access to all your business logic.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!