Skip to Content
author's profile photo Former Member
Former Member

JSF application with @EJB

I am creating Java application that uses JSF with @EJB injection. Does your server support that because I always get null for "userBeam" that is defined in @ManagedBean when I call loginBean.loginProject from xhtml file. If I call it from Webservlet then it works. I am using trial account.

Code example:

@ManagedBean(name = "loginBean")


public class LoginBean implements Serializable {

private static final long serialVersionUID = 1L;

private String password;

private String message, uname;


UserBeam userBeam;

public String getMessage() {

return message;


public void setMessage(String message) {

this.message = message;


public String getPassword() {

return password;


public void setPassword(String password) {

this.password = password;


public String getUname() {

return uname;


public void setUname(String uname) {

this.uname = uname;


public String loginProject() {

if (userBeam == null) <-- userBeam IS NULL


System.out.println("userBeam == null");


boolean result = userBeam.login(uname, password);


public String logout() {

HttpSession session = Util.getSession();


return "login";





public class UserBeam {


private static EntityManager em;

public List<User> getAllPersons() {


return em.createNamedQuery("AllUsers").getResultList();


public void addUser() {

User newUser = new User();










public boolean login(String user, String password) {

System.out.println("login(String user, String password)");

System.out.println("USER: " + user + " PASS: " + password );

return true;



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Nov 17, 2015 at 09:56 AM


    I cannot reproduce your scenario.

    I tried with your example and I received:

    login(String user, String password)

    USER: Vily PASS: G

    Is it possible to share with us your application so that we can check what might be the problem.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.