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

  • SEARCH
  • Home
  • 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 1013999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:11:20+00:00 2026-05-16T10:11:20+00:00

I have created an EAR with a web project, ejb3 project and the ejb

  • 0

I have created an EAR with a web project, ejb3 project and the ejb client. I’m able to call the bean methods via injection in the servlet.
I’m planning to use a ServiceDelegate which is a pojo to handle the bean invocation. So I’ll call the delegate from my servlet and the delegate will call the appropriate beans and its methods.

But I’m unable to get the bean references in the delegate class which is in the web project. @EJB annotation returned a null reference. So I tried a JNDI lookup with java:comp/env/EARname/BeanName. But I always end up with naming exceptions.

Name comp/env/EARname not found in context “java:”.

Please suggest me the correct way to call ejb3 beans via JNDI on Websphere 7 server.

  • 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-16T10:11:21+00:00Added an answer on May 16, 2026 at 10:11 am

    Dependency injection in Java EE 5 and 6, works only for managed classes. In the servlet container, this is supported in a few types of classes, and not in all POJOs (unfortunately).

    The Servlet Spec 2.5 sheds light on the classes for which the container must inject dependencies if they are present:


    Component Type: Servlets

    Classes implementing the following interfaces

    • javax.servlet.Servlet

    Component Type: Filters

    Classes implementing the following interfaces:

    • javax.servlet.Filter

    Component Type: Listeners

    Classes implementing the following interfaces:

    • javax.servlet.ServletContextListener
    • javax.servlet.ServletContextAttributeListener
    • javax.servlet.ServletRequestListener
    • javax.servlet.ServletRequestAttributeListener
    • javax.servlet.http.HttpSessionListener
    • javax.servlet.http.HttpSessionAttributeListener

    Therefore, if you have to resolve the issue with dependency lookups, you could adopt either of the following strategies:

    • Inject the dependency into a managed class, and propagate it to the ServiceDelegate. This is a design smell IMHO.
    • Perform a JNDI lookup using the InitialContext, but you should be aware of the JNDI bindings generated for the EJBs that you have deployed. This appears to be failing since the JNDI name might be incorrect – the Java EE specification has not standardized the JNDI names that are assigned to the deployed EJBs. In other words, given the lack of portable JNDI names, you should attempt to bind the EJB to a known name and perform a lookup of the same.
    • You’ll need to verify that the EJB session object is indeed bound to the java:comp/env namespace. This might not be the case. To be clear, if the dependency is not injected by the container, then one must declare the local EJB reference entries in web.xml. The container will not automatically inject the session EJB objects into the servlet’s namespace; it will require the EJB to be declared as a resource in a managed class. This appears to be the primary case of failure, although it is listed last.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an EAR file with a nested EJB project, a .war dynamic web
I have created an EAR project in Eclipse to be deployed on JBoss. In
I have created a simple EAR the contains a EJB module and a Application
I have a EAR package that contains a web module and EJB. The EJB
I have an ear app with two EJB and one WEB (war) projects all
Background : I have created a web service client VoucherWebService (consumed from an external
I have a basic EJB 3.0 (Java EE 5) project in IBM RAD (aka
Let's say I have two ear file and one .jar file with an EJB
I have created a servlet mapping as /reskilling in my Servlet class. When I
I want to create an EAR project that consists of an EJB 3.1 module

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.