aspose file tools*
The moose likes JBoss/WildFly and the fly likes Getting remote EJB when asking for local Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Getting remote EJB when asking for local" Watch "Getting remote EJB when asking for local" New topic
Author

Getting remote EJB when asking for local

Etienne Labuschagne
Greenhorn

Joined: Oct 18, 2007
Posts: 7

First, this post has nothing to do with remote INTERFACE vs local. It's about a local JBoss speaking to a remote JBoss (non-clustered setup).

The local JBoss has a JMX Bean that acts as a client and a stateless session bean, let's call it WorkerBean. The second JBoss also has WorkerBean deployed on it.

Code in the JMX decides if it need to use the local WorkerBean or the one deployed on the remote server. This code creates a context object with the provider url pointing either to localhost, or the remote JBoss' address.

My problem is, I always get the local WorkerBean, even if I explicitly ask for the remote one. If I undeploy WorkerBean from the local server, I get the remote one. So it's NOT a communication problem to the remote server as it works, as long as the bean is not deployed locally.

I am probably missing something fundamental regarding using JNDI to get hold of my beans. I do not think this is JBoss specific (though I haven't tested on another server), but rather me doing something wrong - probably JNDI wise.

I have set up a test project that I can provide, replicating this problem.

Code in JMX bean that creates the context and looks up the bean:



Father of many
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30973
    
159

Etienne,
Welcome to JavaRanch!

I don't currently use JBoss, but I think this might be app server specific. The host portions of JNDI names tend to vary by app server. I'm going to move this to JBoss. The moderators there can move it back to EJB if I am wrong.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10268
    
169

I dont know about other application servers, but i have seen this happen on JBoss and infact there have even been posts about this in various forums.

I have set up a test project that I can provide, replicating this problem


Please mail it to the email id in my profile.


[My Blog] [JavaRanch Journal]
Etienne Labuschagne
Greenhorn

Joined: Oct 18, 2007
Posts: 7

Thanks for the offer for help, Jaikiran. I have sent the project to you via e-mail.
Pavel Aronin
Greenhorn

Joined: Oct 30, 2007
Posts: 1
i had the same problem,and after debugging and getting in depth for a few days (99% of the credit is to my collageus actually) this is the result:

When JBOSS (4.0.1 don't know about later versions) starts up, it turns to a class called InvokerInterceptor and sets there a local invoker(the call is static,and it comes from the LocalInvoker class). When you call for your remote bean,what actually happens is that your call goes through a chain of interceptors defined in your local JBOSS.One of them is that InvokerInterceptor fellow,and you get back a local object (look at isLocal() function in InvokerInterceptor and you figure out why right away).

You can try to workaround this behaviour by defining your own interceptors in standardjboss.xml and making JBOSS turn to them instead of build-ins,but be aware that you can get undefined behaviour in other cases if you overwrite this setting.If you do try to workaround,note the static call I mentioned in LocalInvoker (have to take care of that as well).

Our final solution is to use web services - might consider that too instead of all this mess.

Hope it helped.
Etienne Labuschagne
Greenhorn

Joined: Oct 18, 2007
Posts: 7

Thanks for the follow-up, Pavel. I will see if I can use the info to solve my problem. We are also planning to move up to JBoss 5 and that may also make the problem "go away"

Etienne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting remote EJB when asking for local