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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:21:27+00:00 2026-05-28T19:21:27+00:00

So far, I almost always worked with no-interface EJBs and have a slight understanding

  • 0

So far, I almost always worked with no-interface EJBs and have a slight understanding about the need of @Local annotation. Consider this example:

public interface MyBeanIntf { void doStuff(); }

@Stateless
public class MyBean implements MyBeanIntf { public void doStuff(){ } }

Should the MyBeanIntf be marked as @Local? I don’t see any benefit from that, because even when I don’t annotate it as @Local, I still can use DI to properly inject it into UI Controller:

@Named
@SessionScoped
public class TestController implements Serializable {

  // injection works perfectly, even when MyBeanIntf is not marked as @Local
  @Inject
  private MyBeanIntf myBean;

  // or even like this:
  // @EJB
  // private MyBeanIntf myBean;

}

Let’s make it more complex:

public interface MyBeanIntf { void doStuff(); }
public class MySuperBean implements MyBeanIntf { public void doStuff() { } }

@Stateless
public class MyBean extends MySuperBean { }

Is MyBean now considered a valid Local EJB bean? I have some doubts because it implements the interface indirectly.

  • 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-28T19:21:29+00:00Added an answer on May 28, 2026 at 7:21 pm

    If your EJB implements some interface but you don’t specify (neither on the EJB nor the interface itself) which interface it is (@Remote, @Local) than it’s assumed that it’s a @Local one.

    Therefore your code:

    public interface MyBeanIntf { void doStuff(); }
    
    @Stateless
    public class MyBean implements MyBeanIntf { public void doStuff(){ } }
    

    is semantically identical to the following:

    @Local
    public interface MyBeanIntf { void doStuff(); }
    
    @Stateless
    public class MyBean implements MyBeanIntf { public void doStuff(){ } }
    

    When it comes to the second part of your question, I think that section 4.9.2.1 Session Bean Superclasses from EJB 3.1 FR spec would be interesting for you. From my understanding (so it might not be correct), it seems that your bean should not be considered as exposing a valid Local interface because of the following excerpt:

    @Stateless
    public class A implements Foo { ... }
    
    @Stateless
    public class B extends A implements Bar { ... }
    

    Assuming Foo and Bar are local business interfaces and there is no
    associated deployment descriptor, session bean A exposes local
    business interface Foo and session bean B exposes local business
    interface Bar, but not Foo
    .

    Session bean B would need to explicitly include Foo in its set of
    exposed views for that interface to apply.

    Update:

    As an addition one more excerpt from the spec:

    A session bean class is permitted to have superclasses that are
    themselves session bean classes. However, there are no special rules
    that apply to the processing of annotations or the deployment
    descriptor for this case. For the purposes of processing a particular
    session bean class, all superclass processing is identical regardless
    of whether the superclasses are themselves session bean classes.

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

Sidebar

Related Questions

As far as I understand WebRequest.PreAuthenticate is almost always good. If I enable it
I have had this issue for sometime on my app and it always bothered
I have a successful (almost) animation in jquery but now need a text saying
I'm in the process of learning F# and am enjoying it so far. Almost
So far I have encountered adjacency list, nested sets and nested intervals as models
As far as I can tell, this is isn't possible, so I'm really just
I'm developping my first real big pluggin for wordpress and so far almost everything
So far in my web developing experiences, I've noticed that almost all web developers/designers
Almost everywhere I worked I met lots of people who didn't care that they
Anyone know a good solution? So far I have not found a better way

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.