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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:42:35+00:00 2026-06-13T15:42:35+00:00

I am trying to inject EJB into Spring (3.1.2) service (both in different WARs)

  • 0

I am trying to inject EJB into Spring (3.1.2) service (both in different WARs)
Both are very simple (methods removed to simplify example):

EJB:

@Remote
public interface MyBean {
}

@Singleton
public class MyBeanImpl implements MyBean{
}

Service:

@Service
public class MyServiceImpl implements MyService{
}

At first sight thing is very simple, but I tried:

@EJB(lookup = "java:global/ejbApp/MyBeanImpl!com.my.MyBean")
private MyBean myBean;

and it didin’t work. Then I also tried:

@EJB(mappedName = "java:global/ejbApp/MyBeanImpl!com.my.MyBean")
private MyBean myBean;

And

@Resource(mappedName = "java:global/ejbApp/MyBeanImpl!com.my.MyBean")
private MyBean myBean;

but neither worked.

I managed to inject my EJB using:

<jee:jndi-lookup id="myBean" jndi-name="java:global/ejbApp/MyBeanImpl!com.my.MyBean" />

in my spring configuration and in the service:

@Autowired
private MyBean myBean;

But I really dont like this solution. I would like to have my JNDI path in some annotation to be able to do e.g:

@EJB(lookup = MyBean.JNDI_NAME)
private MyBean myBean;
  • 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-13T15:42:37+00:00Added an answer on June 13, 2026 at 3:42 pm

    We have found quite nice and simple solution.
    Into spring configuration file one has to put:

    <bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor">
        <property name="alwaysUseJndiLookup" value="true" />
    </bean>
    

    And that enables spring to search for the beans annotated with @Resource in JNDI.
    So now one can do:

    @Resource(mappedName = MyBean.JNDI_NAME)
    private MyBean myBean;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use Spring to inject @PersistenceContext entityManager into my service. The
I'm trying to inject Spring beans into an EJB using @Interceptors(SpringBeanAutowiringInterceptor.class) but I cannot
I am using FluentValidation and Ninject. I am trying to inject a service into
Currently I am trying to inject a stateless EJB into a CDI managed controller
I am trying to inject a DAO into an CXF Service. For this purpose
I am trying to inject a JAXBContext into spring application context, by: <bean id=jaxbContext
I'm trying to inject webapproot value into spring form like this <form:form action=${webappRoot}/user/create commandName=createUsr
I am trying to inject dependency to my session dictionary class into my controller's
I am trying to inject JQuery into a UIWebView of a page that I
I am trying to properly use Ninject to inject log4net logging into my MVC3

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.