This discussion is archived
3 Replies Latest reply: May 8, 2012 1:12 AM by 651477 RSS

Classic EJB3 backward compatibility issue

771286 Newbie
Currently Being Moderated
Hi,

I have changed a EJB2.1 SLSB to a EJB3 bean, and now I am having trouble accessing it from the clients.

I have gone through multiple guides online telling me how to do this, but it is still not working.

So, what I have now is:

My SLSB:
@Stateless(mappedName="InboundLegacyDataServiceBean", name="InboundLegacyDataService")
@Remote(InboundLegacyDataServiceRemote.class)
@RemoteHome(InboundLegacyDataServiceRemoteHome.class)
public class InboundLegacyDataServiceBean implements InboundLegacyDataServiceRemote2{

//... business methods

}

My Interface as I wish to expose it to EJB2 clients :
public interface InboundLegacyDataServiceRemote extends javax.ejb.EJBObject{

public abstract String getLegacyData(String messageId)throws RemoteException;
//...
}

My new Interface as I wish to expose it to EJB3 clients:
@Remote
public interface InboundLegacyDataServiceRemote2{

public abstract String getLegacyData(String messageId);
//...
}

And since weblogic uses mappedname and package declaration for jndi-name, i set up a DD:
<wls:weblogic-enterprise-bean>
<wls:ejb-name>InboundLegacyDataService</wls:ejb-name>
<wls:enable-call-by-reference>true</wls:enable-call-by-reference>
<wls:jndi-name>brreg.ejb.BReMS.InboundLegacyDataService</wls:jndi-name>
</wls:weblogic-enterprise-bean>

Now, when I browse the JNDI-tree on my WLS it says in the overview:
Binding Name:     brreg.ejb.BReMS.InboundLegacyDataService     
Class:     my.package.*InboundLegacyDataService_icu4pu_HomeImpl_1033_WLStub*
Hash Code:     73415687     
toString Results:     ClusterableRemoteRef

this used to say something like
Binding Name:     brreg.ejb.BReMS.Administration     
Class:     *$Proxy333*     
Hash Code:     70851603     
toString Results:     ClusterableRemoteRef

And when I try to call this from my client, I get an exception:
ClassCastException: my.package.*InboundLegacyDataService_icu4pu_EOImpl_1033_WLStub*


How is this done on WebLogic? This shouldn´t be too hard.
  • 1. Re: Classic EJB3 backward compatibility issue
    651477 Explorer
    Currently Being Moderated
    hi, which WLS version are you using?
    to lookup the EJB3 remote business interface via mappedName, you'll need to JNDI lookup like:
    contxt.lookup("InboundLegacyDataServiceBean#InboundLegacyDataServiceRemote2");
    the JNDI name will be mappedName#<full path of business interface>

    Thanks,
    Amy
  • 2. Re: Classic EJB3 backward compatibility issue
    771286 Newbie
    Currently Being Moderated
    Hi Amy,

    thanks for your update. I am using WLS 10.3.3.

    Yes you are right about the JNDI name for the EJB3 interfaces, but I need the JNDI to exactly the same as it was for the bean when it was implemented as EJB2.1.
    (I don´t want to do anything on the client side). So I included my weblogic-ejb-jar which maps the beans 2.1-interface to my old JNDI, and this seems to be working now.

    But now it gives me a ClassCastException when I try to cast the EJBHome-interface to the interface in the client.
  • 3. Re: Classic EJB3 backward compatibility issue
    651477 Explorer
    Currently Being Moderated
    the element
    <wls:weblogic-enterprise-bean>
    <wls:jndi-name>brreg.ejb.BReMS.InboundLegacyDataService</wls:jndi-name>
    in DD can only applied for remote home interface.

    in 10.3.3, i'll recommend you to use @JNDIName annotation, since it's more convenient than <business-interface-jndi-name-map> in deployment descriptor.
    you can try something like:
    @JNDIName("brreg.ejb.BReMS.InboundLegacyDataService")
    @Remote
    public interface InboundLegacyDataServiceRemote2{

    public abstract String getLegacyData(String messageId);
    //...
    }

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points