<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java Interview Questions &#187; Ejb Interview Questions</title>
	<atom:link href="http://www.bestjavainterviewquestions.com/category/ejb-interview-questions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bestjavainterviewquestions.com</link>
	<description>Java Interview Questions &#124; Core Java Interview Questions &#124; Advanced Java Interview Questions &#124; EJB Interview Questions &#124; J2EE Interview Questions &#124; Hibernate Interview Questions</description>
	<lastBuildDate>Fri, 30 Jul 2010 06:00:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>EJB Interview questions</title>
		<link>http://www.bestjavainterviewquestions.com/ejb-interview-questions-2/</link>
		<comments>http://www.bestjavainterviewquestions.com/ejb-interview-questions-2/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 19:27:24 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Ejb Interview Questions]]></category>
		<category><![CDATA[ejb technical interview questions]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=582</guid>
		<description><![CDATA[Q) What is EJB Rep) Enterprise JavaBeans. Q) What is EJB container Rep) A container that implements the EJB component contract of the J2EE architecture. This contract specifies a runtime environment for enterprise beans that includes security, concurrency, life-cycle management, transactions, deployment, naming, and other services. An EJB container is provided by an EJB or [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Q) What is EJB</p>
<p>Rep) </strong>Enterprise JavaBeans.</p>
<p><strong>Q) What is EJB container</p>
<p>Rep) </strong>A container that implements the EJB component contract<br />
of the J2EE architecture. This contract specifies a<br />
runtime environment for enterprise beans that includes<br />
security, concurrency, life-cycle management,<br />
transactions, deployment, naming, and other services.<br />
An EJB container is provided by an EJB or J2EE server.</p>
<p><strong>Q) What is EJB container provider</p>
<p>Rep) </strong>A vendor that supplies an EJB container.</p>
<p><strong>Q) What is EJB context</p>
<p>Rep) </strong>A vendor that supplies an EJB container. An object<br />
that allows an enterprise bean to invoke services<br />
provided by the container and to obtain the<br />
information about the caller of a client-invoked<br />
method.<br />
<strong><br />
Q) What is EJB home object</p>
<p>Rep)</strong> An object that provides the life-cycle operations<br />
(create, remove, find) for an enterprise bean. The<br />
class for the EJB home object is generated by the<br />
container&#8217;s deployment tools. The EJB home object<br />
implements the enterprise bean&#8217;s home interface. The<br />
client references an EJB home object to perform<br />
life-cycle operations on an EJB object. The client<br />
uses JNDI to locate an EJB home object</p>
<p><strong>Q) What is EJB JAR file</p>
<p>Rep) </strong>A JAR archive that contains an EJB module.</p>
<p><strong>Q) What is EJB module</p>
<p>Rep) </strong>A deployable unit that consists of one or more<br />
enterprise beans and an EJB deployment descriptor.</p>
<p><strong>Q) What is EJB object</p>
<p>Rep) </strong>An object whose class implements the enterprise bean&#8217;s<br />
remote interface. A client never references an<br />
enterprise bean instance directly; a client always<br />
references an EJB object. The class of an EJB object<br />
is generated by a container&#8217;s deployment tools.</p>
<p><strong>Q) What is EJB server</p>
<p>Rep) </strong>Software that provides services to an EJB container.<br />
For example, an EJB container typically relies on a<br />
transaction manager that is part of the EJB server to<br />
perform the two-phase commit across all the<br />
participating resource managers. The J2EE architecture<br />
assumes that an EJB container is hosted by an EJB<br />
server from the same vendor, so it does not specify<br />
the contract between these two entities. An EJB server<br />
can host one or more EJB containers.</p>
<p><strong>Q) What is EJB server provider</p>
<p>Rep) </strong>A vendor that supplies an EJB server.</p>
<p><strong>Q) What is element</p>
<p>Rep) </strong>A unit of XML data, delimited by tags. An XML element<br />
can enclose other elements.</p>
<p><strong>Q) What is empty tag</p>
<p>Rep)</strong> A tag that does not enclose any content<br />
<strong><br />
Q) What is enterprise bean</p>
<p>Rep)</strong> A J2EE component that implements a business task or<br />
business entity and is hosted by an EJB container;<br />
either an entity bean, a session bean, or a<br />
message-driven bean.</p>
<p><strong>Q) What is enterprise bean provider</p>
<p>Rep) </strong>An application developer who produces enterprise bean<br />
classes, remote and home interfaces, and deployment<br />
descriptor files, and packages them in an EJB JAR<br />
file.</p>
<p><strong>Q) What is enterprise information system</p>
<p>Rep) </strong>The applications that constitute an enterprise&#8217;s<br />
existing system for handling companywide information.<br />
These applications provide an information<br />
infrastructure for an enterprise. An enterprise<br />
information system offers a well-defined set of<br />
services to its clients. These services are exposed to<br />
clients as local or remote interfaces or both.<br />
Examples of enterprise information systems include<br />
enterprise resource planning systems, mainframe<br />
transaction processing systems, and legacy database<br />
systems.</p>
<p><strong>Q) What is enterprise information system resource</p>
<p>Rep)</strong> An entity that provides enterprise information<br />
system-specific functionality to its clients. Examples<br />
are a record or set of records in a database system, a<br />
business object in an enterprise resource planning<br />
system, and a transaction program in a transaction<br />
processing system.<br />
<strong><br />
Q) What is Enterprise JavaBeans (EJB)</p>
<p>Rep) </strong>A component architecture for the development and<br />
deployment of object-oriented, distributed,<br />
enterprise-level applications. Applications written<br />
using the Enterprise JavaBeans architecture are<br />
scalable, transactional, and secure.</p>
<p><strong>Q) What is Enterprise JavaBeans Query Language (EJB QL)</p>
<p>Rep) </strong>Defines the queries for the finder and select methods<br />
of an entity bean having container-managed<br />
persistence. A subset of SQL92, EJB QL has extensions<br />
that allow navigation over the relationships defined<br />
in an entity bean&#8217;s abstract schema.</p>
<p><strong>Q) What is an entity</p>
<p>Rep) </strong>A distinct, individual item that can be included in an<br />
XML document by referencing it. Such an entity<br />
reference can name an entity as small as a character<br />
(for example, &lt;, which references the less-than symbol<br />
or left angle bracket, &lt;). An entity reference can<br />
also reference an entire document, an external entity,<br />
or a collection of DTD definitions.</p>
<p><strong>Q) What is entity bean</p>
<p>Rep)</strong> An enterprise bean that represents persistent data<br />
maintained in a database. An entity bean can manage<br />
its own persistence or can delegate this function to<br />
its container. An entity bean is identified by a<br />
primary key. If the container in which an entity bean<br />
is hosted crashes, the entity bean, its primary key,<br />
and any remote references survive the crash.</p>
<p><strong>Q) What is entity reference</p>
<p>Rep) </strong>A reference to an entity that is substituted for the<br />
reference when the XML document is parsed. It can<br />
reference a predefined entity such as &lt; or reference<br />
one that is defined in the DTD. In the XML data, the<br />
reference could be to an entity that is defined in the<br />
local subset of the DTD or to an external XML file (an<br />
external entity). The DTD can also carve out a segment<br />
of DTD specifications and give it a name so that it<br />
can be reused (included) at multiple points in the DTD<br />
by defining a parameter entity.<br />
<strong><br />
Q) What is error</p>
<p>Rep) </strong>A SAX parsing error is generally a validation error;<br />
in other words, it occurs when an XML document is not<br />
valid, although it can also occur if the declaration<br />
specifies an XML version that the parser cannot<br />
handle. See also fatal error, warning.</p>
<p><strong>Q) What is Extensible Markup Language</p>
<p>Rep)</strong> XML.<br />
<strong><br />
Q) What is external entity</p>
<p>Rep) </strong>An entity that exists as an external XML file, which<br />
is included in the XML document using an entity<br />
reference.</p>
<p><strong>Q) What is external subset</p>
<p>Rep) </strong>That part of a DTD that is defined by references to<br />
external DTD files.</p>
<p><strong>Q) What is fatal error</p>
<p>Rep) </strong>A fatal error occurs in the SAX parser when a document<br />
is not well formed or otherwise cannot be processed.<br />
See also error, warning.</p>
<p><strong>Q) What is filter</p>
<p>Rep)</strong> An object that can transform the header or content (or<br />
both) of a request or response. Filters differ from<br />
Web components in that they usually do not themselves<br />
create responses but rather modify or adapt the<br />
requests for a resource, and modify or adapt responses<br />
from a resource. A filter should not have any<br />
dependencies on a Web resource for which it is acting<br />
as a filter so that it can be composable with more<br />
than one type of Web resource.</p>
<p><strong>Q) What is filter chain</p>
<p>Rep) </strong>A concatenation of XSLT transformations in which the<br />
output of one transformation becomes the input of the<br />
next.</p>
<p><strong>Q) What is finder method</p>
<p>Rep) </strong>A method defined in the home interface and invoked by<br />
a client to locate an entity bean.<br />
<strong><br />
Q) What is form-based authentication</p>
<p>Rep) </strong>An authentication mechanism in which a Web container<br />
provides an application-specific form for logging in.<br />
This form of authentication uses Base64 encoding and<br />
can expose user names and passwords unless all<br />
connections are over SSL.<br />
<strong><br />
Q) What is general entity</p>
<p>Rep) </strong>An entity that is referenced as part of an XML<br />
document&#8217;s content, as distinct from a parameter<br />
entity, which is referenced in the DTD. A general<br />
entity can be a parsed entity or an unparsed entity.</p>
<p><strong>Q) What is group</p>
<p>Rep) </strong>An authenticated set of users classified by common<br />
traits such as job title or customer profile. Groups<br />
are also associated with a set of roles, and every<br />
user that is a member of a group inherits all the<br />
roles assigned to that group.</p>
<p><strong>Q) What is handle</p>
<p>Rep) </strong>An object that identifies an enterprise bean. A client<br />
can serialize the handle and then later deserialize it<br />
to obtain a reference to the enterprise bean.<br />
<strong><br />
Q) What is home handle</p>
<p>Rep) </strong>An object that can be used to obtain a reference to<br />
the home interface. A home handle can be serialized<br />
and written to stable storage and deserialized to<br />
obtain the reference.</p>
<p><strong>Q) What is home interface</p>
<p>Rep) </strong>One of two interfaces for an enterprise bean. The home<br />
interface defines zero or more methods for managing an<br />
enterprise bean. The home interface of a session bean<br />
defines create and remove methods, whereas the home<br />
interface of an entity bean defines create, finder,<br />
and remove methods.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/main-exceptions-in-thread/" title="Main Exceptions in Thread"><img src="Array" alt="Main Exceptions in Thread" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/uploading-excel-file-using-jsp/" title="Uploading Excel File  Using Jsp"><img src="Array" alt="Uploading Excel File  Using Jsp" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/what-is-port-number/" title="What is Port Number"><img src="Array" alt="What is Port Number" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/difference-between-getcurrentsession-and-opensession/" title="Difference between getCurrentSession() and openSession()"><img src="Array" alt="Difference between getCurrentSession() and openSession()" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/ejb-interview-questions/" title="EJB INTERVIEW QUESTIONS"><img src="Array" alt="EJB INTERVIEW QUESTIONS" /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/ejb-interview-questions-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Stateful session Bean</title>
		<link>http://www.bestjavainterviewquestions.com/creating-a-stateful-session-bean/</link>
		<comments>http://www.bestjavainterviewquestions.com/creating-a-stateful-session-bean/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 15:00:30 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Example of stateful session bean]]></category>
		<category><![CDATA[statefulsessionbean]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=564</guid>
		<description><![CDATA[To send two values to a stateful session bean and getting their sum and difference. The program makes two conversations(calls) with the session bean. In one call it gets the sum and in the second call it gets the difference. Between the calls state is to be maintained. 1 Step) Remote interface : import javax.ejb.*; [...]]]></description>
			<content:encoded><![CDATA[<p>To send two values to a stateful session bean and getting their sum and difference.</p>
<p>The program makes two conversations(calls) with the session bean. In one call it gets the sum and in the second call it gets the difference. Between the calls state is to be maintained.</p>
<p><em><strong>1 Step) Remote interface :</strong><br />
</em></p>
<p><em>import javax.ejb.*;<br />
import java.rmi.*;</p>
<p>//No change from Stateless</p>
<p>public interface Calc extends EJBObject<br />
{<br />
public int add(int a,int b) throws RemoteException;<br />
public int sub(int a, int b) throws RemoteException;<br />
}</p>
<p><strong>2 Step: Home interface;</strong></p>
<p>import javax.ejb.*;<br />
import javax.rmi.*;</p>
<p>public interface CalcHome extends EJBHome<br />
{<br />
public Calc create() throws CreateException, RemoteException;</p>
<p>//Observe the change in the implementation of business methods<br />
}</p>
<p><strong>3 Step: Bean class file;</strong></p>
<p>import javax.ejb.*;<br />
import javax.rmi.*;</p>
<p>public class CalcBean implements SessionBean<br />
{</p>
<p>//change here, creating some instance variables to be used in between method calls<br />
SessionContext ctx;<br />
int a,b;</p>
<p>public int add(int a ,int b)<br />
{</p>
<p>//initialize local ot instance variables</p>
<p>this.a=a;<br />
this.b=b;</p>
<p>return a+b;<br />
}</p>
<p>//for subtraction, instance variables assigned in the previous call are used<br />
public int sub()<br />
{<br />
return a-b;<br />
}</p>
<p>//override all the 4 SessionBean methods</p>
<p>public void ejbCreate(){  }<br />
public void ejbActivate(){  }<br />
public void ejbPassivate(){  }<br />
public void setSessionContext(SessionContext ctx)<br />
{<br />
this.ctx = ctx;<br />
}<br />
}</p>
<p><strong>4 Step: Write XML files needed to create a manifest file</strong></p>
<p>The template of XML files with default setting are available in :<br />
C:\ weblogic\examples\ejb\basic\statefulsession\build\meta-Inf<br />
Copy the Meta-Inf directory to your working directory. That is this Meta-Inf directory becomes subdirectory to your working directory.</p>
<p><strong>1. ejb-jar.xml:</strong></p>
<p>//on this name bean will be deployed<br />
&lt;ejb-name&gt; Calculation &lt;/ejb-name&gt;</p>
<p>//write your home interface name<br />
&lt;home&gt; CalcHome &lt;/home&gt;</p>
<p>//write your remote interface name<br />
&lt;remote&gt; Calc &lt;/remote&gt;</p>
<p>//write your bean class name<br />
//earlier it is Stateless<br />
&lt;session -type&gt; Stateful &lt;/session-type&gt;</p>
<p>comedown and write again<br />
&lt;ejb-name&gt; Calculation &lt;/ejb-name&gt;</p>
<p><strong>2. weblogic-ejb-jar.xml :</strong></p>
<p>&lt;ejb-name&gt; Calculation &lt;/ejb-name&gt;<br />
comedown and write again</p>
<p>//this is reference name to be mentioned in client<br />
//program and with this reference name bean and client will communicate.</p>
<p>&lt;jndi-name&gt; XXX &lt;/jndi-name&gt;</p>
<p><strong>5  Step : Write JAR file :</strong></p>
<p>jar cvf CalcJar.jar *.class META-INF\.xml<br />
<strong><br />
6  Step: Compile JAR file and obtain compiled JAR file :</strong></p>
<p>ejbc CalcJar.jar CalcJar1.jar</p>
<p><strong>7  Step: Copy the compiled JAR file to myserver directory:</strong></em></p>
<p><em>copy CalcJar1.jar c:\weblogic \myserver</p>
<p><strong>8  Step: Deploy the bean: (run from start menu)</strong></p>
<p>start a weblogic 5.1.0 a Utilities a Edit Server Properties<br />
Use Search menu option to locate Weblogic EJB Demo Properties</p>
<p><strong>Write the following statement :</strong></p>
<p>c:\weblogic \myserver \CalcJar1.jar \<br />
<strong><br />
9  Step Run weblogic server (run from start menu )</strong></p>
<p>start weblogic 5.1.0 a weblogic Server</p>
<p>Observer the server displays: 1 deployed. 0 failed to deploy</p>
<p>What we have done so far is, we have created the bean and deployed in weblogic server. Now<br />
we can call and use it.</p>
<p><strong>10 Step: to write the client program, compile and run it to call the bean:</strong></p>
<p>//Observe the change in the implementation of business methods</p>
<p>import javax.ejb.*;<br />
import javax.rmi.*;<br />
import javax.naming.*;<br />
import java.util.*;<br />
class CalcClient<br />
{<br />
public static void main(String args[] ) throws Exception<br />
{<br />
Properties p=new Properties();<br />
p.put(Context.INITIAL_CONTEXT_FACTORY, &#8221; weblogic.jndi.T#InitialContextFactory&#8221;);<br />
p.put(Context.PROVIDER_RUL, &#8220;t3://local:7001&#8243;);<br />
//InitialContext() method throws javax.naming.NamingException<br />
Context ctx = new InitialContext(p);<br />
CalcHome chome = (calcHome) ctx.lookup(&#8220;SNRao&#8221;);<br />
//create() method throws RemoteException and javax.ejb.CreateException<br />
Calc rref = chome.create();</p>
<p>//observe change here<br />
int sum = rref.add(20,5);<br />
int diff = rref.sub();</p>
<p>System.out.println(&#8220;sum :&#8221;+sum);<br />
System.out.println(&#8220;Diff : &#8220;+diff);<br />
}<br />
}</em></p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/servlet-important-questions/" title="Servlet Important Questions"><img src="Array" alt="Servlet Important Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/springs-interview-questions-3/" title="Springs Interview Questions"><img src="Array" alt="Springs Interview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/define-implicit-variables-in-jsp/" title="Define Implicit Variables in JSP"><img src="Array" alt="Define Implicit Variables in JSP" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/core-java-inteview-questions/" title="Core Java Inteview Questions"><img src="Array" alt="Core Java Inteview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/java-interview-questions/" title="Java Interview Questions"><img src="Array" alt="Java Interview Questions" /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/creating-a-stateful-session-bean/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Life Cycle of stateless session bean</title>
		<link>http://www.bestjavainterviewquestions.com/life-cycle-of-stateless-session-bean/</link>
		<comments>http://www.bestjavainterviewquestions.com/life-cycle-of-stateless-session-bean/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 19:27:09 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Life cycle of Stateless Session bean]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=559</guid>
		<description><![CDATA[Stateless session bean The stateless session beans life cycle has two states: does not exist state and the method ready pool Does not exist When a bean instance is in the does not exist state, it is not an instance in the momory of the system.In other words, it has not been instantiated yet. The [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>Stateless session bean</strong></em></p>
<p><em>The stateless session beans life cycle has two states:</em></p>
<ol>
<li>does not exist state and</li>
<li>the method ready pool</li>
</ol>
<p><strong>Does not exist</strong></p>
<p>When a bean instance is in the does not exist state, it is not an instance in the momory of the system.In other words, it has not been instantiated yet.</p>
<p><strong>The method ready pool</strong></p>
<p>Stateless bean instances enter the Method-Ready pool, as the container needs them. When the EJB server is first started, it will create a number of stateless bean instances and enter them into the Method-Ready pool, (The actual behavior of the server depends on the implementation). When the number of stateless instances servicing client request is insufficient, more can be created and added to the pool.</p>
<p><strong>Transitioning to the method-ready pool</strong></p>
<p>When an instance transitions from the Does Not Exist state to the Method-Ready pool, three operations are performed on it. First, the bean instance is instantiated by invoking the <strong>Class.newInstance()</strong> method on the stateless bean class.</p>
<p>Second, the session bean&#8217;s <strong>setSessionContext(SessionContext context)</strong> method is invoked on the bean instance. This is when the instance receives its reference to the EJBContext for its lifetime. The SessionContext reference may be stored in a <strong>nonTransient </strong>instance field of the stateless session bean.</p>
<p>Finally, the no-argument <strong>ejbCreate()</strong> method is invoked on the bean instance. Remember that a stateless session bean only has one <strong>ejbCreate() </strong>method is invoked only once in the life cycle of the stateless session bean, when the client invokes the <strong>create()</strong> method on the EJB home, it is not delegated to the bean instance.</p>
<p>Stateless session beans are not subject to activation, so they can maintain open connections to resources for their entire life cycle. The <strong>ejbRemove() </strong>method should close any open resources before the stateless session bean is removed from memory at the end of its life cycle.</p>
<p><strong>Life in the Method-Ready Pool:</strong></p>
<p>Once an instance is in the Method-Ready pool,  it is ready to service client requests. When a client invokes a business method on an EJB object, the method call is delegated to any available instance in the Method-Ready pool. While the instance is executing the request, it is unavailable for use by other EJB objects. Once the instance has finished, it is immediately available to any EJB object then needs it.</p>
<p>Stateless session instances are only dedicated to an EJB object for the duration of the method. When  an instance is swapped in, its <strong>SessionContext </strong>changes to reflect the context of its EJB object and the client invoking the mehtod. The bean instance may be included in the transactional scope of the client&#8217;s request, and it may access <strong>SessionContext </strong>information specific to the client requested for example, the security and transactional methods. Once the instance has finished servicing the client, it is disassociated from the EJB object and returned to the Method-Ready pool.</p>
<p><strong>Transitioning out of the Method-Ready-Pool</strong></p>
<p>(The death of a stateless bean instance)</p>
<p>Bean instances leave the Method-Ready pool for does Not Exist state when the server no longer needs the instance. This occurs when the server decides to reduce the total size of the Method-Ready pool by removing one or more instance from memory. The process begins by invoking the<strong> ejbRemove() </strong>method on the instance. At this time, the bean instance should perform any cleanup operations, like closing open resources. The<strong> ejbRemove()</strong> method is only invoked once in the life cycle of a stateless session bean&#8217;s instance, whenit is about to make a transition to the does not exist state. When a client invokes one of the<strong> remove()</strong> method on a stateless bean&#8217;s remote or home interface, it is not delegated to the bean instance. The client&#8217;s invocations of this method simply invalidates the <strong>stub </strong>and releases the EJB object, it notifies the container that the client no longer needs the bean. The container itself invokes the <strong>ejbRemove() </strong>method on the stateless  instance, but only at the end of the instance&#8217;s life cycle.</p>
<p>During the <strong>ejbRemove() </strong>method, the <strong>SessionContext </strong>is still available to the bean istance. Following the execution of the <strong>ejbRemove()</strong> method, the bean is dereferenced and eventually garbage collected.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/servlet-interview-questions/" title="Servlet Interview Questions"><img src="Array" alt="Servlet Interview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/can-we-call-destroy-method-on-servlets-from-service-method/" title="Can we call destroy() method on servlets from service method"><img src="Array" alt="Can we call destroy() method on servlets from service method" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/java-util-package-2/" title="JAVA UTIL PACKAGE"><img src="Array" alt="JAVA UTIL PACKAGE" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/define-implicit-variables-in-jsp/" title="Define Implicit Variables in JSP"><img src="Array" alt="Define Implicit Variables in JSP" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/load-factor/" title="Load Factor"><img src="Array" alt="Load Factor" /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/life-cycle-of-stateless-session-bean/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Providing current date and time using Stateless session bean</title>
		<link>http://www.bestjavainterviewquestions.com/providing-current-date-and-time-using-stateless-session-bean/</link>
		<comments>http://www.bestjavainterviewquestions.com/providing-current-date-and-time-using-stateless-session-bean/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 16:49:14 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Ejb Interview Questions]]></category>
		<category><![CDATA[Provide Stateless session bean date and time]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=555</guid>
		<description><![CDATA[Development of every bean includes minimum 4 programs. Remote interface Home interface Bean program Client program Remote interface defines all the methods (business methods) used for communication Home interface defines methods used to connect to the bean. Bean program is the implementation program for all themethods of remote and home interfaces. Finally, a client program [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>Development of every bean includes minimum 4 programs.</strong></em></p>
<ol>
<li><em>Remote interface</em></li>
<li><em>Home interface</em></li>
<li><em>Bean program</em></li>
<li><em>Client program</em></li>
</ol>
<p>Remote interface defines all the methods (business methods) used for communication</p>
<p>Home interface defines methods used to connect to the bean. Bean program is the implementation program for all themethods of remote and home interfaces. Finally, a client program that invokes the business methods of the bean working on the server.</p>
<p><strong>1st program: Remote interface</strong></p>
<p><em>import javax.ejb.*;     //for EJBObject<br />
</em></p>
<p><em>import java. rmi.*;  // for RemoteException</em></p>
<p><em>//every business method should throw RemoteException<br />
</em></p>
<p><em>public interface Time extends EJBObject</em></p>
<p><em>{</em></p>
<p><em>String printTime() throws RemoteException;</em></p>
<p><em>}</em></p>
<p><strong>2nd program : Home interface</strong></p>
<p><em>import javax.ejb.*;</em></p>
<p><em>import java.rmi.*;</em></p>
<p><em>public interface TimeHome extends EJBHome</em></p>
<p><em>{</em></p>
<p><em>public Time create()throws CreateException, RemoteException;</em></p>
<p><em>//the create () method should return the interface object that extends //EJBObject</em></p>
<p><em>}</em></p>
<p><strong>3rd program : Bean class file</strong></p>
<p><em>import javax.ejb.*;</em></p>
<p><em>import java.util.*;   // for Date Class<br />
</em></p>
<p><em>public class TimeBean implements SessionBean</em></p>
<p><em>{</em></p>
<p><em> public String printTime()</em></p>
<p><em>{</em></p>
<p><em>//this is the implementation of business method</em></p>
<p><em>String str = &#8220;Time is &#8220;+new Date().toString();</em></p>
<p><em>return str;   // str is returned to client<br />
</em></p>
<p><em>}</em></p>
<p><em>public void ejbCreate() { } //this corresponds to create() method of home interface</em></p>
<p><em>//override the callback methods of SessionBean interface</em></p>
<p><em>public void ejbPassivate() { }</em></p>
<p><em>public void ejbActivate() { }</em></p>
<p><em>public void ejbRemove() { }</em></p>
<p><em>public void ejbSessionContext(SexxionContext ctx) { }</em></p>
<p><em>}</em></p>
<p><strong>Note:</strong></p>
<ol>
<li>Every Bean should implement either SessionBean or EntityBean interfaces</li>
<li>For every create() method of Home interface, there should be a corresponding ejbCreate() method. create() method can be overloaded and in this example we have only one</li>
</ol>
<p><strong>4th program : Client program:</strong></p>
<p><em>import java.rmi.*;</em></p>
<p><em>import javax.naming.*;</em></p>
<p><em>import java.util.*;  //for Properties data structure<br />
</em></p>
<p><em>public class HelloClient</em></p>
<p><em>{</em></p>
<p><em>public static void main(String args[])throws Exception</em></p>
<p><em>{</em></p>
<p><em>Properties p=new Properties();</em></p>
<p><em>p.put(Context.INITIAL_CONTEXT_FACTORY, &#8220;weblogic.jndi.T3InitialContextFactor&#8221;);</em></p>
<p><em>p.put(Context.PROVIDER_URL, &#8220;t3 :// 197.0.0.102.7001&#8243;);</em></p>
<p><em>Context ic=new InitialContext(p); //SNRao is reference(jndi)name given inXML file</em></p>
<p><em>TimeHome home1= (TimeHome) ic.lookup(&#8220;SNRao&#8221;);</em></p>
<p><em>Time hello1=home1.create(); //this is the create() method of home interface</em></p>
<p><em>String retval =hello1.pringTime();  // now printTime() is executed on server and //output is sent to client</em></p>
<p><em>System.out.println(retval);</em></p>
<p><em>hello.remove();</em></p>
<p><em>}</em></p>
<p><em>}</em></p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/swings-interview-questions/" title="Swings Interview Questions"><img src="Array" alt="Swings Interview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/difference-between-print-and-println-methods-in-java/" title="Difference between Print() and Println() Methods in Java"><img src="Array" alt="Difference between Print() and Println() Methods in Java" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/java-swings-interview-questions/" title="Java Swings Interview Questions"><img src="Array" alt="Java Swings Interview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/jsp-interview-questions-2/" title="JSP Interview Questions"><img src="Array" alt="JSP Interview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/java-rmi-interview-questions/" title="Java RMI Interview questions"><img src="Array" alt="Java RMI Interview questions" /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/providing-current-date-and-time-using-stateless-session-bean/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Services Provided by EJB Container</title>
		<link>http://www.bestjavainterviewquestions.com/services-provided-by-ejb-container/</link>
		<comments>http://www.bestjavainterviewquestions.com/services-provided-by-ejb-container/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 14:13:44 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[EJB Containers]]></category>
		<category><![CDATA[EJB Container]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=552</guid>
		<description><![CDATA[An applications server provides middleware services to the applications, such as transaction services, security services and others. These services are needed for the applciations to be scalable, robust and secure for multiple concurrent users. The EJB container : The EJB container provides a playground where the enterprise beans can run. There can be many beans [...]]]></description>
			<content:encoded><![CDATA[<p>An applications server provides middleware services to the applications, such as transaction services, security services and others. These services are needed for the applciations to be scalable, robust and secure for multiple concurrent users.</p>
<p><strong>The EJB container :</strong></p>
<p>The EJB container provides a playground where the enterprise beans can run. There can be many beans running within a container. Beans containers are responsible for managing the beans running within them. They interact with the beans calling a few required methods that the bean must expose. Containers may also provide access to legacy system.</p>
<p><strong>The EJB server :</strong></p>
<p>The EJB server provides a runtime environment for one or more containers. EJB servers manage low-level system resources, allocating resources to containers as they are needed. EJB specification does not exactly demonstrate differences between an EJB container and EJB server. They go hand by hand.</p>
<p><strong>The services that Implicit distributed transaction management provide :</strong></p>
<p>Implicit distributed transaction management transactions allow us to perform robust, deterministic operations in a distributed environment by setting attributes on the enterprise beans. The EJB server provides a transaction service a low-level implementation of transaction management and coordination. The transaction service must be exposed throught the Java Transaction API(JTA). The JTA is a high-level interface that we can use to control transactions.</p>
<p><strong>Implicit Security :</strong></p>
<p>Security is a majour consideration for multitier deployments. The Java2 platform Standard Edition yields a robust security service that can authorize and authenticate users, securing deployments from unwanted visitors. EJB adds to this the notion of transparent security, allowing components to reap the benefits of a secure deployment without necessarily coding to a security API.</p>
<p><strong>Implicit resource management and component life cycle:</strong></p>
<p>The EJB server implicityly manages the resources for the components such as threads, sockets and database connections. The life cycle of the components themselves are also managed, allowing for components to be reused by the EJB server as necessary.</p>
<p><strong>Implicit persistence:</strong></p>
<p>Persistence is a natural requirement of any deployment that requires permanent storage. EJB offers assistance hereby automatically saving persistent object data to an underlying storage and retrieving that data at a later time.</p>
<p><strong>Implicit remote accessibility :</strong></p>
<p>EJB products will automatically convert our stand-alone, network-less components into distributed, network-aware beings,</p>
<p><strong>Implicit multiclient support:</strong></p>
<p>EJB servers automatically route concurrent requests from client. EJB servers provide built-in thread support, instantiating multiple copies of your component as necessary and channeling client requests to those instances.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/define-earjar-and-war/" title="Define Ear,jar and war"><img src="Array" alt="Define Ear,jar and war" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/core-java-inteview-questions/" title="Core Java Inteview Questions"><img src="Array" alt="Core Java Inteview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/awt-interview-questions/" title="AWT Interview Questions"><img src="Array" alt="AWT Interview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/explain-stream-tokenizer/" title="Explain Stream Tokenizer"><img src="Array" alt="Explain Stream Tokenizer" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/how-many-ejb-objects-are-created-for-a-bean/" title="How many EJB Objects are created for a Bean"><img src="Array" alt="How many EJB Objects are created for a Bean" /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/services-provided-by-ejb-container/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Define EJB frame work</title>
		<link>http://www.bestjavainterviewquestions.com/define-ejb-frame-work/</link>
		<comments>http://www.bestjavainterviewquestions.com/define-ejb-frame-work/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 10:23:14 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[EJB Frame Work Support]]></category>
		<category><![CDATA[EJB Frame Work support]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=549</guid>
		<description><![CDATA[EJB provides the following frame work support. Distributed object infra structure. Component packing add employment. Declarative transaction management. Factory support. Bean activation and passivation. Container metadata. Security. i)  Distributed object infrastructure: EJB does not concern itself with the distributed object infrastructing. It assumes underlying ORB that understands the CORBA RMI/IDI. Semantics. The ORB transports must [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>EJB provides the following frame work support.</strong></em></p>
<ol>
<li><em>Distributed object infra structure.</em></li>
<li><em>Component packing add employment.</em></li>
<li><em>Declarative transaction management.</em></li>
<li><em> Factory support.</em></li>
<li><em>Bean activation and passivation.</em></li>
<li><em>Container metadata.</em></li>
<li><em>Security.</em></li>
</ol>
<p><strong>i)  Distributed object infrastructure:</strong></p>
<p>EJB does not concern itself with the distributed object infrastructing. It assumes underlying ORB that understands the CORBA RMI/IDI. Semantics. The ORB transports must be able to propagate CORBA OTS transactions. IIOP ORB&#8217;s are designed to provide this type of service.</p>
<p><strong>ii) Component packaging and deployment :</strong></p>
<p>EJB defines a packaging mechanism for Server-side components based on JAR&#8217;s manifests and deployment descriptors. The container un-JAR&#8217;s the EJB and then runs if based on the instruction it gets from the maifest and deployment descriptors.</p>
<p><strong>iii) Declarative transaction Management :</strong></p>
<p>EJB supports implicit transaction built on the CORBA OTS/JTS services. EJB does not need to make implicit calls to OTS/JTS to participate in distributed transaction. The EJB container automatically manges the start, commit and roll back of a transaction. Programming can define the transactional attribute of a bean at design time using declartive statement in deployment descriptor. Metadata about the beans they contain, for example, the container can return the class name of the Enterprise bean that this factory interface is associated with.</p>
<p><strong>iv) Factory Support</strong> :</p>
<p>As a bean provides programmer is responsibel for defining a remote factory interface for bean. Developer define a factory I/F that extends factory and define one or more create method. The container provider will automatically generate the factory implementation.How ever, bean must implement an EJB  create() for each create(). As a last step, programmer must register factories with the container, so, that client can create new beans. The container also provide a finder interface to help clients locate existing entity bean.</p>
<p><strong>v) Bean activation and passivation:</strong></p>
<p>As a part of managing the life cycle of an enterprise bean the container calls your bean when it is loaded into memory(or activation). It also calls it when it is deactivated from memory for passionate.</p>
<p><strong>vi) Bean state management :</strong></p>
<p>EJB container can handle both transient and persistent bean. Persistent bean encapsulate in their object reference a unique ID that point to their state. An entity bean manages its own persistence by implementing the persistencde operation directly the container simply hands it a unique-key and tells it to load its state.</p>
<p><strong>vii) Container Metadata</strong></p>
<p>EJB containers can provide metadata about the beans they contain. For example the container an return the class name of the enterprise bean that  this factory interface is associated with.</p>
<p><strong>viii) Security :</strong></p>
<p>EJB cotainer automate the management of some of the security aspects of a bean . Programming needs to declaratively define the security rules for an enterprise bean in security descriptor object. Programmer must then serialize this object and put it in the beans JAR. The EJB container uses this object to perform all security check on behalf of bean.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/what-is-unicode-system/" title="What is unicode System"><img src="Array" alt="What is unicode System" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/difference-between-include-and-import/" title="Difference between #include and Import"><img src="Array" alt="Difference between #include and Import" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/define-session-tracking/" title="Define Session Tracking"><img src="Array" alt="Define Session Tracking" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/exception-handling-and-their-uses/" title="Exception Handling and their uses"><img src="Array" alt="Exception Handling and their uses" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/difference-between-sessionsave-and-sessionsaveorupdate-3/" title="Difference between session.save() and session.saveOrUpdate()"><img src="Array" alt="Difference between session.save() and session.saveOrUpdate()" /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/define-ejb-frame-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Write a note on EJB frame work</title>
		<link>http://www.bestjavainterviewquestions.com/write-a-note-on-ejb-frame-work/</link>
		<comments>http://www.bestjavainterviewquestions.com/write-a-note-on-ejb-frame-work/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 09:50:03 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[EJB FrameWork]]></category>
		<category><![CDATA[Enterprise JavaBean(EJB)]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=545</guid>
		<description><![CDATA[EJB Frame Work: EJB defines the callBack interfaces a Java Bean must expose to its OTM, and viceversa. In addition. EJB specifies a packaging mechanism for server-side components. The EJB specification defines a server component model for Java Beans. An EJB is specialized non-visual Java Bean that runs on a server like Java Beans. EJB [...]]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;"><em><strong>EJB Frame Work:</strong></em></span></p>
<p>EJB defines the callBack interfaces a Java Bean must expose to its OTM, and viceversa. In addition. EJB specifies a packaging mechanism for server-side components. The EJB specification defines a server component model for Java Beans. An EJB is specialized non-visual Java Bean that runs on a server like Java Beans. EJB can be assembled via tools to create new application. In a multitier application architecture, most of an application logic is moved from the client to one or more server.</p>
<p>A server component model simplifies the process of moving the logic to the server. The component model implements a set of automatic services to manage the components.</p>
<p><em><strong>EJB provides the following frame work support.</strong></em></p>
<ol>
<li>Distributed object infra structure.</li>
<li>Component packing add employment.</li>
<li>Declarative transaction management.</li>
<li> Factory support.</li>
<li>Bean activation and passivation.</li>
<li>Container metadata.</li>
<li>Security.</li>
</ol>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/jsp-interview-questions-2/" title="JSP Interview Questions"><img src="Array" alt="JSP Interview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/explain-executeupdate-method/" title="Explain executeUpdate Method"><img src="Array" alt="Explain executeUpdate Method" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/defining-life-cycle-of-thread/" title="Defining Life Cycle of Thread"><img src="Array" alt="Defining Life Cycle of Thread" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/define-servletoutputstream/" title="Define ServletOutputStream"><img src="Array" alt="Define ServletOutputStream" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/define-array-in-java/" title="Define Array in Java"><img src="Array" alt="Define Array in Java" /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/write-a-note-on-ejb-frame-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Define Transaction Isolation in EJB</title>
		<link>http://www.bestjavainterviewquestions.com/define-transaction-isolation-in-ejb/</link>
		<comments>http://www.bestjavainterviewquestions.com/define-transaction-isolation-in-ejb/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 13:06:22 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Ejb Interview Questions]]></category>
		<category><![CDATA[transaction isolation]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=176</guid>
		<description><![CDATA[Q) What are transaction isolation levels in EJB? A) 1. Transaction_read_uncommitted- Allows a method to read uncommitted data from a DB(fast but not wise). 2. Transaction_read_committed- Guarantees that the data you are getting has been committed. 3. Transaction_repeatable_read &#8211; Guarantees that all reads of the database will be the same during the transaction (good for [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Q) What are transaction isolation levels in EJB? </strong></p>
<p><strong>A)</strong></p>
<p><strong></strong>1. Transaction_read_uncommitted- Allows a method to read uncommitted data from a DB(fast but not wise).<br />
2. Transaction_read_committed- Guarantees that the data you are getting has been committed.<br />
3. Transaction_repeatable_read &#8211; Guarantees that all reads of the database will be the same during the transaction (good for read and update operations).<br />
4. Transaction_serializable- All the transactions for resource are performed serial.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/awt-interview-questions-3/" title="AWT Interview Questions"><img src="Array" alt="AWT Interview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/define-static-keyword/" title="Define Static Keyword"><img src="Array" alt="Define Static Keyword" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/using-serialization/" title="Using Serialization "><img src="Array" alt="Using Serialization " /></a></li><li><a href="http://www.bestjavainterviewquestions.com/cookie-examples/" title="Cookie Examples"><img src="Array" alt="Cookie Examples" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/connecting-our-classsay-x-to-database-using-hibernate/" title="Connecting our Class(say x) to DataBase using Hibernate"><img src="Array" alt="Connecting our Class(say x) to DataBase using Hibernate" /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/define-transaction-isolation-in-ejb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Define Local Interfaces</title>
		<link>http://www.bestjavainterviewquestions.com/define-local-interfaces/</link>
		<comments>http://www.bestjavainterviewquestions.com/define-local-interfaces/#comments</comments>
		<pubDate>Sun, 24 Aug 2008 13:02:28 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Ejb Interview Questions]]></category>
		<category><![CDATA[local interfaces]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=173</guid>
		<description><![CDATA[Q) What are Local Interfaces? Describe. A) EJB was originally designed around remote invocation using the Java Remote Method Invocation (RMI) mechanism, and later extended to support to standard CORBA transport for these calls using RMI/IIOP. This design allowed for maximum flexibility in developing applications without consideration for the deployment scenario, and was a strong [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Q) What are Local Interfaces? Describe.</strong><br />
<strong>A) </strong>EJB was originally designed around remote invocation using the Java Remote Method Invocation (RMI) mechanism, and later extended to support to standard CORBA transport for these calls using RMI/IIOP. This design allowed for maximum flexibility in developing applications without consideration for the deployment scenario, and was a strong feature in support of a goal of component reuse in J2EE. Many developers are using EJBs locally, that is, some or all of their EJB calls are between beans in a single container. With this feedback in mind, the EJB 2.0 expert group has created a local interface mechanism. The local interface may be defined for a bean during development, to allow streamlined calls to the bean if a caller is in the same container. This does not involve the overhead involved with RMI like marshalling etc. This facility will thus improve the performance of applications in which co-location is planned. Local interfaces also provide the foundation for container-managed relationships among entity beans with container-managed persistence.</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/define-jarwarear-file/" title="Define Jar,War,Ear file"><img src="Array" alt="Define Jar,War,Ear file" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/jsf-important-questions/" title="JSF Important Questions"><img src="Array" alt="JSF Important Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/what-is-thread-how-to-use-threads/" title="What is Thread, How to Use Threads?"><img src="Array" alt="What is Thread, How to Use Threads?" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/awt-interview-questions-3/" title="AWT Interview Questions"><img src="Array" alt="AWT Interview Questions" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/some-important-methos-in-applets/" title="Some important methos in Applets"><img src="Array" alt="Some important methos in Applets" /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/define-local-interfaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EJB INTERVIEW QUESTIONS</title>
		<link>http://www.bestjavainterviewquestions.com/ejb-interview-questions/</link>
		<comments>http://www.bestjavainterviewquestions.com/ejb-interview-questions/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 15:59:07 +0000</pubDate>
		<dc:creator>Ramakrishna</dc:creator>
				<category><![CDATA[Ejb Interview Questions]]></category>

		<guid isPermaLink="false">http://www.bestjavainterviewquestions.com/?p=38</guid>
		<description><![CDATA[EJB INTERVIEW QUESTIONS AND ANSWERS Q) What are Enterprise Java Beans? A) Enterprise Java Beans (EJB) is a specification which defines a component architecture for developing distributed systems. Applications written using the Enterprise JavaBeans architecture are resusable,scalable, transactional, and secure. Enterprise Java Bean&#8217;s allow the developer to only focus on implementing the business logic of [...]]]></description>
			<content:encoded><![CDATA[<p><strong>EJB INTERVIEW QUESTIONS AND ANSWERS </strong></p>
<p><strong>Q) What are Enterprise Java Beans?<br />
A)</strong> Enterprise Java Beans (EJB) is a specification which defines a component architecture for developing distributed systems. Applications written using the Enterprise JavaBeans architecture are resusable,scalable, transactional, and secure. Enterprise Java Bean&#8217;s allow the developer to only focus on implementing the business logic of the application.</p>
<p><strong>Q) How many types of Enterprise beans are there and what are they?<br />
A) </strong>There are 3 types EJB&#8217;s and they are:<br />
1. Entity Bean&#8217;s<br />
2. Session Bean&#8217;s<br />
3. Message Driven Bean&#8217;s(MDB&#8217;s)<br />
<strong><br />
Q) How many types of Entity beans are there and what are they?<br />
A)</strong> There are 2 types Entity bean&#8217;s and they are:<br />
1. Container Managed Persistence(CMP) Entity Bean&#8217;s<br />
2. Bean Managed Persistence(BMP) Entity Bean&#8217;s</p>
<p><strong>Q) How many types of Session beans are there and what are they?<br />
A)</strong> There are 2 types Session bean&#8217;s and they are:<br />
1. Statefull Session Bean&#8217;s<br />
2. Stateless Session Bean&#8217;s</p>
<p><strong>Q) How many types of MDB&#8217;s are there and what are they?<br />
A)</strong> There are no different kinds of Message driven beans.</p>
<p><strong>Q) How is a enterprise bean different from a java bean?<br />
A)</strong> Both the enterprise bean and the java bean are designed to be highly reusable. But other than being reusable there is no similarity between them. Java bean is mostly a simple client-side component whereas enterprise bean is a complex server side component.</p>
<p><strong>Q) How many java files should a developer code to develop a session bean?<br />
A)</strong><br />
3  java files has to be provided by the developer. They are:<br />
1) an Home Interface<br />
2) a Remote Interface<br />
3) And a Session Bean implementation class.</p>
<p><strong>Q) Explain the role of Home Interface.<br />
A)</strong> Home interface contains factory methods for locating, creating and removing instances of EJB&#8217;s.</p>
<p><strong>Q) Explain the role of Remote Interface.<br />
A)</strong> Remote interface defines the business methods callable by a client. All methods defined in the remote interface must throw RemoteException.</p>
<p><strong>Q) What is the need for a separate Home interface and Remote Interface. Can&#8217;t they be defined in one interface?<br />
A)</strong> EJB doesn&#8217;t allow the client to directly communicate with an enterprise bean. The client has to use home and remote interfaces for any communication with the bean.<br />
The Home Interface is for communicating with the container for bean&#8217;s life cycle operations like creating, locating,removing one or more beans. While the remote interface is used for remotely accessing the business methods.</p>
<p><strong>Q) What are callback methods?<br />
A) </strong>Callback methods are bean&#8217;s methods, which are called by the container. These are called to notify the bean, of it&#8217;s life cycle events.<br />
<strong><br />
Q) How will you make a session bean as stateful or stateless?<br />
A) </strong>We have to specify the it in the deployment descriptor(ejb-jar.xml) using &lt;session-type&gt; tag.<br />
<strong><br />
Q) What is meant by Activation?<br />
A)</strong> The process of transferring an enterprise bean from secondary storage to memory.</p>
<p><strong>Q) What is meant by Passivation?<br />
A)</strong> The process of transferring an enterprise bean from memory to secondary storage.</p>
<p><strong>Q) What is a re-entrant Entity Bean?<br />
A)</strong> An re-entrant Entity Bean is one that can handle multiple simultaneous, interleaved, or nested invocations which will not interfere with each other.</p>
<p><strong>Q) Why are ejbActivate() and ejbPassivate() included for stateless session bean even though they are never required as it is a nonconversational bean?<br />
A)</strong> To have a consistent interface, so that there is no different interface that you need to implement for Stateful Session Bean and Stateless Session Bean. 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.<br />
<strong><br />
Q) What is an EJBContext?<br />
A)</strong> EJBContext is an object that allows an enterprise bean to invoke services provided by the container and to obtain the information about the caller of a client-invoked method.</p>
<p><strong>Q) Explain the role of EJB Container?<br />
A)</strong> EJB Container implements the EJB component contract of the J2EE architecture. It provides a runtime environment for enterprise beans that includes security, concurrency, life cycle management, transactions, deployment, naming, and other services. An EJB Container is provided by an EJB Server.</p>
<p><strong>Q) What are Entity Bean&#8217;s?<br />
A)</strong> Entity Bean is an enterprise bean that represents persistent data maintained in a database. An entity bean can manage its own persistence or can delegate this function to its container. An entity bean is identified by a primary key. If the container in which an entity bean is hosted crashes, the entity bean, its primary key, and any remote references survive the crash.<br />
<strong><br />
Q) What is a Primary Key?<br />
A) </strong>Primary Key is an object that uniquely identifies an entity bean within a home.</p>
<p><strong>Q) Can we specify primitive data type be as a primary key?<br />
A) </strong>Primitive data type cannot be directly used as primary key, it should be wrapped using a wrapper class.</p>
<p><strong>Q) What is a Deployment Descriptor?<br />
A) </strong>Deployment Descriptor is a XML file provided with each module and application that describes how they should be deployed. The deployment descriptor directs a deployment tool to deploy a module or application with specific container options and describes specific configuration requirements that a deployer must resolve.<br />
<strong><br />
Q) What are the new features that were introduced in EJB version 2.0 specification?<br />
A)</strong><br />
1. New CMP Model. It is based on a new contract called the abstract persistence schema, that will allow to the container to handle the persistence automatically at runtime.<br />
2. EJB Query Language. It is a sql-based language that will allow the new persistence schema to implement and execute finder methods.<br />
3. Message Driven Beans. It is a new bean type, that is introduced to handle asynchronous messaging.<br />
4. Local interfaces. Enabales beans in the same EJB Container to communicate directly.<br />
5. ejbHome methods. Entity beans can declare ejbHome methods that perform operations related to the EJB component but that are not specific to a bean instance.<br />
<strong><br />
Q) What are the difference&#8217;s between a Local Interface and a Remote Interface?<br />
A)</strong> Local Interfaces are new mechanism introduced in EJB 2.0 specification which enables components in the same container to bypass RMI and call each other&#8217;s methods directly. In general, direct local method calls are faster than remote method calls. The downside is a loss of flexibility: because bean and client must run in the same container, the location of the bean is not transparent to the client (as it is with remote interfaces). remote interfaces pass parameters by value, while local interfaces pass them by reference.<br />
<strong><br />
Q) Can a bean be defined both as a Local and a Remote?<br />
A)</strong> Yes.</p>
<p><strong>Q) What are ejbHome methods or Home Business Methods?<br />
A)</strong> EJB 2.0 allows entity beans to declare ejbHome methods in the home interface. These methods perform operations that are not specific to a particular bean instance.</p>
<p><strong>Q) What is a transaction?<br />
A)</strong> A transaction is a sequence of operations that must all complete successfully, or leave system in the state it had been before the transaction started.<br />
<strong><br />
Q) What do mean by ACID properties of a transaction?<br />
A) </strong>ACID is the acronym for the four properties guaranteed by transactions: atomicity, consistency, isolation, and durability.<br />
<strong><br />
Q) Where will you mention whether the transaction is container managed or bean managed?<br />
A)</strong> Transaction management is specified in the deployment descriptor(ejb-jar.xml) using &lt;transaction-type&gt; tag.<br />
<strong><br />
Q) What are container managed transactions?<br />
A)</strong> In an enterprise bean with container-managed transactions, the EJB container sets the boundaries of the transactions. You can use container-managed transactions with any type of enterprise bean: session, entity, or message-driven. Container-managed transactions simplify development because the enterprise bean code does not explicitly mark the transaction&#8217;s boundaries. The code does not include statements that begin and end the transaction.<br />
<strong><br />
Q) What methods are restricted being called inside a method decalred as container managed?<br />
A)</strong> We should not invoke any method that might interfere with the transaction boundaries set by the container. The list of restricted methods are as follows:<br />
1) The commit, setAutoCommit, and rollback methods of java.sql.Connection<br />
2) The getUserTransaction method of javax.ejb.EJBContext<br />
3) Any method of javax.transaction.UserTransaction<br />
<strong><br />
Q) What are bean managed transactions?<br />
A)</strong> For bean-managed transactions, the bean specifies transaction demarcations using methods in the javax.transaction.UserTransaction interface. Bean-managed transactions include any stateful or stateless session beans with a transaction-type set to Bean. Entity beans cannot use bean-managed transactions.<br />
For stateless session beans, the entering and exiting transaction contexts must match. For stateful session beans, the entering and exiting transaction contexts may or may not match. If they do not match, EJB container maintains associations between the bean and the nonterminated transaction.<br />
Session beans with bean-managed transactions cannot use the setRollbackOnly and getRollbackOnly methods of the javax.ejb.EJBContext interface.<br />
<strong><br />
Q) What is the difference between container managed and bean managed transaction?<br />
A)</strong> In container-managed transaction, the transaction boundaries are defined by the container while in bean managed transaction, the transaction boundaries are defined by the bean. Entity Beans transactions are always container managed.<br />
<strong><br />
Q) Why entity bean&#8217;s transaction can&#8217;t be managed by the bean?<br />
A) </strong>Entity bean&#8217;s represent the data and responsible for the integrity of the data. Entity bean&#8217;s doesn&#8217;t represent business operations to manage transactions. So there is no requirement for an entity bean managing it&#8217;s transaction.<br />
<strong><br />
Q) How many types of transaction attributes are available in EJB and what are they?<br />
A)</strong> There 6 types of Transaction Atributes defined in EJB. They are as follows:<br />
1. NotSupported : If the method is called within a transaction, this transaction is suspended during the time of the method execution.<br />
2. Required : If the method is called within a transaction, the method is executed in the scope of this transaction; otherwise, a new transaction is started for the execution of the method and committed before the method result is sent to the caller.<br />
3. RequiresNew : The method will always be executed within the scope of a new transaction. The new transaction is started for the execution of the method, and committed before the method result is sent to the caller. If the method is called within a transaction, this transaction is suspended before the new one is started and resumed when the new transaction has completed.<br />
4. Mandatory: The method should always be called within the scope of a transaction, else the container will throw the TransactionRequired exception.<br />
5. Supports : The method is invoked within the caller transaction scope; if the caller does not have an associated transaction, the method is invoked without a transaction scope.<br />
6. Never : The client is required to call the bean without any transaction context; if it is not the case, a java.rmi.RemoteException is thrown by the container.<br />
<strong><br />
Q)  Are we allowed to change the transaction isolation property in middle of a transaction?<br />
A) </strong>No. You cannot change the transaction isolation level in the middle of transaction.<br />
<strong><br />
Q) Are enterprise beans allowed to use Thread.sleep()?<br />
A) </strong>Enterprise beans are restricted from invoking multithreading thread functionality.<br />
<strong><br />
Q)  Can a bean be attached to more than one JNDI name?<br />
A)</strong> Yes. A same bean can be deployed multiple times in the same server with different JNDI names.<br />
<strong><br />
Q) Can a client program directly access an Enterprise bean?<br />
A) </strong>No. EJB Clients never access an EJB directly. The container insulates the beans from direct access from client applications. Every time a bean is requested, created, or deleted, the container manages the whole process.</p>
<p><strong>Q)  When is an application said to be distributed?<br />
A)</strong> An application is distributed when its components are running in separate runtime environments(JVM&#8217;s), usually on different platforms connected via a network.<br />
Distributed applications are usually of 3 types. They are :<br />
1. two tier (client and a server)<br />
2.three tier (client and a middleware and a server)<br />
3. multitier (client and multiple middleware and multiple servers).</p>
<p><strong>Q) What is an EAR file?<br />
A)</strong> EAR is Enterprise Archive file. A archive file that contains a J2EE application.<br />
<strong><br />
Q) What do mean by business method?<br />
A)</strong> A method of an enterprise bean that implements the business logic or rules of an application.</p>
<p><strong>Q) What is a finder method?<br />
A)</strong> A method defined in the home interface and invoked</p>
<h2  class="related_post_title">Random Posts</h2><ul class="related_post"><li><a href="http://www.bestjavainterviewquestions.com/mapping-files-in-hibernate/" title="Mapping Files in Hibernate"><img src="Array" alt="Mapping Files in Hibernate" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/difference-between-sessionsave-and-sessionsaveorupdate-4/" title="Difference between session.save() and session.saveOrUpdate()"><img src="Array" alt="Difference between session.save() and session.saveOrUpdate()" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/what-is-port-number/" title="What is Port Number"><img src="Array" alt="What is Port Number" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/define-jsp-include-and-jsp-forward/" title="Define Jsp-include and Jsp-forward"><img src="Array" alt="Define Jsp-include and Jsp-forward" /></a></li><li><a href="http://www.bestjavainterviewquestions.com/difference-between-sessionsave-sessionsaveorupdate-and-sessionpersist/" title="Difference between session.save() , session.saveOrUpdate() and session.persist()"><img src="Array" alt="Difference between session.save() , session.saveOrUpdate() and session.persist()" /></a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.bestjavainterviewquestions.com/ejb-interview-questions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
