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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:25:28+00:00 2026-05-23T03:25:28+00:00

Being completely new to Java EE (but not to Java itself) I’m trying to

  • 0

Being completely new to Java EE (but not to Java itself) I’m trying to build a very simple “Enterprise Application” with Hibernate as JPA provider and JSF as the actual UI framework. For this purposes I’m using the NetBeans 7 with GlassFish 3.1.

{ApplicationName}-ejb:

I’ve accomplished to generate entity classes from database and local sesssion beans for these entities. Beans.xml is in place.

@Stateless
public class QuestFacade extends AbstractFacade<Quest> implements QuestFacadeLocal {
    // some methods here as well as EntityManager injection ...
}

{ApplicationName}-war:

I’ve created a simple POJO as a backing bean for the JSF page. I’ve annotated it with javax.inject.@Named and javax.enterprise.context.@SessionScoped. This backing bean is now accessible from the JSF page as well as being injected when the actual page is accessed. Beans.xml is in place as well.

@Named
@SessionScoped
public class QuestBean implements Serializable {

    @EJB
    protected QuestFacade questFacade;

    // several methods delegating lookups to the questFacade ...
}

Having this deployed and page accessed, I’m, however, getting an error from GlassFish that the QuestFacade cannot be looked up by the JNDI.

The stacktrace is quite long but the initial cause could be enough:

Caused by: javax.naming.NamingException: Lookup failed for 'model.session.QuestFacade#model.session.QuestFacade' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: model.session.QuestFacade#model.session.QuestFacade not found]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:173)
    ... 74 more
Caused by: javax.naming.NameNotFoundException: model.session.QuestFacade#model.session.QuestFacade not found
    at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:248)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:215)
    at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:77)
    at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:119)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:505)
    ... 78 more

I understand that I’m persuading GlassFish to inject an EJB from a different module within the same application. Should the @Remote interface be used instead? I’ve also tried to explicitely specify the name for both @Stateless and @EJB annotation but without any success.

I believe that I’m doing something fundamentaly wrong, but I cannot find out what.

Any suggestion or would be greatly appreciated!

  • 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-23T03:25:29+00:00Added an answer on May 23, 2026 at 3:25 am

    I believe that I’m doing something fundamentaly wrong, but I cannot find out what.

    What you’re doing wrong is that if you implement a business interface (either @Local or @Remote), then you must declare the variable where injection takes place as having the type of that interface, not of the actual bean class.

    So in your case:

    @Named
    @SessionScoped
    public class QuestBean implements Serializable {
    
        @EJB
        protected QuestFacadeLocal questFacade;
    
        // several methods delegating lookups to the questFacade ...
    }
    

    However, a business interface is not required in EJB when you’re doing local (in-jvm) communication. As you discovered, if you don’t specify a business interface at all for your EJB, you can inject the bean class itself. This is because you then automatically get the so-called no-interface view.

    If you want, you can optionally declare that you want BOTH the local view and the no-interface view. In that way, you can inject your bean class in places whether either the bean type itself is declared or its business interface. For this you use the @LocalBean.

    @Stateless
    @LocalBean
    public class QuestFacade extends AbstractFacade<Quest> implements QuestFacadeLocal {
        // some methods here as well as EntityManager injection ...
    }
    

    Injection can thus happen in two ways now:

    @Named
    @SessionScoped
    public class QuestBean implements Serializable {
    
        @EJB
        protected QuestFacadeLocal questFacade; // possible because of local view
        @EJB
        protected QuestFacade questFacadeN; // possible because of no-interface view
    
        // several methods delegating lookups to the questFacade ...
    }
    

    In practice I didn’t found much use for having both methods available at the same time though, but maybe this adds to your understanding.

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

Sidebar

Related Questions

I am completely new to java, but I have urgent requirement to create a
hey guys, i am completely new to programming but I am trying hard, however
I come from a .NET background and am completely new to Java and am
I am new to java and I have been testing my application all day
Being relatively new to the .net game, I was wondering, has anyone had any
Being vaguely familiar with the Java world I was googling for a static analysis
Being new to test based development, this question has been bugging me. How much
Being really new to wx, I'm wondering if there is an IDE (especially for
Being a application developer, do I need to know Unicode?
Being fairly new to JavaScript, I'm unable to discern when to use each of

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.