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
Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
"MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Large industrial manufacturing organizations are adopting the agile principles of cloud software companies. The industrial manufacturing development process has not scaled over time. Now that design CAD teams are geographically distributed, centralizing their work is key. With large multi-gigabyte projects, outdated tools have stifled industrial team agility, time-to-market milestones, and impacted P&L stakeholders.
"Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
In his session at 21st Cloud Expo, Carl J. Levine, Senior Technical Evangelist for NS1, will objectively discuss how DNS is used to solve Digital Transformation challenges in large SaaS applications, CDNs, AdTech platforms, and other demanding use cases. Carl J. Levine is the Senior Technical Evangelist for NS1. A veteran of the Internet Infrastructure space, he has over a decade of experience with startups, networking protocols and Internet infrastructure, combined with the unique ability to it...
"IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
"Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
"There's plenty of bandwidth out there but it's never in the right place. So what Cedexis does is uses data to work out the best pathways to get data from the origin to the person who wants to get it," explained Simon Jones, Evangelist and Head of Marketing at Cedexis, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
SYS-CON Events announced today that Evatronix 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. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
Leading companies, from the Global Fortune 500 to the smallest companies, are adopting hybrid cloud as the path to business advantage. Hybrid cloud depends on cloud services and on-premises infrastructure working in unison. Successful implementations require new levels of data mobility, enabled by an automated and seamless flow across on-premises and cloud resources. In his general session at 21st Cloud Expo, Greg Tevis, an IBM Storage Software Technical Strategist and Customer Solution Architec...
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
An increasing number of companies are creating products that combine data with analytical capabilities. Running interactive queries on Big Data requires complex architectures to store and query data effectively, typically involving data streams, an choosing efficient file format/database and multiple independent systems that are tied together through custom-engineered pipelines. In his session at @BigDataExpo at @ThingsExpo, Tomer Levi, a senior software engineer at Intel’s Advanced Analytics gr...