• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting remote EJB when asking for local

 
Greenhorn
Posts: 7
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:

 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Etienne Labuschagne
Greenhorn
Posts: 7
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the offer for help, Jaikiran. I have sent the project to you via e-mail.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic