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 946493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:55:32+00:00 2026-05-15T22:55:32+00:00

I’ve been struggling for this for a while now. I’m trying to gear up

  • 0

I’ve been struggling for this for a while now.

I’m trying to gear up for EJB 3.0. I’m using JBoss 5.1.0 GA as my application server. I started with very simple stateless session bean with local interface and a simple jsp-servlet client which invokes session bean method. All this while I’ve been trying to use @EJB annotation to inject session bean into the servlet class.

public class SampleServlet extends HttpServlet {

    @EJB
    private PersonLocal person;

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        System.out.println("In servlet");       
        response.getWriter().write("Person Name : "+person.getName());
        System.out.println(person.getName());       
    }
}

I’m using JBoss 5.1.0 GA with the default configuration. (I also tried with all configuration)

However, I used to get a null reference to the session bean injection. After struggling for a day or so, I finally tried the ugly EJB 2.x JNDI lookup method instead of @EJB annotation with configuration for jndi specified in the jndi.properties file and it worked without any other changes!

Now, I tried to find out in the JBoss docs whether JBoss 5.1.0 GA does or does not support the injection with @EJB annotation, but couldn’t find a concrete answer. So can someone tell me whether it does? cause I would really prefer annotation over JNDI lookup (I mean, who will not?). Am i missing something..?

Probably should have put this in the JBoss forums, but.. I’m addicted to this place 😉

  • 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-05-15T22:55:33+00:00Added an answer on May 15, 2026 at 10:55 pm

    This is definitely supported by JBoss 5.x since it is Java EE 5 certified.

    Actually, I suggest to check the Chapter 11. Introduction to EJB injection in Servlets of the JBoss EJB3 Tutorials, they describe a detailed and step by step example.

    And pay a particular attention to the following note:

    For the injection to take place in a
    web module, your web.xml should use
    the 2.5 version of the web-app xsd:

    <web-app version="2.5"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.