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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:35:25+00:00 2026-06-11T16:35:25+00:00

I faced with a problem I can’t invoke a method of a bean instance

  • 0

I faced with a problem I can’t invoke a method of a bean instance once it isn’t declared in the business interface.

Basically the problem came to me after I started working with a EJB 2.1 project had been developed by another team.
The app server is Websphere v8

The problem is following:
We have an abstract class FooAbstract where basic business functions are declared (like read, delete, update, etc.)

Each bean must extend that class and implement abstract methods of course.
Beans can have their own public methods as well (and actually have).

For some reasons those methods aren’t declared in business interfaces,
however all bean’s methods are invoked through reflection instead of direct calls (I don’t know why).

In my opinion the reflection makes system much more slower than it could be, but I can’t handle with the architecture because almost of all needed methods aren’t visible for direct calls.

Here is an example:

public abstract class FooAbstract {
    public abstract Object create();
    public abstract void delete(Object x);
}

A FooBean class that does business logic (jndi name “Foo”):

public class FooBean extends FooAbstract implements SessionBean {
    /** inherited method */
    public Object create() {
        Object x = new SomeDBMappedObject();
        ...  // creating an object in DB and return wrapper class
        return x;
    }

    /** inherited method */
    public void delete(Object x) {
        ... // deleting object from DB
    }

    /** The method that performs some extra logic */
    aMethod() {
      ... //do extra logic
    }
}

Local business interface:

public interface FooLocal extends EJBLocalObject {
    public abstract Object create();
    public abstract void delete(Object x);
}

And finally Local Home interface:

public interface FooLocalHome extends EJBLocalHome {
   public FooLocal create() throws CreateException;
}

According to the architecture specification if I need to invoke a method of another EJB I should use some utility class UtilityBean that uses reflection to dispatch my call.

Something like:

...
   public static Object dispath(String jndi, String methodname, Object parameters) {
      ...
   }
...

Eventually, my question:

I want to call extra method of FooBean directly within my EJB, but if I do something like this:

public void doSomething {
    InitialContext ctx = new InitialContext ();
    FooHome home = (FooHome) ctx.lookup("local:ejb/Foo");
    Object bean = home.create();
    ...
}

into “bean” variable I get a reference to FooBean instance, but I cannot invoke method aMethod() because it doesn’t exist in FooLocal interface.

Are there any suggestions?

  • 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-11T16:35:27+00:00Added an answer on June 11, 2026 at 4:35 pm

    Normally you could use reflection to access a private method of an object. However, the actual underlying object for the variable bean is not a FooBean, but a proxy object that also implements FooLocal. Accessing that private method will not be possible without adding it to the interface.

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

Sidebar

Related Questions

I faced a problem that I can not find a way to change the
I'm playing around with namespaces and faced a problem I can't really understand. My
I faced a problem, that I can't solved for 3 days and you're my
I've faced a problem I can't solve that's why I beg you to help
I'm faced with a problem, and can't decide what the correct solution is. Here
I faced this problem how can I retrieve string with another language (not English)
I'm using CDI (Weld) and I've faced a problem, hope you can help. I
I think many of us has faced this problem on UITableView delegate method -
My problem is certainly right on my face but I can't see it... I
I faced a problem while using threading for the first time, In an SWT

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.