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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:12:01+00:00 2026-06-09T19:12:01+00:00

For some reasons, I would like to deploy my application as two separate artifacts:

  • 0

For some reasons, I would like to deploy my application as two separate artifacts: Users-ejb.jar and Users-war.war, not packaged in the same ear (but still, deployed in the same JBoss AS 7.1 instance). In the Users-war.war I have a backing bean (annotated as a JSF managed bean) where I wish to inject an EJB3 packaged in the Users-ejb.jar. The simple @EJB injection that worked when everything was packaged in a single ear no longer works when the Users-ejb.jar and the Users-war.war are deployed seperately.

A narrowed-down simplified example of my setup follows:

EJB3 bean

import javax.ejb.*;

(...)

@Stateless(name="userFacade")
@Local(IUserFacadeLocal.class)
@Remote(IUserFacadeRemote.class)
public class UserFacade extends AbstractFacade<User> implements IUserFacadeLocal, IUserFacadeRemote {

Backing bean

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.ejb.EJB;

import entities.User;
import facades.IUserFacadeRemote;
import facades.IUserFacadeLocal;

@ManagedBean(name="indexBackingBean")
@SessionScoped
public class IndexBackingBean implements Serializable {

    @EJB(beanName="userFacade")
    private IUserFacadeLocal userFacade;

I’ve tried various combinations like declaring the type of the EJB3 bean in the backing bean as IUserFacadeRemote (as opposed to IUserFacadeLocal) but they all fail with the same exception when the Users-war.war module is deployed:

Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException:
JBAS014543: No EJB found with interface of type 'facades.IUserFacadeLocal' and
 name 'userFacade' for binding controllers.IndexBackingBean/userFacade

The Users-ejb.jar is deployed to JBoss AS 7.1 without any complains but when the Users-war.war is deployed, JBoss complains that it can’t find the bean he’s supposed to inject.

However, I am able to obtain a reference to the EJB3 bean using JNDI using:

String jndiName = "java:global/Users-ejb/userFacade!facades.IUserFacadeRemote";
this.userFacade = (IUserFacadeRemote) new InitialContext().lookup(jndiName);

Despite that, the @EJB injection doesn’t seem to work.

UPDATE:
I followed the suggestion give below by Tom Anderson and the injection that does work is the:

@EJB(mappedName = "java:global/Users-ejb/userFacade!facades.IUserFacadeRemote")

which if I understand correctly uses the vendor-specific mappedName attribute. I couldn’t get the injection to work in a vendor-independent way.

  • 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-09T19:12:03+00:00Added an answer on June 9, 2026 at 7:12 pm

    I wish i understood this area of the EE spec well enough to give you a definitive answer, but i don’t.

    The JBoss EJB documentation has this to say:

    • The @EJB annotation also has a mappedName() attribute. The specification leaves this a vendor specific metadata, but JBoss recognizes mappedName() as the global JNDI name of the EJB you are referencing. If you have specified a mappedName(), then all other attributes are ignored and this global JNDI name is used for binding.
    • If you specify @EJB with no attributes defined […] Then the following rules apply:
      • The EJB jar of the referencing bean is searched for an EJB with the interface, used in for @EJB injection. If there are more than one EJB that publishes same business interface, then an exception is thrown. If there is only one bean with that interface then that one is used.
      • Search the EAR for EJBs that publish that interface. If there are duplicates, then an exception is thrown. Otherwise the matching bean is returned.
      • Search globally in JBoss for an EJB of that interface. Again, if duplicates, an exception is thrown.
    • @EJB.beanName() corresponds to . If the beanName() is defined, then use the same algorithm as @EJB with no attributes defined except use the beanName() as a key in the search. An exception to this rule is if you use the ejb-link ‘#’ syntax. The ‘#’ syntax allows you to put a relative path to a jar in the EAR where the EJB you are referencing lives. See spec for more details

    The “Search globally in JBoss for an EJB of that interface” certainly suggests that an injection like the one you wrote should work. Indeed, that it should work without the beanName. However, my suspicion is that from the point of view of a component in the WAR, a component in the EJB-JAR is remote, and therefore you will need to use the remote interface.

    So, the first thing i’d try is:

    @EJB
    private IUserFacadeRemote userFacade;
    

    Without a beanName, in case that’s making trouble. It sounds like you’ve tried that, though.

    If the normal approach to injection doesn’t work, i might fall back to trying an injection via a mappedName, which in JBoss is a global JNDI name. So:

    @EJB(mappedName = "java:global/Users-ejb/userFacade!facades.IUserFacadeRemote")
    private IUserFacadeRemote userFacade;
    

    This is obviously rather ugly.

    Anyway, good luck!

    EDIT: Something else you could try is to use a qualified relative beanName which explicitly names the EJB-JAR:

    @EJB(beanName = "Users-ejb.jar#userFacade")
    private IUserFacadeRemote userFacade;
    

    Because the WAR and EJB-JAR are not packaged in an EAR, this might need to be:

    @EJB(beanName = "../Users-ejb.jar#userFacade")
    private IUserFacadeRemote userFacade;
    

    But by this point i’m just guessing.

    EDIT STRIKES BACK: We may have overlooked something very simple. The lookup attribute of the @EJB annotation lets you specify “A portable lookup string containing the JNDI name for the target EJB component”, hence:

    @EJB(lookup = "java:global/Users-ejb/userFacade!facades.IUserFacadeRemote")
    private IUserFacadeRemote userFacade;
    

    Might work. This is essentially a portable version of the JBoss-specific use of mappedName.

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

Sidebar

Related Questions

I would like to put some extra merged cells for grouping reasons on the
For some reasons, I would like to do an explicit quoting of a string
My question is fairly clear, and I really would like to hear some reasons
I'm developing a JSF2 application using Glassfish which contains some EJB's; is there a
I have an excel file with some email links. I would like to have
I would like to develop a desktop application but I want to use web
I would like to make my application to have several skins. My primary aim
I have a String which I would like to modify in some way. For
I'm working on a Java library and would like to remove some functions from
What are some reasons why I wouldn't want to disable IIS logging completely for

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.