A session bean encapsulates business logic that can be invoked programmatically by a client over local, remote, or web service client views. More specifically, a stateless session bean does not maintain a conversational state with the client, so it is mostly used as a service(e.g. rest api, persistence-retrieval) and does specific job without the need of keeping a state.
Questions tagged [stateless-session-bean]
188 questions
2
votes
0 answers
How to get user name in session bean when redirected to error page?
Can anyone tell me how to get user name in session bean correctly? In our application we do it by calling this method:
@Resource
private EJBContext _context;
private String getUserName() {
return _context.getCallerPrincipal().getName();
}
And…

mykola
- 1,736
- 5
- 25
- 37
2
votes
2 answers
What are the advantages to using a Stateless Bean and DI instead of a POJO and Static Methods
Why would it be beneficial to use stateless beans and dependancy injection over just a simple pojo with static methods? In other words, are the advantages to an EJB purely because of the underlying container benefits like threading, transactions,…

FAtBalloon
- 4,500
- 1
- 25
- 33
2
votes
1 answer
Should MDB call remove() after using stateless session bean?
Our years-old WebLogic J2EE application has a message-driven bean which makes use of a stateless session bean. The MDB onMessage method gets the home interface of the stateless session bean and calls the home interface's create() method to get the…

Christopher Graziano
- 421
- 1
- 5
- 8
2
votes
1 answer
EJB Stateless Session Bean - could not create error
Let me start by pointing out that while I've been using Java SE for a while now this is my first foray into Java EE territory. I'm using Netbeans 6.9 and the Netbeans code generator to do most of the heavy lifting (more on this further down). The…

Insectatorious
- 1,305
- 3
- 14
- 29
2
votes
1 answer
can transaction span multiple business methods with stateless + transaction scoped persistence context
given that the default persistence context for EJB (including stateless) is TRANSACTION_SCOPED as I know, is the statement 'transaction can span multiple business methods with stateless bean' valid even if the persistence context is defaulted to…

osama yaccoub
- 1,884
- 2
- 17
- 47
2
votes
1 answer
How to split SFSB Facade?
I am having some problems devoloping an application based on EJB 3 technology.
I would like to use a Facade Pattern in the Session beans to decouple my client (a web application) from my Entity Beans.
I am using a SFSB to manage the user session.
So…

Andrea
- 3,627
- 4
- 24
- 36
2
votes
3 answers
java.lang.ClassCastException with the same class object
This piece of code irritates me,
sometimes it working and some other times it doesn't !
The NamedQuery : (name = "User.findByLogin", query = "SELECT u
FROM User u WHERE u.login = :login")
public User findByLogin(String login) {
Query…

bilelovitch
- 1,975
- 1
- 16
- 24
2
votes
2 answers
Is it possible to extract the original message body string (i.e., XML string or JSON string) within the "post()" method of a REST service?
QUESTION:
Is it possible to extract the original message body string (i.e., XML string or JSON string) - within the "post()" method - of a REST service?
Environment
Java 8
WebLogic 12.1.3 (w/ jax-rs(2.0,2.5.1) deployable library)
(The…

sairn
- 461
- 3
- 24
- 58
2
votes
1 answer
How to return values from a list in round robin in a multi threaded environment?
I have to write a code which involves making a web service call to a backend asynchronously and returning a toll free number in round robin from a list of TFNs to the caller. Below is my code
@Stateless
public class TollFreeServiceBean {
@EJB
…

Krishna Chaitanya
- 2,533
- 4
- 40
- 74
2
votes
0 answers
Dynamic and programmatic creation of EJB3 Session Beans
I have a use case where I want to create dynamically (=programmatically) a Stateless Session Bean (EJB3) instead of declaratively creating a Stateless bean through annotation (@Stateless).
Is there a way of telling the EJB container / CDI that my…

user2120188
- 427
- 1
- 4
- 16
2
votes
2 answers
EJB3 Caching Instance Variables
I've noticed some strange code on a project I am working on - its a SLSB EJB3, and it uses a private instance variable to maintain a cache of data (it even calls it dataCache or something), with a getter/setter. For EJB2 and bellow, this was a…

Justin
- 81
- 1
- 6
2
votes
2 answers
NullPointerException with @Inject and @PostPersist Method
After an entity is persisted, I want to execute a Bean, which sends a registration Mail to the newly registered user. I want to do this with a Listener class. I did the following:
Annotated the Entity with @EntityListener…

Rallenaldo
- 107
- 8
2
votes
1 answer
Java EE 6 + JPA - Exception: Message Driven Bean cant be managed bean
I create an Enterprise Application CustomerApp that also generated two projects CustomerApp-ejb and CustomerApp-war. In the CustomerApp-ejb, I create a SessionBean call CustomerSessionBean.java as below.
package com.customerapp.ejb;
import…

Thang Pham
- 38,125
- 75
- 201
- 285
2
votes
2 answers
Assign a pool to a specific stateless bean in JBoss EAP 6.1
I can see how one can control the size of the global pool for all the stateless session beans.
However, I would like to be able to have a new pool that only applies to one type of stateless bean. This way, all my stateless beans but one would be…

phoenix7360
- 2,807
- 6
- 30
- 41
2
votes
2 answers
Stateless session bean transactions
I am working on a JSF web application. The service layer is developed using stateless session beans. These stateless beans are injected to managed beans using CDI.
I know that to manage transactions in stateless beans, I can use either container…

Ani
- 722
- 9
- 27