Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7816455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:52:36+00:00 2026-06-02T05:52:36+00:00

I have a problem calling EJB object in struts action. I deployed my application

  • 0

I have a problem calling EJB object in struts action.

I deployed my application in glassfish, in application description of glassfish admin console I see that there is one StatelessSessionBean deployed. My application’s .ear file consist of .war (web module) and .jar (ejb), one message-driven, one session bean.

When I try to call session bean in struts action class I get nullpointer exception.

Here is my call:

@EJB
private AccountFacade accountFacade;

@Override
public ActionForward execute(ActionMapping mapping,
                             ActionForm form,
                             HttpServletRequest request,
                             HttpServletResponse response)
        throws Exception {
    UserCreationForm userCreationForm = (UserCreationForm) form;

    Account account = new Account();
    account.setName(userCreationForm.getName());
    account.setEmail(userCreationForm.getEmail());
    account.setPassword(userCreationForm.getPassword());

    accountFacade.create(account);

    return mapping.findForward(NavigationUtils.ACTION_SUCCESS);
}

Exception occurs at this line: accountFacade.create(account);

Account facade class looks like this:

@Stateless
public class AccountFacade extends AbstractFacade<Account> implements AccountFacadeLocal {

    /**
     * Persistence context entity manager.
     */
    @PersistenceContext(unitName = "SearchEnginePU")
    private EntityManager em;

    /**
     * Gets entity manager.
     *
     * @return entity manager.
     */
    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    /**
     * Constructor.
     */
    public AccountFacade() {
        super(Account.class);
    }

}

AccountFacadeLocal interface:

@Local
public interface AccountFacadeLocal {

    void create(Account account);

    void edit(Account account);

    void remove(Account account);

    Account find(Object id);

    List<Account> findAll();

    int count();

}

What am I missing here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:52:39+00:00Added an answer on June 2, 2026 at 5:52 am

    A Struts action is not a standard Java EE web component, and is not instantiated and managed by the Java EE container, so EJBs are not injected in Struts actions.

    Use JNDI to lookup your beans, or use http://code.google.com/p/struts-di/ (not tested). Also see EJB 3.1: Does it allow injection of beans into resources not managed by the container? for a similar question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a problem calling multiple instance of a class that i have coded
Here's my problem: I have an unmanaged dll that I made.I'm calling one of
I have a peculiar problem when calling a web service that expects the message
I have a problem calling an action using javascript. So, I calculate a distance
I have a problem in calling a template class I have. I declared a
I have some problem with calling web service from flex. I have service with
I have a problem with calling a property() inside a dynamic model in Django.
I have got a problem with calling a global function, which takes a pointer
I have problem with fancybox. I want to write a function that will run
I have a terrible problem that hopefully has a very simple answer. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.