Welcome!

Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

EJB

EJB

This month, we'll study for the EJB portion of the BEA WebLogic Server 6.0 Certification Test.

Now, I know I was also supposed to talk about JDBC this month, but I just didn't have enough room to squeeze it in. EJB is by far the most widely covered topic on the test, and I didn't want to take any attention away from it. I'll be sure to cover JDBC next month.

Let me say it again: EJB is the biggest topic of the test. With that said, it should be the topic that you know best. I'll try to summarize the portions of EJB that you should be familiar with. We'll start with the general interfaces you need to build EJBs.

For the purposes of the test, there are four primary interfaces to know when building Enterprise JavaBeans. These interfaces are the Remote interface, the Home interface, the MessageListener interface, and the implementation class interface.

To implement the Remote interface, you need to implement the EJBObject interface. The aptly named EJBHome interface must be implemented to create the Home interface. The MessageListener interface is used only for message-driven beans. It informs the bean that a message has been received from a JMS Queue or Topic. Since each type of EJB performs a different job, there are different types of interfaces for the implementation class interface. More details about how all of these interfaces work for each type of EJB are discussed below.

Entity Beans
You'll create the Remote interface by extending EJBObject. The Remote interface should primarily reflect your business methods in the implementation class. All Remote interface methods must be defined as throwing RemoteException.

Create the Home interface by extending EJBHome. Please note: you must provide a findByPrimaryKey() method and may provide zero or more createXXX() or findXXX() methods (where XXX is anything).

In order to create the implementation class, you must implement the EntityBean interface. You must make sure the class is public - not marked as static, final, or abstract - and does not contain a finalizer method. The class must provide an implementation of every method listed in the Remote interface and an ejbFindByPrimaryKey() method that corresponds to the findByPrimaryKey() method in the Home interface. In addition, it must provide an implementation of every creation and finder method listed in the Home interface. Be sure to review Table 1, which lists some entity bean methods of note.

Stateless Session Beans
As with entity beans, create the Remote interface by extending EJBObject. The Remote interface should primarily reflect your business methods and the methods must be defined as throwing RemoteException.

Create the Home interface by extending EJBHome. Please note: you must provide a create() method. This method must not contain any input parameters and cannot be overloaded.

To create the implementation class, you must implement the SessionBean interface and make sure your class is public - not marked as static, final, or abstract - and doesn't contain a finalizer method. The class must provide an implementation of every method listed in the Remote interface and an ejbCreate() method that corresponds to the create() method in the Home interface. Table 2 lists some stateless session bean methods of note.

Stateful Session Beans
The Remote interface of a stateful session bean is constructed the same as a stateless session bean, but the Home interface is slightly different. You create the Home interface by extending EJBHome. Please note: you must provide at least one create() method; you may provide additional create methods, using the createXXX() syntax (where XXX is anything).

In order to create the implementation class, you must implement the SessionBean interface. Again, make sure the class is public, not marked as static, final or abstract. It should not contain a finalizer method and should provide an implementation of every business method listed in the Remote interface. The class should also contain an ejbCreateXXX() method that corresponds to each createXXX() method in the Home interface. Table 3 lists some stateful session bean methods you should know for the test.

Message-Driven Beans
If you're unfamiliar with message-driven beans, you just need to know that they're similar in function to a stateless session bean, yet the processing is done asynchronously. The business methods are executed based on messages received from a single JMS Queue or Topic. For more information on message-driven beans, see http://e-docs.bea.com/wls/docs60/ejb/message_beans.html.

Also, unlike the other EJBs, a message-driven bean doesn't have a Remote or Home interface, because it's never invoked directly by the client. Given this, the methods of a message-driven bean do not have return values or propagate exceptions back to the client.

The MessageListener interface provides the ability for the bean to realize that it has consumed a message. The onMessage() method takes an input of type Message, which can be a BytesMessage, ObjectMessage, TextMessage, StreamMessage, or MapMessage.

To create the implementation class, you must implement the MessageDrivenBean interface. As with all the other implementation classes, make sure the class is public - not marked as static, final, or abstract - and doesn't contain a finalizer method. Table 4 lists message-driven bean methods of importance.

EJB Exceptions
In studying for the test, you should know how different types of EJB exceptions are processed. The first thing to know is that application exceptions are propagated back to the caller, but the EJB container will intercept and handle a system exception. At this point, generally, the container will throw a RemoteException back to the caller. Table 5 lists the important exceptions used by EJB.

EJB Utility Classes
Several utility classes that you need to be familiar with are associated with EJBs.

The SessionContext interface allows the session bean to access properties of the EJB container. Understanding that SessionContext is passed into a Session Bean at creation time and is maintained until the bean is destroyed is important. Similarly, the EntityContext interface allows the entity bean to access properties of the EJB container. The EntityContext is passed into an entity bean at creation time and is maintained until the bean is destroyed.

The last utility class to know for the test is the SessionSynchronization interface. This interface notifies a session bean of important transaction-related events. Table 6 summarizes the events.

Deployment
You need to understand the EJB application file structure. The EJB application should contain the class (or java) files, the ejb-jar.xml file, and weblogic-ejb-jar.xml file.

The ejb-jar.xml and weblogic-ejb-jar.xml files must reside in the \META-INF subdirectory of the jar file. The class (or java) files should reside in the package-relative location. Table 7 shows the structure of an EJB application.

The ejb-jar.xml file contains a large number of deployment descriptors, which are important to know for the test. Some of these are listed in Table 8; a sample ejb-jar.xml file is shown in Listing 1.

The weblogic-ejb-jar.xml file contains more information about the EJBs being deployed. The information in this file is specific to WebLogic Server. Some important descriptors are listed in Table 9 and a sample file is shown in Listing 2.

Next month, I'll look at JDBC in addition to the transactions and clustering topics of the test. Before you take the sample test, though, I'd like to mention another resource to help you study for the test! Be sure to check out the BEA WebLogic Server 6.1 Bible; it can be used as a valuable study aid for the test.

Good luck on the test!

Sample Test
1. Which JMS acknowledgement mode increases message throughput by responding to messages when processor time is available?
a) DUPS_AUTO_ACKNOWLEDGE
b) DUPS_NO_ACKNOWLEDGE
c) DUPS_OK_ACKNOWLEDGE
d) DUPS_IMMED_ACKNOWLEDGE

2. An EJB created using EJB version 2.0 must throw what type of exception?
a) RemoteException
b) EJBException
c) NetworkException
d) None of the Above

3. Which interface are you most likely to use to retrieve properties of a session bean's EJB container?
a) SessionSynchronization
b) SessionContext
c) EJBContext
d) EJBContainer

4. What statement illustrates a difference between creating an entity bean and a session bean?
a) A session bean Home interface does not have a create method.
b) An entity bean does not have a Home interface.
c) An entity bean Home interface does not have a create method.
d) A session bean Home interface does not have any finder methods.

5. Which subdirectory does the ejb-jar.xml file reside in?
a) WEB-INF
b) META-INF
c) Application Directory
d) Root Directory

6. What is a good reason to use a message-driven bean instead of a session bean?
a) Asynchronous Processing
b) Synchronous Processing
c) Exceptions are not propagated to the client
d) Can consume messages from multiple Queues and Topics

7. What interface do you extend to create the EJB's remote interface?
a) EJBObject
b) EJBRemote
c) EJBHome
d) BeanRemote

8. What interface do you extend to create a stateful session bean's implementation class?
a) StatefulSessionBean
b) EJBObject
c) EJBHome
d) SessionBean

9. What interface do you extend to create a stateless session bean's implementation class?
a) StatelessSessionBean
b) EJBObject
c) EJBHome
d) SessionBean

10. What interfaces do you need to implement to build a message- driven bean?
a) ServerSessionPool and MessageBean
b) MessageDrivenBean and EJBObject
c) MessageListener and MessageDrivenBean
d) MessageListener and EJBObject

Answer Key
1. a, 2. b, 3. b, 4. d, 5. b, 6. a, 7. a, 8. d, 9. d, 10. C

More Stories By Dave Cooke

