File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes PortableRemoteObject & Mail in j2ee 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 "PortableRemoteObject & Mail in j2ee" Watch "PortableRemoteObject & Mail in j2ee" New topic
Author

PortableRemoteObject & Mail in j2ee

rastin purr
Ranch Hand

Joined: Jul 20, 2002
Posts: 73
Could any one explain to me what is the use of PortableRemoteObject.narrow method used for? As down cast could be done directly, why is there a need for PortableRemoteObject. Thanks
Could Initial Context (JNDI) be used to looked up a mail session (for email)? I believe so. Please correct me if I am wrong. And if so, where should it be located? I mean how should the mail server and username password authentication be set. Is it server specific? If so how could it be done in j2eesdk1.3.1 ri and Orion server? Thanks
regards
Rastin
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Originally posted by rastin purr:
Could any one explain to me what is the use of PortableRemoteObject.narrow method used for? As down cast could be done directly, why is there a need for PortableRemoteObject. Thanks
Could Initial Context (JNDI) be used to looked up a mail session (for email)? I believe so. Please correct me if I am wrong. And if so, where should it be located? I mean how should the mail server and username password authentication be set. Is it server specific? If so how could it be done in j2eesdk1.3.1 ri and Orion server? Thanks
regards
Rastin

as for the first question, I would highly recommend that you read mastering EJB by Ed Roman. PDF available at www.middleware-company.com.
<extracted-from-book>

javax.rmi.PortableRemote Object.narrow(). This is a static method on an RMI-IIOP class called Portable
RemoteObject. This method casts the generic object that we looked up via JNDI
to our RMI-IIOP interface type. This narrow() operation is required whenever
you lookup an RMI-IIOP object via JNDI. Why do we need it, and why don’t
we just cast it using a regular Java cast? The short answer is CORBA interoperability.

<extracted-from-book>
check appendix B.
as per the second question (mail):
Yes, it could be used. In fact, this is what I'm doing:

it should be located whenever you need to send email, in this case you need the mail Session.
In my case, I'm using JBoss, so in my jboss.xml file I add these lines.

JBoss comes with an xml file called mail-service.xml. In this file you set up the SMTP server or POP server, username, password, JNDI name, etc... very easy.
sorry but I don't know how to do it with Orion. shouldn't be too much the difference..
hope it helps
good luck


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
rastin purr
Ranch Hand

Joined: Jul 20, 2002
Posts: 73
Thanks Andres,
Just to make sure i understand it correctly, does this means that,
if say, part of the j2ee application (some ejb jar files) is running on a host, and the j2ee application (some different ejb jar files) is running on a different host, and to look up the ejb on diferrent host normal java casting cannot be done cause they are network appart. So we need PortableRemoteObject to do the down casting. Is that right?
If say, on a different situation, a server (orion or weblogic) is running on a host and the j2ee application is on another different host, to get the initial context, we need to set the provider and the uri say something like t3 for weblogic and ormi for orion... Am I right so far? please correct me if i am not. And to lookup the DataSource for connection pooling in order to get a connection, do we need to use portable remove object as well? I think so cause they are separated and they should communicate using rmi-iiop? Is that correct?
Please explain. Thanks. Anyone who has any ideas are welcome. Thanks again.
Ras
rastin purr
Ranch Hand

Joined: Jul 20, 2002
Posts: 73
anyone?? anyone at all???
rastin purr
Ranch Hand

Joined: Jul 20, 2002
Posts: 73
Sorry if this this trouble anyone here.
Please, is there any one here who could give me a reply? I know there are lots of good j2ee developers out there in the javaranch site. Please help me out. Please................
Rastin
 
 
subject: PortableRemoteObject & Mail in j2ee
 
Similar Threads
Error with running batch file from Java class
is PortableRemoteObject. really needed?
MS exchange server information
Local Interfaces
Java Mail on Websphere .. plz Help