[jboss-jira] [JBoss JIRA] Created: (EJBTHREE-1100) local-home-jndi-name

Shane Preater (JIRA) jira-events at lists.jboss.org
Fri Nov 2 09:39:56 EDT 2007


local-home-jndi-name
--------------------

                 Key: EJBTHREE-1100
                 URL: http://jira.jboss.com/jira/browse/EJBTHREE-1100
             Project: EJB 3.0
          Issue Type: Bug
    Affects Versions: AS 4.2.2.GA
         Environment: Windows XP
            Reporter: Shane Preater


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>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list