Hi All
I'm using Oracle Application Server(OC4J) for
J2EE. i created an application of Stateless Session Bean on j2sdkee1.3.1, & it is working fine on it. Same Application (an .ear file) i deployed on OC4J. But it is giving an error NoInitialContextException, fails at lookup.
The code is as follows to call beans
<%
InitialContext ic = new InitialContext();
Object ob = ic.lookup("ejb/beans.SimpleSessionBean");
%>
"ejb/beans.SimpleSessionBean" is a JNDI name for session bean
if i used another method
<%
Hashtable env = new Hashtable();
env.put (Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory");
........
%>
Though i've oc4j.jar in "J2EE_HOME"\lib directory, it throws an error ClassNotFoundException :com.evermind.server.rmi.RMIInitialContextFactory
Application contains a method getEchoString(
String):String & an index.jsp page calling a bean's method.
i created ejb-jar.xml manually. The contents are as follows
--------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN' 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>SimpleSessionBean</ejb-name>
<home>bean.SimpleSessionHome</home>
<remote>bean.SimpleSession</remote>
<ejb-class>bean.SimpleSessionBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
---------------------------------------------------------------------------
Contents of web.xml are as follows
--------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
<web-app>
<display-name>SimpleSessionWAR</display-name>
<
servlet>
<servlet-name>index</servlet-name>
<display-name>index</display-name>
<jsp-file>/index.jsp</jsp-file>
</servlet>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
---------------------------------------------------------------------------
Contents of application.xml are as follows
-----------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN' 'http://java.sun.com/dtd/application_1_3.dtd'>
<application>
<display-name>SimpleSessionApp</display-name>
<description>Application description</description>
<module>
<web>
<web-uri>war-ic.war</web-uri>
<context-root></context-root>
</web>
</module>
<module>
<ejb>ejb-jar-ic.jar</ejb>
</module>
</application>
---------------------------------------------------------------------------
Can anybody tell me the solution
Thanks in Advance :roll: