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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:56:43+00:00 2026-05-16T06:56:43+00:00

If I create an EJB3 bean (say a stateless session bean) in an application

  • 0

If I create an EJB3 bean (say a stateless session bean) in an application using Spring 2.5 for DI, how should I inject dependencies from Spring into the bean without coupling the bean to Spring?

  • 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-16T06:56:43+00:00Added an answer on May 16, 2026 at 6:56 am

    I don’t know if you consider applying an interceptor as coupling but that’s to my knowledge the standard approach. From the Chapter 18. Enterprise Java Beans (EJB) integration of the documentation:

    18.3.2. EJB 3 injection interceptor

    For EJB 3 Session Beans and
    Message-Driven Beans, Spring provides
    a convenient interceptor that resolves
    Spring 2.5’s @Autowired annotation
    in the EJB component class:
    org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor.
    This interceptor can be applied
    through an
    @Interceptors
    annotation in the EJB component class,
    or through an interceptor-binding XML
    element in the EJB deployment
    descriptor.

    @Stateless
    @Interceptors(SpringBeanAutowiringInterceptor.class)
    public class MyFacadeEJB implements MyFacadeLocal {
    
        // automatically injected with a matching Spring bean
        @Autowired
        private MyComponent myComp;
    
        // for business method, delegate to POJO service impl.
        public String myFacadeMethod(...) {
            return myComp.myMethod(...);
        }
        ...
    }
    

    SpringBeanAutowiringInterceptor by
    default obtains target beans from a
    ContextSingletonBeanFactoryLocator,
    with the context defined in a bean
    definition file named
    beanRefContext.xml. By default, a
    single context definition is expected,
    which is obtained by type rather than
    by name. However, if you need to
    choose between multiple context
    definitions, a specific locator key is
    required. The locator key (i.e. the
    name of the context definition in
    beanRefContext.xml) can be
    explicitly specified either through
    overriding the
    getBeanFactoryLocatorKey method in a
    custom
    SpringBeanAutowiringInterceptor
    subclass.

    The only other option I’m aware of (extending the EJB 2.x support classes) is much worse from a coupling point of view (and thus doesn’t answer your question).

    See also

    • Default Injecting Spring bean to EJB3 SLSB without @Autowired Annotation
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have created a demo application Using JSF & EJB 3.0 (Stateless session bean
I'm experimenting with EJB3 I would like to inject a stateful session bean into
I want to create a timer EJB3 when a stateless bean is created in
I'm designing a DAO layer for a EJB3 project, they are stateless session bean.
I have an EJB3 stateless session bean that uses some other ejbs to do
I'm studying EJB3. I have a session bean which provides services to create/update customer
I'm exposing the following EJB3 stateless session bean through a web service. @Stateless public
I'm using NetBeans and GlassFish 3.0.1 to create an EJB3 application. I have written
I am trying to create a simple project with few stateless session beans.I have
I am attempting to create a EJB3.0 container-managed persistence bean and am having issues

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.