Home » Tag Archives: EJB (page 2)

Tag Archives: EJB

Stateless EJBs: Pooling and Lifecycle

java-interview-questions-answers

A summarized view (notes) of the Stateless EJB pooling and life-cycle. Useful for newbies . . . . . EJB Pooling: Quick Overview EJB instances are stored in a location known as the EJB Pool – this is nothing but an in-memory cache. Stateless EJBs are generally instantiated on-demand i.e. as and when the client invokes a method on the ...

Read More »

EJB passivation and activation example

java-interview-questions-answers

In this tutorial we are going to see how activation and passivation works in a Stateful Java Enterprise Session Bean. 1. Introduction Stateful Session Beans usually hold information about a specific client, and holds that information throughout the whole session. It is a fact though, that client sessions tend to be active for a respectable amount of time, and of ...

Read More »

Java EE Stateful Session Bean (EJB) example

java-interview-questions-answers

In this article we are going to see how you can use Stateful Session Beans to keep track of state across a client Session in a simple Web Application. 1. Introduction Stateful Session Beans usually hold information about a specific client’s session, and holds that information throughout the whole session (opposed to Stateless Session Beans). A Stateful EJB instance is ...

Read More »

Java EE EJB Interceptors tutorial and example

java-interview-questions-answers

In this example we are going to see how to use Interceptors in an EJB and test it using a simple Web Application. 1. Introduction Interceptors are used, as the name suggests, when you want to intercept calls to EJB methods. If you declare an Interceptor for a Bean, every time a method of that Bean is invoked, it will ...

Read More »

JBoss AS7 JNDI & EJB 3.1 Naming changes

As a result of the “feature train” continuing to march on and us not keeping our software stack up-to-date, our team finds ourselves in the un-enviable position of having to migrate: JBoss 4.2.3 to AS 7.1.x (currently looking at 7.1.1) EJB 2.1 to EJB 3.1 Hibernate 2 to Hibernate 3 or 4 in quick fashion.  I mean, who wants to ...

Read More »

EJB Inheritance is Different From Java Inheritance

java-interview-questions-answers

Despite the fact that EJB inheritance sometimes uses Java inheritance — they’re not always the same. Just as you could read in my previous post, EJB doesn’t have to implement any interface to expose a business interface. The other way around is also true — just because EJB is implementing some interface or extending other EJB doesn’t mean it exposes ...

Read More »

Defining EJB 3.1 Views (Local, Remote, No-Interface)

java-interview-questions-answers

This post will talk about possible ways of defining EJB views using annotations (I’ll just mention about using EJB Deployment Descriptor at the end.) I’ll focus on the most current EJB 3.1 views omitting legacy local, remote and home interfaces. Therefore, we can choose between: remote business interface view, local business interface view, no-interface view. I won’t discuss functional differences ...

Read More »

Four solutions to the LazyInitializationException – Part 2

This article continues from part 1 of the tutorial. Load collection by Stateful EJB with PersistenceContextType.EXTENDED This approach can be applied only to applications that works with Full JEE environments: to use a EJB with PersistenceContextType.EXTENDED. Check the code below how the DAO would look like: package com.ejb; import javax.ejb.Stateful; import javax.persistence.*; import com.model.Person; @Stateful public class SystemDAOStateful { @PersistenceContext(unitName ...

Read More »

Four solutions to the LazyInitializationException – Part 1

In the post today we will talk about the common LazyInitializationException error. We will see four ways to avoid this error, the advantage and disadvantage of each approach and in the end of this post, we will talk about how the EclipseLink handles this exception. To see the LazyInitializationException error and to handle it, we will use an application JSF ...

Read More »