prem_kumar79
asked on
javax.naming.NameNotFoundException
able to deploy CMP bean to standalone OC4J (9.0.3.0.0) via JDeveloper Version 9.0.2.798. But, when I try to access bean following error is thrown.
javax.naming.NameNotFoundE xception: Emp not found
at com.evermind.server.rmi.RM IContext.l ookup(RMIC ontext.jav a:124)
at javax.naming.InitialContex t.lookup(I nitialCont ext.java:3 50)
at Samplemypackage1.EmpClient .main(EmpC lient.java :23)
Process exited with exit code 0.
package Samplemypackage1;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContex t;
import mypackage1.Emp;
import mypackage1.EmpHome;
import java.util.Collection;
import java.util.Iterator;
public class EmpClient
{
public static void main(String [] args)
{
EmpClient empClient = new EmpClient();
try
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CO NTEXT_FACT ORY, "com.evermind.server.rmi.R MIInitialC ontextFact ory");
env.put(Context.SECURITY_P RINCIPAL, "admin");
env.put(Context.SECURITY_C REDENTIALS , "prem");
env.put(Context.PROVIDER_U RL, "ormi://localhost:23791/Em p");
Context ctx = new InitialContext(env);
EmpHome empHome = (EmpHome)ctx.lookup("Emp") ;
}
catch(Throwable ex)
{
ex.printStackTrace();
}
}
}
The error occurs when it looks for the bean
EmpHome empHome = (EmpHome)ctx.lookup("Emp") ;
There is no problem in the deployment process it makes connection to the Pointbase database while getting deployed.
The bean files are in application directory plus application-deployments directory too.
There is no problem with Session or Sessionless bean.
Even after changing the code to
Context ctx = new com.evermind.server.rmi.RM IInitialCo ntextFacto ry().getIn itialConte xt(env);
//EmpHome empHome = (EmpHome)ctx.lookup("Emp") ;
Object empHome = ctx.lookup("Emp");
the error is not rectified.
The server.xml has
<application name="Emp" path="../applications/Emp. ear" auto-start="true" />
and ejb-jar.xml has
<ejb-name>Emp</ejb-name>
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" "http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd">
<orion-ejb-jar>
<enterprise-beans>
<entity-deployment name="Emp" copy-by-value="false" data-source="com.pointbase .xa.xaData Source" exclusive-write-access="fa lse" location="E:\forte4j\point base\datab ases\sampl es.dbn" table="EMP">
<primkey-mapping>
<cmp-field-mapping>
<fields>
<cmp-field-mapping name="id" persistence-name="ID" persistence-type="INTEGER( 10)"/>
</fields>
</cmp-field-mapping>
</primkey-mapping>
<cmp-field-mapping name="id" persistence-name="ID" persistence-type="INTEGER( 10)"/>
<cmp-field-mapping name="name" persistence-name="NAME" persistence-type="VARCHAR( 20)"/>
<cmp-field-mapping name="dept" persistence-name="DEPT" persistence-type="VARCHAR( 2)"/>
</entity-deployment>
</enterprise-beans>
<assembly-descriptor>
<default-method-access>
<security-role-mapping name="<default-ejb-caller- role>" impliesAll="true"/>
</default-method-access>
</assembly-descriptor>
</orion-ejb-jar>
<?xml version = '1.0' encoding = 'windows-1252'?>
<!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>
<entity>
<description>Entity Bean ( Container-managed Persistence )</description>
<display-name>Emp</display -name>
<ejb-name>Emp</ejb-name>
<home>mypackage1.EmpHome</ home>
<remote>mypackage1.Emp</re mote>
<ejb-class>mypackage1.impl .EmpBean</ ejb-class>
<persistence-type>Containe r</persist ence-type>
<prim-key-class>mypackage1 .EmpPK</pr im-key-cla ss>
<reentrant>False</reentran t>
<cmp-field>
<field-name>id</field-name >
</cmp-field>
<cmp-field>
<field-name>name</field-na me>
</cmp-field>
<cmp-field>
<field-name>dept</field-na me>
</cmp-field>
</entity>
</enterprise-beans>
</ejb-jar>
I think JNDI is problem. Should I specify it somewhere?
I do not what is wrong with the code. Please help.
javax.naming.NameNotFoundE
at com.evermind.server.rmi.RM
at javax.naming.InitialContex
at Samplemypackage1.EmpClient
Process exited with exit code 0.
package Samplemypackage1;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContex
import mypackage1.Emp;
import mypackage1.EmpHome;
import java.util.Collection;
import java.util.Iterator;
public class EmpClient
{
public static void main(String [] args)
{
EmpClient empClient = new EmpClient();
try
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CO
env.put(Context.SECURITY_P
env.put(Context.SECURITY_C
env.put(Context.PROVIDER_U
Context ctx = new InitialContext(env);
EmpHome empHome = (EmpHome)ctx.lookup("Emp")
}
catch(Throwable ex)
{
ex.printStackTrace();
}
}
}
The error occurs when it looks for the bean
EmpHome empHome = (EmpHome)ctx.lookup("Emp")
There is no problem in the deployment process it makes connection to the Pointbase database while getting deployed.
The bean files are in application directory plus application-deployments directory too.
There is no problem with Session or Sessionless bean.
Even after changing the code to
Context ctx = new com.evermind.server.rmi.RM
//EmpHome empHome = (EmpHome)ctx.lookup("Emp")
Object empHome = ctx.lookup("Emp");
the error is not rectified.
The server.xml has
<application name="Emp" path="../applications/Emp.
and ejb-jar.xml has
<ejb-name>Emp</ejb-name>
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" "http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd">
<orion-ejb-jar>
<enterprise-beans>
<entity-deployment name="Emp" copy-by-value="false" data-source="com.pointbase
<primkey-mapping>
<cmp-field-mapping>
<fields>
<cmp-field-mapping name="id" persistence-name="ID" persistence-type="INTEGER(
</fields>
</cmp-field-mapping>
</primkey-mapping>
<cmp-field-mapping name="id" persistence-name="ID" persistence-type="INTEGER(
<cmp-field-mapping name="name" persistence-name="NAME" persistence-type="VARCHAR(
<cmp-field-mapping name="dept" persistence-name="DEPT" persistence-type="VARCHAR(
</entity-deployment>
</enterprise-beans>
<assembly-descriptor>
<default-method-access>
<security-role-mapping name="<default-ejb-caller-
</default-method-access>
</assembly-descriptor>
</orion-ejb-jar>
<?xml version = '1.0' encoding = 'windows-1252'?>
<!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>
<entity>
<description>Entity Bean ( Container-managed Persistence )</description>
<display-name>Emp</display
<ejb-name>Emp</ejb-name>
<home>mypackage1.EmpHome</
<remote>mypackage1.Emp</re
<ejb-class>mypackage1.impl
<persistence-type>Containe
<prim-key-class>mypackage1
<reentrant>False</reentran
<cmp-field>
<field-name>id</field-name
</cmp-field>
<cmp-field>
<field-name>name</field-na
</cmp-field>
<cmp-field>
<field-name>dept</field-na
</cmp-field>
</entity>
</enterprise-beans>
</ejb-jar>
I think JNDI is problem. Should I specify it somewhere?
I do not what is wrong with the code. Please help.
Try to change your lookup to: java:comp/env/ejb/Emp and see what happens.
Also, try changing this:
env.put(Context.PROVIDER_U RL, "ormi://localhost:23791/Em p");
to this:
env.put(Context.PROVIDER_U RL, "ormi://localhost:23791");
env.put(Context.PROVIDER_U
to this:
env.put(Context.PROVIDER_U
ASKER
Object empHome = ctx.lookup("ejb/Emp");
java:comp/env/ejb/Emp
env.put(Context.PROVIDER_U RL, "ormi://localhost:23791/Em p");
to this:
env.put(Context.PROVIDER_U RL, "ormi://localhost:23791");
Did not work. Showed the same error
java:comp/env/ejb/Emp
env.put(Context.PROVIDER_U
to this:
env.put(Context.PROVIDER_U
Did not work. Showed the same error
comment out the
env.put(Context.PROVIDER_U RL, "ormi://localhost:23791");
line and run the client local to the server...
Same error?
env.put(Context.PROVIDER_U
line and run the client local to the server...
Same error?
Try using
ctx.list("ormi://localhost :23791");
to get an enumeration of all the bound objects' names (as a NamingEnumeration), then iterate through and see what's in there.
-Mark.
ctx.list("ormi://localhost
to get an enumeration of all the bound objects' names (as a NamingEnumeration), then iterate through and see what's in there.
-Mark.
ASKER
NamingEnumeration n= ctx.list("ormi://localhost :23791");
System.out.println(n.hasMo re());
Returns “False”
The problem is only for CMP bean and not for Session or Sessionless beans.
System.out.println(n.hasMo
Returns “False”
The problem is only for CMP bean and not for Session or Sessionless beans.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Object empHome = ctx.lookup("ejb/Emp");