1 Reply Latest reply: Apr 13, 2011 9:09 PM by Dieter Cailliau RSS

org.jboss.ejb3.annotation.RemoteBinding on JBOSS4

Tomasz Wolak Newbie

Hi:

I have been tasked with wipping out a small app using ejb3 and jsf on jboss. Having jboss 5 already up and running I coded it there first.  The app is very simple: entity Bean together with Manager bean with local/remote interfaces.  I used the org.jboss.ejb3.annotation.RemoteBinding to map my custom name of the manager bean.  The manager bean was being accessed from JSF backing bean using direct injection.  This setup worked great on Jboss5.  However we currently use JBoss4 in production but I figured this will be a non issue just put the ear file in the Jboss4.x and off we go.  Well not quite.  I was aware of the fact that DI does not work in non container manager beans (such as JSF bean) so I used direct context lookup to account for this fact.

 

Here is stub for my manager:

 

import org.jboss.ejb3.annotation.LocalBinding;

import org.jboss.ejb3.annotation.RemoteBinding;

 

@RemoteBinding(jndiBinding = "FakeInvManager/remote")

@LocalBinding(jndiBinding = "FakeInvManager/local")

public class FakeInvManagerBean implements FakeInvManagerRemote,

        FakeInvManagerLocal {

}

 

here is part of JSF where I look up the manager:

 

try {

                Context envCtx = new InitialContext();

                invMgr = (FakeInvManagerLocal) envCtx

                        .lookup("FakeInvManager/local");

            } catch (NamingException ne) {

                log.error("Cannot create instance of the FakeInvManager",

                        ne);

                throw ne;

            }

This is where it is getting intresting: I deployed this on JBOSS 4 and I had a failure ("FakeInvManager/local" not bound).  Looked in the JNDI tree to find that the bean is not getting registered under "FakeInvManager/local".  I could only use the global name "earFileName/BeanName/local".  This meant that @LocalBinding is not working.  Did a bit digging and found out that @LocalBinding implmentation changed from JBoss4 to JBoss5 from

org.jboss.annotation.ejb.LocalBinding;

to

org.jboss.ejb3.annotation.LocalBinding;

So I updated my manager to use JBoss4 (org.jboss.annotation.ejb.LocalBinding) implementation and everything went to normal i.e. I could look up the resource using the LocalBinding specified jndiBiding name (i.e. FakeInvManager/local").

 

You'd think that the story is over...problem solved?

Well here is my dilema: Originally I have deployed my manager Bean to JBOSS4.x using JBOSS5.x specific import:org.jboss.ejb3.annotation.LocalBinding;

Yet there is NO trace of that package on Jboss4.x so how come I did not explode with "ClassNotFound" or something to this account?  In fact once I changed my lookup to the global JNDI biding the whole thing worked where I think it shouldn't? 

  • 1. org.jboss.ejb3.annotation.RemoteBinding on JBOSS4
    Dieter Cailliau Newbie

    JBoss4 ignored the annotation: you can use a class, even if some of its annotations are not on the classpath.

     

    The fact that the jndi lookup worked, with the old annotation present (but which was ignored because not on the classpath) and without the jboss4 annotation is: because jboss bound the thing to the default jboss generated jndi name, which is earname/ImplementationClassSimpleName/local (and /remote).