{"id":516,"date":"2011-08-12T20:36:00","date_gmt":"2011-08-12T17:36:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/basic-ejb-references-injection-and-lookup.html"},"modified":"2012-11-01T22:25:07","modified_gmt":"2012-11-01T20:25:07","slug":"basic-ejb-references-injection-and","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html","title":{"rendered":"Basic EJB References, Injection and Lookup"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">In the <a href=\"http:\/\/www.javacodegeeks.com\/2011\/08\/introduction-to-ejb-30-injection-and.html\">first part<\/a> of this series we&#8217;ve introduced the mechanisms provided by the <a href=\"http:\/\/jcp.org\/en\/jsr\/detail?id=220\">Enterprise JavaBeans v. 3.0 Specification<\/a> to define EJB components, declare a reference to an EJB and wiring them up both by dependency injection or programmatic JNDI lookup.<\/p>\n<p>In this blog post we&#8217;ll examine some basic examples to understand how to use the EJB API.<\/p>\n<p><strong><span class=\"Apple-style-span\" style=\"font-size: large\">A Basic EJB<\/span><\/strong><\/p>\n<p>An EJB is basically a POJO with some extra EJB metadata. The required metadata to deploy it as an EJB component can be provided both by using the EJB annotations or by the standard deployment descriptor. The following class implements a very basic stateless session EJB:<\/p>\n<pre class=\"brush:java\">package es.reacts;\r\n\r\nimport javax.ejb.Stateless;\r\n\r\n@Stateless(name = \"UniqueLocalSessionEJB\")\r\npublic class UniqueLocalSessionEJBBean implements UniqueLocalBusinessInterface {\r\n   public UniqueLocalSessionEJBBean() {\r\n   }\r\n\r\n   public String sayLocalHello() {\r\n    return this.getClass().getName() + \"::\" + \"Local hello.\";\r\n   }\r\n}<\/pre>\n<p>As you may recollect from our previous blog post, the <i>@Stateless<\/i> annotation is used to define a <i>stateless<\/i> session bean. The optional <i>name<\/i> element is used to define the session bean <i>name<\/i>. This element is analogous to the &lt;ejb-name\/&gt; element of the standard deployment descriptor. This element defaults to the <i>unqualified<\/i> name of the bean class (<i>UniqueLocalSessionEJBBean<\/i> in the example above), and the example above uses it to rename the bean to <i>UniqueLocalSessionEJB<\/i>.<\/p>\n<p>Since we&#8217;re using the <i>@Stateless<\/i> annotation, there&#8217;s no further need to declare the EJB in the deployment descriptor.<\/p>\n<p>In this example, we&#8217;re assuming that the EJB is packaged in an EJB module that depends on the module containing the definition of its business interface (as explained in the following section.)<\/p>\n<p><strong>Business interfaces<\/strong><\/p>\n<p>Every EJB implements one or more business interfaces. Business interfaces can be <i>local<\/i> or <i>remote<\/i>. The most important differences between the two types of business interfaces can be summarized as follows:<\/p>\n<ul style=\"text-align: left\">\n<li>Local business interfaces use pass-by-reference semantics for their methods and method invocations cannot cross the JVM boundary. Local business interfaces are available only to callers in the same application and JVM instance of the callee.<\/li>\n<li>Remote business interfaces use pass-by-value semantics for their methods and method invocations can cross the JVM boundary. Remote business interfaces are available to callers outside the application of the callee.<\/li>\n<\/ul>\n<p>In the previous example, the business interface <i>UniqueLocalBusinessInterface<\/i> is declared as follows:<\/p>\n<pre class=\"brush:java\">package es.reacts;\r\n\r\nimport javax.ejb.Local;\r\n\r\n@Local\r\npublic interface UniqueLocalBusinessInterface {\r\n   String sayLocalHello();\r\n}\r\n<\/pre>\n<p>In the EJB v. 3.0 world a business interface is just a plain old Java interface annotated with either the <i>@Local<\/i> or <i>@Remote<\/i> annotation.<\/p>\n<p><strong>Packaging Business Interfaces<\/strong><\/p>\n<p>In this example we&#8217;re assuming that the EJB business interface is packaged in a JAR file that the EJB module depends on. Since EJB clients only depend on an EJB business interface, it&#8217;s a good practice to package the business interfaces in a separate library in order to ease the interface distribution and to decouple them from their implementations.<\/p>\n<p><strong><span class=\"Apple-style-span\" style=\"font-size: large\">Injecting an EJB into a Java Servlet<\/span><\/strong><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Now that we&#8217;ve defined an EJB, we&#8217;re ready to use it from a servlet in a Java EE web module. Assuming that there&#8217;s only one EJB implemented the <i>UniqueLocalBusinessInterface<\/i> in our application, we can inject it using an empty <i>@EJB<\/i> annotation:<\/p>\n<pre class=\"brush:java\">package es.reacts;\r\n\r\nimport java.io.IOException;\r\nimport java.io.PrintWriter;\r\n\r\nimport javax.ejb.EJB;\r\n\r\nimport javax.servlet.*;\r\nimport javax.servlet.http.*;\r\n\r\npublic class ServletTest1 extends HttpServlet {\r\n  @EJB\r\n  UniqueLocalBusinessInterface lc;\r\n\r\n  public void doGet(HttpServletRequest request,\r\n   HttpServletResponse response)\r\n   throws ServletException, IOException {\r\n   [...]\r\n   lc.sayLocalHello();\r\n   [...]\r\n  }\r\n<\/pre>\n<p>The first thing to note is that the EJB is injected into our servlet by the application server since the bean interface alone is sufficient to identify the target EJB. In this case the <i>beanInterface<\/i> element of the <i>@EJB<\/i> annotation takes on its default value, as explained in our <a href=\"http:\/\/www.javacodegeeks.com\/2011\/08\/introduction-to-ejb-30-injection-and.html\">previous post<\/a>, that is the type of the injected field: <i>UniqueLocalBusinessInterface<\/i>. Since there&#8217;s just one EJB in the application that implements this business interface, the <i>lc<\/i> field of the servlet is injected with a reference to an instance of such a class.<\/p>\n<p>The second thing worth pointing out is that we&#8217;re injecting an EJB into a servlet field safely because the EJB is <i>stateless<\/i>. Since servlet are <i>stateless by default<\/i>, you should <strong>not<\/strong> inject stateful resources into servlet fields properties otherwise you may run into concurrency-related problems. If you needed to use a stateful EJB into a servlet, you should retrieve a reference by programmatic JNDI lookup since that will guarantee that a new instance is returned for every lookup operation.<\/p>\n<p>Let&#8217;s deploy and run our application and we&#8217;ll see that the servlet is injected its target EJB and the method invocation to the <i>sayLocalHello()<\/i> method of its business interface is carried out correctly.<\/p>\n<p>If we wanted to inject a reference to a remote interface the client code would not be affected. If you try and change the <i>UniqueLocalBusinessInterface<\/i> from <i>@Local<\/i> to <i>@Remote<\/i>, you&#8217;ll see that the servlet sees no change and continues to work correctly.<\/p>\n<p><strong>What Happens If More Than One EJB Implements the Same Interface?<\/strong><\/p>\n<p>Let&#8217;s suppose that the we add another EJB in our EJB module in this application that implements the same interface as the previous one, <i>UniqueLocalBusinessInterface<\/i>. In this case, since the bean interface is not sufficient any longer to determine the target bean for injection, you&#8217;ll be returned an error. Deploying such an application in the WebLogic Application Server, for example, results in the following error being thrown:<\/p>\n<pre class=\"brush:bash\">[08:46:25 PM] Caused by: weblogic.deployment.EnvironmentException: [J2EE:160199]Error resolving ejb-ref 'es.reacts.ServletTest1\/lc1' from module 'WebTest0' of application 'EJBTestApp'. The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because multiple EJBs in the application were found to implement the 'es.reacts.UniqueLocalBusinessInterface' interface. Please specify a qualified ejb-link for this ejb-ref to indicate which EJB is the target of this ejb-ref.\r\n<\/pre>\n<p><strong>Injecting a Reference to a Specific EJB Instance<\/strong><\/p>\n<p>To solve the problem occurred in the previous section we need to provide the application server with the required information to identify the target EJB. As explained in our <a href=\"http:\/\/www.javacodegeeks.com\/2011\/08\/introduction-to-ejb-30-injection-and.html\">previous post<\/a>, we can use the following two methods:<\/p>\n<ul style=\"text-align: left\">\n<li>Either we use the <i>name<\/i> element of the <i>@EJB<\/i> annotation (or the corresponding &lt;ejb-ref-name\/&gt; element of the deployment descriptor) to declare an EJB reference in the private namespace of the application and link it to the target bean using the deployment descriptor.<\/li>\n<li>Or we use the <i>beanName<\/i> element of the <i>@EJB<\/i> annotation (or the corresponding &lt;ejb-link\/&gt; element of the deployment descriptor) to do it directly in our code.<\/li>\n<\/ul>\n<p><strong>Mapping an EJB into the Private Namespace<\/strong><\/p>\n<p>Using the first method we&#8217;ll end up with the following code in our servlet:<\/p>\n<pre class=\"brush:java\">@EJB(name = \"ejb\/bean-name\")\r\nUniqueLocalBusinessInterface lc;\r\n<\/pre>\n<p>and the following element in the deployment descriptor (web.xml) of our Java EE web module that acts as an EJB client:<\/p>\n<pre class=\"brush:xml\">&lt;ejb-local-ref&gt;\r\n  &lt;ejb-ref-name&gt;ejb\/bean-name&lt;\/ejb-ref-name&gt;\r\n  &lt;ejb-ref-type&gt;Session&lt;\/ejb-ref-type&gt;\r\n  &lt;local&gt;es.reacts.UniqueLocalBusinessInterface&lt;\/local&gt;\r\n  &lt;ejb-link&gt;UniqueLocalSessionEJB&lt;\/ejb-link&gt;\r\n&lt;\/ejb-local-ref&gt;\r\n<\/pre>\n<p>The &lt;ejb-link\/&gt; element contains the bean name that we defined at the beginning of our example with the annotation:<\/p>\n<pre class=\"brush:java\">@Stateless(name = \"UniqueLocalSessionEJB\")\r\n<\/pre>\n<p>in the EJB implementation class.<\/p>\n<p>Please note that, in this example, we used the <i>@EJB<\/i> <i>name<\/i> element explicitely but we could have established the link using its default value. The default value of the <i>name<\/i> element is:<\/p>\n<p>[qualified class name]\/[property or field name]<\/p>\n<p>that, in this case, would be:<\/p>\n<p>es.reacts.ServletTest1\/lc<\/p>\n<p>The disadvantage of using the default auto-generated name together with EJB linking using &lt;ejb-link\/&gt; is that every time you refactor your code you&#8217;ll have to check the deployment descriptors. Although developers sometimes think otherwise, the Java EE Specification defines some other roles such as the assambler and the deployer. In large corporate environments, it&#8217;s not uncommon for such profiles to override developers&#8217; annotations to &#8220;plumb&#8221; the components used by the applications. Annotation override is one of the reasons why standard deployment descriptors still exist. This is especially true when references are to remote components, inside or outside your application. For this reason I suggest you do <strong>not<\/strong> rely on auto-generated names and use custom <i>well documented<\/i> names instead.<\/p>\n<p><strong>Linking an EJB to a Reference in the Private Namespace<\/strong><\/p>\n<p>The second method provides a direct way to link the reference to its target bean using the <i>beanName<\/i> element of the <i>@EJB<\/i> annotation. The servlet code will use the following EJB reference:<\/p>\n<pre class=\"brush:java\">@EJB(beanName = \"UniqueLocalSessionEJB\")\r\nUniqueLocalBusinessInterface lc;\r\n<\/pre>\n<p>and we need no additional information in the deployment descriptor.<\/p>\n<p>Although this method allows the developer to link a reference to an EJB without relying on the deployment descriptor, the suggestion given at the end of the previous section is still valid. Remember that annotations can be overridden at deployment time! Do not link an EJB to a reference if you know beforehand that such a reference is eligible for override. In such cases, prefer assigning a name to the reference instead, as explained in the previous section. <\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/thegreyblog.blogspot.com\/2010\/09\/basic-ejb-references-injection-and.html\">Basic EJB References, Injection and Lookup<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> <a href=\"http:\/\/www.blogger.com\/profile\/02688166348157974808\">Grey<\/a> at the <a href=\"http:\/\/thegreyblog.blogspot.com\/\">The Grey Blog<\/a>.<\/p>\n<div style=\"margin: 0px\"><strong><i>Related Articles :<\/i><\/strong><\/div>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/08\/introduction-to-ejb-30-injection-and.html\">An Introduction to EJB 3.0 Injection and Lookup<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/08\/ejb-programmatic-lookup.html\">EJB Programmatic Lookup<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/08\/references-to-ejbs-outside-your.html\">References to EJBs Outside Your Application With Oracle WebLogic<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/08\/ejb-31-global-jndi-access.html\">EJB 3.1 Global JNDI Access<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/gwt-ejb3-maven-jboss-51-integration.html\">GWT EJB3 Maven JBoss 5.1 integration tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/04\/java-generics-quick-tutorial.html\">Java Generics Quick Tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/05\/how-jvm-handle-locks.html\">How does JVM handle locks<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In the first part of this series we&#8217;ve introduced the mechanisms provided by the Enterprise JavaBeans v. 3.0 Specification to define EJB components, declare a reference to an EJB and wiring them up both by dependency injection or programmatic JNDI lookup. In this blog post we&#8217;ll examine some basic examples to understand how to use &hellip;<\/p>\n","protected":false},"author":33,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[90,91],"class_list":["post-516","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-ejb","tag-ejb3"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Basic EJB References, Injection and Lookup - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In the first part of this series we&#039;ve introduced the mechanisms provided by the Enterprise JavaBeans v. 3.0 Specification to define EJB components,\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Basic EJB References, Injection and Lookup - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In the first part of this series we&#039;ve introduced the mechanisms provided by the Enterprise JavaBeans v. 3.0 Specification to define EJB components,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2011-08-12T17:36:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-11-01T20:25:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Enrico Crisostomo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Enrico Crisostomo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html\"},\"author\":{\"name\":\"Enrico Crisostomo\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cec28099825885634aaa9560f8c3f1dc\"},\"headline\":\"Basic EJB References, Injection and Lookup\",\"datePublished\":\"2011-08-12T17:36:00+00:00\",\"dateModified\":\"2012-11-01T20:25:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html\"},\"wordCount\":1366,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"keywords\":[\"EJB\",\"EJB3\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html\",\"name\":\"Basic EJB References, Injection and Lookup - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2011-08-12T17:36:00+00:00\",\"dateModified\":\"2012-11-01T20:25:07+00:00\",\"description\":\"In the first part of this series we've introduced the mechanisms provided by the Enterprise JavaBeans v. 3.0 Specification to define EJB components,\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"java-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/08\\\/basic-ejb-references-injection-and.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Basic EJB References, Injection and Lookup\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cec28099825885634aaa9560f8c3f1dc\",\"name\":\"Enrico Crisostomo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1409f69f72e12da95325275f8deb51ba603e158b4464ca3565c814454ee92e5d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1409f69f72e12da95325275f8deb51ba603e158b4464ca3565c814454ee92e5d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1409f69f72e12da95325275f8deb51ba603e158b4464ca3565c814454ee92e5d?s=96&d=mm&r=g\",\"caption\":\"Enrico Crisostomo\"},\"sameAs\":[\"http:\\\/\\\/thegreyblog.blogspot.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Enrico-Crisostomo\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Basic EJB References, Injection and Lookup - Java Code Geeks","description":"In the first part of this series we've introduced the mechanisms provided by the Enterprise JavaBeans v. 3.0 Specification to define EJB components,","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html","og_locale":"en_US","og_type":"article","og_title":"Basic EJB References, Injection and Lookup - Java Code Geeks","og_description":"In the first part of this series we've introduced the mechanisms provided by the Enterprise JavaBeans v. 3.0 Specification to define EJB components,","og_url":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-08-12T17:36:00+00:00","article_modified_time":"2012-11-01T20:25:07+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Enrico Crisostomo","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Enrico Crisostomo","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html"},"author":{"name":"Enrico Crisostomo","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cec28099825885634aaa9560f8c3f1dc"},"headline":"Basic EJB References, Injection and Lookup","datePublished":"2011-08-12T17:36:00+00:00","dateModified":"2012-11-01T20:25:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html"},"wordCount":1366,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","keywords":["EJB","EJB3"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html","url":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html","name":"Basic EJB References, Injection and Lookup - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2011-08-12T17:36:00+00:00","dateModified":"2012-11-01T20:25:07+00:00","description":"In the first part of this series we've introduced the mechanisms provided by the Enterprise JavaBeans v. 3.0 Specification to define EJB components,","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","width":150,"height":150,"caption":"java-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2011\/08\/basic-ejb-references-injection-and.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Basic EJB References, Injection and Lookup"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cec28099825885634aaa9560f8c3f1dc","name":"Enrico Crisostomo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1409f69f72e12da95325275f8deb51ba603e158b4464ca3565c814454ee92e5d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1409f69f72e12da95325275f8deb51ba603e158b4464ca3565c814454ee92e5d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1409f69f72e12da95325275f8deb51ba603e158b4464ca3565c814454ee92e5d?s=96&d=mm&r=g","caption":"Enrico Crisostomo"},"sameAs":["http:\/\/thegreyblog.blogspot.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Enrico-Crisostomo"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=516"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/516\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/112"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}