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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:01:35+00:00 2026-05-19T01:01:35+00:00

I have deployed an enterprise app in an EAR and a standalone web app

  • 0

I have deployed an enterprise app in an EAR and a standalone web app in WAR (out side of the EAR) to the same Java EE server.

Question is can I access the local interface of the session bean in the EAR from the standalone WAR? if so can I use dependency injection (DI)?

  • 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-19T01:01:35+00:00Added an answer on May 19, 2026 at 1:01 am

    The answer anyway to both your questions is yes.

    Since both the ear and war are in the same JVM, a local interface can be used. To get an instance of the session bean, you would use the global JNDI name of said bean to do either a JNDI lookup or use with the mappedName property on the @EJB annotation. Those names are standardized via the following pattern:

    java:global[/<app-name>]/<module-name>/<bean-name>[!<fully-qualified-interface-name>]

    Lookup would thus be if the name of your ear is my_app, your bean is MyBean.java and its local interface is com.foo.SomeBeanLocal:

    InitialContext ctx = InitialContext();
    SomeBeanLocal someBean = (SomeBeanLocal) ctx.lookup("java:global/my_ear/SomeBean/com.foo.SomeBeanLocal");
    

    Injection would be:

    public SomeManagedClass {
    
        @EJB(mappedName="java:global/my_ear/SomeBean/com.foo.SomeBeanLocal")
        SomeBeanLocal someBean;
    }
    

    There are two catches however:

    Non-standard naming

    Older Java EE implementations (e.g. JBoss AS 5.1, Glassfish 2, Websphere) used their own naming pattern. E.g. JBoss AS 5.x would use:

    <app-name>/<bean-name>/local|global

    E.g. with the same names as the previous example, the global JNDI name of that bean in JBoss AS 5.1 would be:

    my_app/MyBean/local

    As said, other old application servers might use other names.

    Startup-order

    Especially with injection you have to assure somehow that the application you want to inject from has been started before the application you want to inject into. I.e. in your case that the EAR has been started before the standalone WAR. There are no standard mechanisms for this. You might be just lucky that it happens to be in the right order for you. This order might be influenced by time-stamps, alphabetical order of application names, or something else entirely.

    JBoss AS for example uses <depends> tags in many of its proprietary configuration files, which is perfectly suited for this although it can be hard to find out what exactly you need to depend on (the syntax can be very cryptic).

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

Sidebar

Related Questions

We have Java Enterprise applications deployed on to multiple servers. There are replicated servers
I have a WCF service that's deployed as a Windows Azure Web Role. I'm
I have Deployed my PHP web application on Amazon Cloud. I have installed PHP
I have deployed my MVC app but when I browse from IIS I find
I have deployed a app on tomcat. Some of the libraries used by the
I have created a website in asp.net and deployed it on IIS. It is
I've got a fairly simple web application deployed in GlassFish 3.0.1. I'm using regular
I am trying to recreate an existing project with Maven (any IDE is ok,
I need to add a worker process to my current solution with the following
I am trying to build an project in Eclipse (actually I'm using RAD, so

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.