This is a discussion on Answer EJB Interview Questions - Part 1 within the Java Tutorials forums, part of the Articles and Tutorials category; We are in the process of preparing answers for the interview questions from our question bank . Please anser the following ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Answer EJB Interview Questions - Part 1
We are in the process of preparing answers for the interview questions from our question bank . Please anser the following questions with any reference links for any sample code, tutorial or ebook chapter. After we get answers for these questions, we will update the question bank and move on to the next set of questions.
1. Is there a way to get the original exception object from inside a nested or wrapped Exception (for example an EJBException or RemoteException) 2 If my session bean with single method insert record into 2 entity beans, how can I know that the process is done in same transaction (the attributes for these beans are Required) 3 What is EJB architecture(components) 4 How can i retrieve from inside my Bean(Stateless session and Entity CMP) the user name which i am serving (the user name of user just logged in my web application) 5 Can I develop an Entity Bean without implementing the create() method in the home interface 6 Is stateless Sessiob bean create() method contains any parameters 7 What is the difference between ejbCreate() and ejbPostCreate() 8 What is the difference between ejbStore() and ejbLoad() 9 With EJB 1.1 specs, why is unsetSessionContext() not provided in Session Beans, like unsetEntityContext() in Entity Beans 10 Why are ejbActivate() and ejb Passivate() included for stateless session bean even though they are never required as it is nonconversational bean |
|
|||||
|
Re:Answer EJB Interview Questions - Part 1
Quote:
Both Stateless and Stateful Session Bean implement javax.ejb.SessionBean and this would not be possible if stateless session bean is to remove ejbActivate and ejbPassivate from the interface. You could argue that the two (stateful and stateless) are so different that they should have their own interface but Sun did not think so. They made both session beans implement the same interface and provided deployment descriptor to denote which one is it that you are deploying. Quote:
Quote:
So if your session bean is using container-managed transactions and your method is deployed with \'Required\', \'RequiresNew\' or \'Mandatory\', you can safely assume that the calls to your entity beans are handled under same transaction. If you\'re not running in a transaction, a separate transaction will be set up for each call to your entity beans. If your session bean is using bean-managed transactions, you can ensure that the calls are handled in the same transaction by : javax.transaction.UserTransaction tran= null; try{ tran=ctx.getUserTransaction(); tran.begin(); myBeanHome1.create(....); myBeanHome2.create(...); tran.commit(); }catch(...){} You may want to check if you\'re already running in a transaction by calling tran.getStatus(). Quote:
Some examples: ·When you have an javax.ejb.EJBException, you can use the getCausedByException() that returns a java.lang.Exception. ·A java.rmi.RemoteException there is a public field called detail of type java.lang.Throwable ·With a java.sql.SQLException you need to use the method getNextException() to get the chained java.sql.SQLException. ·When you have an java.lang.reflect.InvocationtargetException, you can get the thrown target java.lang.Throwable using the getTargetException() method. Quote:
sessionContext.getCallerIdentity().getName() where sessionContext is the instance of \"SessionContext\" (setSessionContext) passed to the Session Bean, or the instance of \"EntityContext\" (setEntityContext) passed to the Entity Bean. Remaining answers for part 1 later ![]() Post edited by: vasu, at: 2004/09/30 22:21 |
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to ace an J2EE Interview!! - PART 1 | akpraveen | Interview Questions | 5 | 05-07-2007 04:28 AM |
| comp.lang.c Answers to Frequently Asked Questions (FAQ List) | Steve Summit | Tech FAQ | 0 | 06-01-2004 07:00 AM |
| Quarterly ASCII posting of SCO Programmer's FAQ | Boyd Lynn Gerber | Tech FAQ | 0 | 04-25-2004 11:11 PM |
| Motif FAQ (Part 4 of 9) | Ken Lee | Tech FAQ | 0 | 04-18-2004 09:54 AM |