yep,

was expecting some magic property too but the code said the opposite (to be
honest i find it quite logical)

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*




2012/10/22 Miguel Figueiredo <[email protected]>

> Hi Romain,
>
> I was expecting some magic ;)
>
> I fixed it using the following:
>
> 1. Added an entry to ejb-jar.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"; xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance";
>     version="3.0"
>     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd";>
>     <enterprise-beans>
>         <session>
>             <ejb-name>B</ejb-name>
>             <home>openejbtest.BInterfaceHome</home>
>             <remote>openejbtest.BInterface</remote>
>             <ejb-class>openejbtest.B</ejb-class>
>             <session-type>Stateless</session-type>
>             <transaction-type>Container</transaction-type>
>         </session>
>     </enterprise-beans>
> </ejb-jar>
>
> 2. Created a home interface and injected it in the A EBJ:
>
> *BInterfaceHome*
>
> package openejbtest;
>
> import javax.ejb.EJBException;
>
>
> public interface BInterfaceHome extends javax.ejb.EJBHome {
>     public BInterface create() throws EJBException;
> }
>
> *A*
>
> package openejbtest;
>
> import javax.ejb.EJB;
> import javax.ejb.Stateless;
> import javax.persistence.EntityManager;
> import javax.persistence.PersistenceContext;
>
> @Stateless
> public class A implements AInterface {
>
>     @EJB
>     protected BInterfaceHome b;
>
>     @Override
>     public void methodA() {
>         b.create().methodB();
>     }
> }
>
> Best regards,
> Miguel
>
> On Mon, Oct 22, 2012 at 1:22 PM, Romain Manni-Bucau
> <[email protected]>wrote:
>
> > Hi Miguel,
> >
> > these EJB doesn't look valid so the deployment fails.
> >
> > You have to change something to make it working, no magic property i fear
> >
> > *Romain Manni-Bucau*
> > *Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
> > *Blog: **http://rmannibucau.wordpress.com/*<
> > http://rmannibucau.wordpress.com/>
> > *LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
> > *Github: https://github.com/rmannibucau*
> >
> >
> >
> >
> > 2012/10/22 Miguel Figueiredo <[email protected]>
> >
> > > Hello,
> > >
> > > I have a scenario where I want to inject EJB B that has an interface
> that
> > > extends EJBObject, in EJB A. When I run the OpenEJB container I get the
> > > following error:
> > >
> > > SEVERE - FAIL ... A:    @EJB mistakenly refers to a beans
> > > javax.ejb.EJBObject interface openejbtest.BInterface.  Use the EJBHome
> > > interface instead.
> > > SEVERE - FAIL ... B:    javax.ejb.EJBObject interface declared as
> > > <business-local>. Use <remote>openejbtest.BInterface</remote>
> > >
> > > What should I do to fix this? Changing EJB B and its interface is not
> an
> > > option.
> > >
> > > Here is the listing of a simplified scenario:
> > >
> > > *class A:*
> > >
> > > package openejbtest;
> > >
> > > import javax.ejb.EJB;
> > > import javax.ejb.Stateless;
> > > import javax.persistence.EntityManager;
> > > import javax.persistence.PersistenceContext;
> > >
> > > @Stateless
> > > public class A implements AInterface {
> > >
> > >     @EJB
> > >     protected BInterface b;
> > >
> > >     @Override
> > >     public void methodA() {
> > >     }
> > > }
> > >
> > > *interface AInterface:*
> > >
> > > package openejbtest;
> > >
> > >
> > > public interface AInterface {
> > >
> > >     void methodA();
> > >
> > > }
> > >
> > > *class B:*
> > >
> > > package openejbtest;
> > >
> > > import java.rmi.RemoteException;
> > >
> > > @Stateless
> > > public class B implements BInterface {
> > >
> > >     @EJB
> > >     protected CInterface cEjb;
> > >
> > >     @Overr aide
> > >     public void methodB() {
> > >     }
> > >
> > >     @Override
> > >     public EJBHome getEJBHome() throws RemoteException {
> > >         // TODO Auto-generated method stub
> > >         return null;
> > >     }
> > >
> > >     @Override
> > >     public Handle getHandle() throws RemoteException {
> > >         // TODO Auto-generated method stub
> > >         return null;
> > >     }
> > >
> > >     @Override
> > >     public Object getPrimaryKey() throws RemoteException {
> > >         // TODO Auto-generated method stub
> > >         return null;
> > >     }
> > >
> > >     @Override
> > >     public boolean isIdentical(EJBObject obj) throws RemoteException {
> > >         // TODO Auto-generated method stub
> > >         return false;
> > >     }
> > >
> > >     @Override
> > >     public void remove() throws RemoteException, RemoveException {
> > >         // TODO Auto-generated method stub
> > >
> > >     }
> > >
> > > }
> > > *
> > > interface BInterface:*
> > >
> > > package openejbtest;
> > >
> > > import javax.ejb.EJBObject;
> > >
> > > public interface BInterface extends EJBObject {
> > >     public void methodB();
> > > }
> > >
> > > Best regards,
> > > Miguel
> > >
> > > --
> > > Miguel Figueiredo
> > > Software Developer
> > > http://jaragua.dyndns.org
> > >
> > > "I'm a pretty lazy person and am prepared to work quite hard in order
> to
> > > avoid work."
> > > -- Martin Fowler
> > >
> >
>
>
>
> --
> Miguel Figueiredo
> Software Developer
> http://jaragua.dyndns.org
>
> "I'm a pretty lazy person and am prepared to work quite hard in order to
> avoid work."
> -- Martin Fowler
>

Reply via email to