This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Making calls outside the container Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Making calls outside the container" Watch "Making calls outside the container" New topic
Author

Making calls outside the container

Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
I'm new to EJBs and have the following question. Can I make a socket call to a remote server from within an EJB? For example, can I make such a socket call from within the onMessage() method of a MessageDrivenBean? Or delegate to an object that can make the socket call?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You can, but the specification strongly suggests you not to. I wouldn't be too afraid of doing this as long as you know that you're breaking the spec and accept the possibility of side effects.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8904

Socket clients are acceptable but not socket servers.
The EJB architecture allows an enterprise bean instance to be a network socket client, but it does not allow it to be a network server. Allowing the instance to become a network server would conflict with the basic function of the enterprise bean-- to serve the EJB clients.
[ August 28, 2003: Message edited by: Pradeep Bhat ]

Groovy
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
That's correct. I was too strict in my wording.
Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
Thanks! This is all very useful. Indeed I had a socket client in mind. As you remark, a socket server would be a redundancy.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Making calls outside the container
 
Similar Threads
Can a Session bean use URL and URLConnection classes ?
socket to applet inside a browser ?
How to call an executable (.exe) from java
How does Applets communicate with server?
what is JTAPI ?