David Cooke is an experienced software developer, currently working for Ness Technologies, Inc. a consulting firm located in Dulles, VA. In his current position, Mr. Cooke utilizes Java and BEA WebLogic Server 6.0 to build J2EE-compliant e-commerce systems for a variety of clients. Mr. Cooke has a bachelor's degree in Computer Science from George Mason University and maintains Microsoft, Java and BEA developer certifications.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
Most technology leaders, contemporary and from the hardware era, are reshaping their businesses to do software. They hope to capture value from emerging technologies such as IoT, SDN, and AI. Ultimately, irrespective of the vertical, it is about deriving value from independent software applications participating in an ecosystem as one comprehensive solution. In his session at @ThingsExpo, Kausik Sridhar, founder and CTO of Pulzze Systems, will discuss how given the magnitude of today's applicati...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
In a recent survey, Sumo Logic surveyed 1,500 customers who employ cloud services such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP). According to the survey, a quarter of the respondents have already deployed Docker containers and nearly as many (23 percent) are employing the AWS Lambda serverless computing framework. It’s clear: serverless is here to stay. The adoption does come with some needed changes, within both application development and operations. Tha...
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, will lead you through the exciting evolution of the cloud. He'll look at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering ...
SYS-CON Events announced today that Taica will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TAZMO technology and development capabilities in the semiconductor and LCD-related manufacturing fields are among the best worldwide. For more information, visit https://www.tazmo.co.jp/en/.
SYS-CON Events announced today that Avere Systems, a leading provider of hybrid cloud enablement solutions, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Avere Systems was created by file systems experts determined to reinvent storage by changing the way enterprises thought about and bought storage resources. With decades of experience behind the company’s founders, Avere got its ...
SYS-CON Events announced today that TidalScale will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale is the leading provider of Software-Defined Servers that bring flexibility to modern data centers by right-sizing servers on the fly to fit any data set or workload. TidalScale’s award-winning inverse hypervisor technology combines multiple commodity servers (including their ass...
As hybrid cloud becomes the de-facto standard mode of operation for most enterprises, new challenges arise on how to efficiently and economically share data across environments. In his session at 21st Cloud Expo, Dr. Allon Cohen, VP of Product at Elastifile, will explore new techniques and best practices that help enterprise IT benefit from the advantages of hybrid cloud environments by enabling data availability for both legacy enterprise and cloud-native mission critical applications. By rev...
SYS-CON Events announced today that Ryobi Systems will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ryobi Systems Co., Ltd., as an information service company, specialized in business support for local governments and medical industry. We are challenging to achive the precision farming with AI. For more information, visit http:...
Amazon is pursuing new markets and disrupting industries at an incredible pace. Almost every industry seems to be in its crosshairs. Companies and industries that once thought they were safe are now worried about being “Amazoned.”. The new watch word should be “Be afraid. Be very afraid.” In his session 21st Cloud Expo, Chris Kocher, a co-founder of Grey Heron, will address questions such as: What new areas is Amazon disrupting? How are they doing this? Where are they likely to go? What are th...
High-velocity engineering teams are applying not only continuous delivery processes, but also lessons in experimentation from established leaders like Amazon, Netflix, and Facebook. These companies have made experimentation a foundation for their release processes, allowing them to try out major feature releases and redesigns within smaller groups before making them broadly available. In his session at 21st Cloud Expo, Brian Lucas, Senior Staff Engineer at Optimizely, will discuss how by using...
In this strange new world where more and more power is drawn from business technology, companies are effectively straddling two paths on the road to innovation and transformation into digital enterprises. The first path is the heritage trail – with “legacy” technology forming the background. Here, extant technologies are transformed by core IT teams to provide more API-driven approaches. Legacy systems can restrict companies that are transitioning into digital enterprises. To truly become a lead...
SYS-CON Events announced today that Daiya Industry will exhibit at the Japanese Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ruby Development Inc. builds new services in short period of time and provides a continuous support of those services based on Ruby on Rails. For more information, please visit https://github.com/RubyDevInc.
As businesses evolve, they need technology that is simple to help them succeed today and flexible enough to help them build for tomorrow. Chrome is fit for the workplace of the future — providing a secure, consistent user experience across a range of devices that can be used anywhere. In her session at 21st Cloud Expo, Vidya Nagarajan, a Senior Product Manager at Google, will take a look at various options as to how ChromeOS can be leveraged to interact with people on the devices, and formats th...
SYS-CON Events announced today that Yuasa System will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Yuasa System is introducing a multi-purpose endurance testing system for flexible displays, OLED devices, flexible substrates, flat cables, and films in smartphones, wearables, automobiles, and healthcare.
SYS-CON Events announced today that Taica will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Taica manufacturers Alpha-GEL brand silicone components and materials, which maintain outstanding performance over a wide temperature range -40C to +200C. For more information, visit http://www.taica.co.jp/english/.
Organizations do not need a Big Data strategy; they need a business strategy that incorporates Big Data. Most organizations lack a road map for using Big Data to optimize key business processes, deliver a differentiated customer experience, or uncover new business opportunities. They do not understand what’s possible with respect to integrating Big Data into the business model.
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, will discuss how they b...
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities – ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups. As a result, many firms employ new business models that place enormous impor...
SYS-CON Events announced today that Dasher Technologies will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Dasher Technologies, Inc. ® is a premier IT solution provider that delivers expert technical resources along with trusted account executives to architect and deliver complete IT solutions and services to help our clients execute their goals, plans and objectives. Since 1999, we'v...