Uploaded image for project: 'EJB 3.0'
  1. EJB 3.0
  2. EJBTHREE-1100

local-home-jndi-name

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • AS 4.2.2.GA
    • None
    • None

    Description

      jboss.xml version 3.0 local-home-jndi-name does not work as expected.
      The proxy which ends up deployed under the given name is actually the local interface not the local home interface.

      Code to reproduce:
      Remote bean:
      public class RemoteHomeTestEJB implements SessionBean {

      private SessionContext context = null;

      /*

      • (non-Javadoc)
      • @see javax.ejb.SessionBean#ejbActivate()
        */
        public void ejbActivate() throws EJBException, RemoteException { // TODO Auto-generated method stub }

        /*
        * (non-Javadoc)
        *
        * @see javax.ejb.SessionBean#ejbPassivate()
        */
        public void ejbPassivate() throws EJBException, RemoteException { // TODO Auto-generated method stub }

      /*

      • (non-Javadoc)
      • @see javax.ejb.SessionBean#ejbRemove()
        */
        public void ejbRemove() throws EJBException, RemoteException { // TODO Auto-generated method stub }

        public void ejbCreate() { //Do nothing. }

        /*
        * (non-Javadoc)
        *
        * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
        */
        public void setSessionContext(SessionContext ctx) throws EJBException,
        RemoteException { context = ctx; }

        public String getHello() {
        try { LocalHomeTestHome home = null; home = ServiceLocator.locateHome(LocalHomeTestHome.class, "java:comp/env/local/LocalHomeTest"); return home.create().getHello(); } catch (Exception e) { StringWriter stringWriter = new StringWriter(); PrintWriter writer = new PrintWriter(stringWriter); e.printStackTrace(writer); return stringWriter.toString(); }
        }
        }

        ServiceLocater.java:
        public class ServiceLocator {
        private static final Logger LOG = Logger.getLogger(ServiceLocator.class);

        @SuppressWarnings("unchecked")
        public static <T> T locateHome(Class<T> clazz, String location)
        throws NamingException {
        T home = null;
        Context ic = new InitialContext();

        Object potentialHome = ic.lookup(location);
        if (clazz.isInstance(potentialHome)) { home = (T) potentialHome; } else { home = (T) PortableRemoteObject.narrow(potentialHome, clazz); }
        return home;
        }
        }

        Local bean:

        public class LocalHomeTestEJB implements SessionBean {

        /* (non-Javadoc)
        * @see javax.ejb.SessionBean#ejbActivate()
        */
        public void ejbActivate() throws EJBException, RemoteException { // TODO Auto-generated method stub }

      /* (non-Javadoc)

      • @see javax.ejb.SessionBean#ejbPassivate()
        */
        public void ejbPassivate() throws EJBException, RemoteException { // TODO Auto-generated method stub }

        public void ejbCreate() { //Do nothing. }

        /* (non-Javadoc)
        * @see javax.ejb.SessionBean#ejbRemove()
        */
        public void ejbRemove() throws EJBException, RemoteException { // TODO Auto-generated method stub }

      /* (non-Javadoc)

      • @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
        */
        public void setSessionContext(SessionContext ctx) throws EJBException,
        RemoteException { // TODO Auto-generated method stub }

      public String getHello()

      { return "Hello from Aerosystems"; }

      }

      ejb-jar.xml:
      <ejb-jar version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">

      <description>Simple migration testing to see how to move to EJB 3</description>
      <display-name>EjbMigration</display-name>

      <enterprise-beans>
      <session>
      <description><![CDATA[EcardGenerationFacadeSessionEJB Bean]]></description>
      <display-name>LocalHomeTest</display-name>

      <ejb-name>LocalHomeTest</ejb-name>
      <remote>com.aeroint.ejbtest.common.RemoteHomeTestInterface</remote>
      <local-home>com.aeroint.ejbtest.server.session.LocalHomeTestHome</local-home>
      <local>com.aeroint.ejbtest.server.session.LocalHomeTestInterface</local>
      <ejb-class>com.aeroint.ejbtest.server.session.LocalHomeTestEJB</ejb-class>

      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      </session>

      <session>
      <description><![CDATA[EcardUpdateFacadeSessionEJB Bean]]></description>
      <display-name>RemoteHomeTest</display-name>

      <ejb-name>RemoteHomeTest</ejb-name>

      <home>com.aeroint.ejbtest.common.RemoteHomeTestHome</home>
      <remote>com.aeroint.ejbtest.common.RemoteHomeTestInterface</remote>
      <ejb-class>com.aeroint.ejbtest.server.facade.RemoteHomeTestEJB</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      <ejb-local-ref >
      <ejb-ref-name>local/LocalHomeTest</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      <local-home>com.aeroint.ejbtest.server.session.LocalHomeTestHome</local-home>
      <local>com.aeroint.ejbtest.server.session.LocalHomeTestInterface</local>
      <ejb-link>LocalHomeTest</ejb-link>
      </ejb-local-ref>

      </session>
      </enterprise-beans>
      </ejb-jar>

      jboss.xml:
      <jboss xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
      version="3.0">
      <enterprise-beans>
      <session>
      <ejb-name>RemoteHomeTest</ejb-name>
      <home-jndi-name>remote/RemoteHomeTest</home-jndi-name>
      </session>
      <session>
      <ejb-name>LocalHomeTest</ejb-name>
      <local-home-jndi-name>local/LocalHomeTest</local-home-jndi-name>
      </session>
      </enterprise-beans>
      </jboss>

      Attachments

        Activity

          People

            Unassigned Unassigned
            zagarol Shane Preater (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: