EJB3 jndi lookup problem in OC4J 

Joined:
04/09/2007
Posts:
753

September 20, 2009 16:52:19    Last update: March 22, 2010 01:28:49
When I assemble a session bean without the proprietary deployment descriptor (orion-ejb-jar.xml), OC4J generates one like this (as can be seen from the OC4J management console):
<?xml version="1.0" encoding="utf-8"?>

<orion-ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-ejb-jar-10_0.xsd" deployment-version="10.1.3.3.0" deployment-time="123d598f9ca" schema-major-version="10" schema-minor-version="0" >
      <enterprise-beans>
            <session-deployment name="SimpleBean" location="SimpleBean" local-location="simpleEjb_SimpleBeanLocal" persistence-filename="SimpleBean.test_default_group_1">
            </session-deployment>
      </enterprise-beans>
      <assembly-descriptor>
            <default-method-access>
                  <security-role-mapping name="&lt;default-ejb-caller-role&gt;" impliesAll="true" />
            </default-method-access>
      </assembly-descriptor>
</orion-ejb-jar>


So I use this code to lookup the EJB:
import javax.naming.Context;
import javax.naming.InitialContext;
.
.
.
Context ctx = new InitialContext();
Simple s = (Simple) ctx.lookup("simpleEjb_SimpleBeanLocal");


OC4J throws ClassCastException:
java.lang.ClassCastException: com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.ejb.StatelessSessionDefaultLocalHomeImpl


The JNDI browser (OC4J container home -> Administration -> JNDI browser) shows that the name simpleEjb_SimpleBeanLocal is bound to: com.evermind.server.ejb.StatelessSessionDefaultLocalHomeImpl

Solution:
Change the local name in the OC4J generated orion-ejb-jar.xml to simpleEjb_SimpleBeanLocal2 and put it in the EJB package. Redeploy.

The JNDI browser shows that simpleEjb_SimpleBeanLocal is still bound to com.evermind.server.ejb.StatelessSessionDefaultLocalHomeImpl. But simpleEjb_SimpleBeanLocal2 is bound to the right proxy: SimpleBean_LocalProxy_5f4b5e5.
Share |
| Comment  | Tags