Rajnish Bhasin

Greenhorn
+ Follow
since Mar 01, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Rajnish Bhasin

Narrowing is only for the Initial EJBHome Stub....that too only in case of Remote Calls.... since u r doing a IIOP call which might result in u getting Objects of some other Language type...so u need to make sure that u get the right object from yr IIOP call.

After u get the EJBHome stub... u r all set... then u dont need a narrow call ever... since u already know what Object u r working on....of course u can get a collection from from yr EJBHome object when u fetch more than ONE primary key.... but the whole point is that u r aware that these calls are on the EJBHome STUB ...

But in case of the IIOP lookup u are not sure footed as to what Object type u might be returned ... so PortableRemoteObject.narrow() makes it sure u get the right Object.

Hope this helps...
Becoz in case of EJBHome Narrowing what u r narrowing is a object of java.lang.Object and u r not sure what Object that might be in case of IIOP where interaction might be between Objects of diffrent Languages.
Where as in case of the EJBObject u dont need a narrow as u r already aware what u will get back i.e a object of the type of yr Remote Interface and not just java.lang.Object.

Hope it helps...
Hi,
Havent worked on EJB's that much(although i am certified).
Was just wondering, in case of Web Sessions ONE client would get the same session object thoughout the Web Application till he/she invalidates the session or it times out etc.

Just wanted to clarify the same thing in case of Sateful Session Beans.
If i am a JSP/Servlet Client, and i am making multiple calls to a Stateful session bean by means of a JNDI lookup in diffrent JSP pages, will i get the same Stateful session bean ...... or do i need to store the reference of the EJBObject in a HttpSession and then use the same in diffrent JSP Pages.

Simply put... when the same client calls the same Stateful Session Bean from diffrent JSP pages in a Web App(By Means of a JNDI Lookup), does he get the same Stateful Session Bean in all cases... or does he need to store the reference of the EJBObject he got in the first place(first JSP Page where look up was performed) in a HttpSession so that its available to all JSP Pages.

Looking forward to a satisfying response....
Cheers..
This question has always lingered in my mind, when i hear that even Stateful Session Beans are SCALABLE in the sense that they can be(OR better the STATE of a STATEFUL SESSION BEAN)passivated. This allows for saving resources on the container.
My Questions are:
1)How is the container saving on resources when a stateful session bean is passivated. Does it also nullify the bean whose state has been passivated to some kind of storage ?, thereby making the BeanObject eligible for garbage collection?
2)There is no POOL in case of the stateful session bean, so where does the bean that has been passivated go?, what does the container do with the Bean?
3)What does the container do at the time of activation ? Does it create a new Bean Object and initialize with the values that were passivated ? If that is not the case which bean Object does the container Initialize with the already passivated values ? And if it does make a new Bean to initialize with the passivated values then why is a ejbCreate() not called again ?
I hope my questions are legitimate... and i receive a good response from some one.
Thanks Guys.
Hi all,
I have been asked this peculiar question for interviews a couple of times and i just dont have an answer to it.
Guess some one here can help me with this !!!
Q.Suppose i am deploying an .WAR app on Weblogic. Where do i put the .properties file, in case i have some resouces which need to be accessed via .properties file ?
I know in general cases we put the .properties in DOC_ROOT/WEB-INF/classes
And thats what i always answer.But it seems there is some other way round to this....
Please let me know!!!
Very Well Said...
Thanks a lot for the excellent example and explanation.
Hi everyone,
I cleared the cert a month back, but was never satisfied with the way CMR has been handled in most BOOKS.
There has always been a confusion in the role of Container Managed Relationships and why exaclty they have been introduced?
Also why are only Local Component Interfaces required as return types for CMR?
If some one could give a detailed explanation of the above mentioned it would be of extreme help to me in understanding this particular part of EJB's!!!
Well everybody has been beating around the bush saying that, CMR require Local
Component interfaces rather than Remote ones.
But no one has yet explained as to why Local Interfaces are required for CMR!!!
What is so special abt CMR that it requires only LOCAL Interfaces ?
Hope we get a reply for the same...
One more point:
1)The original purpose of having Local Home/Component interfaces was not becoz of the JVM thing.It was basically to allow for Container Managed Relationships(CMR), which allow u to access Objects of another Entity Bean u r in a relationship with extreme ease and less overhead of calling diffrent queries.
2)Although it was later that SUN also provided Local Home/Component interfaces for client bean calling to save upon overhead of having remote calls being made to Objects on the same heap.
Following are the methods u can call upon in order to get Object refrences to either yr Home or yr Remote interface.
1)getHomeHandle() method in java.ejb.EJBHome interface returns a javax.ejb.Handle Object.You can call getEJBHome() method on this HomeHandle Object to get a refrence to yr Home Interface.
2)getHandle() in yr javax.ejb.EJBObject interface returns a javax.ejb.Handle Object.You can call getEJBObject() method on this Handle Object to get a refrence to yr Remote/EJBObject Interface.
Hope that was of help to you...
Hope this helps...
1)Entity is the row in the DB.
2)Entity Bean is the Object Oriented EJB view of that Entity in the DB.
3)EJBObject is the container created refrence to the Bean. It is not specific to any bean in the pool, rather it is created only after:
a)The container picks one bean from the pool and call the ejbCreate() method on it in response to the create() called by the Client on the Home interface.
b)The client calls a findXXX() method and the container either locates an existing EJBObject or creates one for the client based on the Primary Key passed by the Client.
My primary question was...
1)Can we throw or declare java.rmi.RemoteException inside a business method of any kind of bean ? lets say Entity bean...
2)Some beans act as clients for other beans.... like in case of a Session Facade a Session bean Acts like one for the Entity bean.
3)Since java.rmi.RemoteException is aslo a Checked Exception, we need to either:
a)Put it in the throws Clause.
b)Catch it in the catch block.
4)I just need to know why is it mentioned in the HF EJB book that u should never throw/declare a java.rmi.RemoteException in the Bean Class.
[ March 13, 2004: Message edited by: Rajnish Bhasin ]
O.k,
Let me get this straight first....
All throughout the Head First EJB Book, i have always read that NEVER THROW A REMOTE EXCEPTION IN YOUR BEAN CLASS.
Now what i wanted to ask is, in case of a Bean Facade Model the session bean acts as a Client to a Entity Bean...
Now acting as a client means declaring the RemoteException in the throws clause or in the catch block...
Becoz when we call actual business methods from a client on a Bean, we always have to handle the RemoteException. And in this case a business method of one bean is acting as the client to another bean, so to declare a RemoteException in this case would be o.k ?
Waiting for a convincing response...
Nathan...
Could u pls elaborate on this.....as to what are u trying to refer by this...

It really should be no different from calling getHandle on the remote bean and passing that to the local home, where it gets the associated remote bean and does whatever it wants with it.


One gets EJBObjects from the home interface.
One thing is very clear, we dont create EJBObjects, the container does.So the container is intellegent enough to send back only EJBLocalObjects in case of a LocalHome and similarily Remote EJBObjects for a RemoteHome.
So where does the confusion arise ?
I really dont understand how has the bean Provider landed in this Picture of Sending EjbObjects to the HomeObject ?
Nathan, please let me know if i am wrong, or if i have not judged the question properly.
Thats a good one Nathan...
Well that makes Chris a ready contender for the exam.
All the Best Chris...