• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2696
  • Last Modified:

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.NameNotFoundException: Emp not found

at com.evermind.server.rmi.RMIContext.lookup(RMIContext.java:124)

at javax.naming.InitialContext.lookup(InitialContext.java:350)

at Samplemypackage1.EmpClient.main(EmpClient.java:23)

Process exited with exit code 0.

package Samplemypackage1;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
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_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "prem");
env.put(Context.PROVIDER_URL, "ormi://localhost:23791/Emp");
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.RMIInitialContextFactory().getInitialContext(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.xaDataSource" exclusive-write-access="false" location="E:\forte4j\pointbase\databases\samples.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</remote>
<ejb-class>mypackage1.impl.EmpBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>mypackage1.EmpPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-field>
<field-name>id</field-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<field-name>dept</field-name>
</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.
0
prem_kumar79
Asked:
prem_kumar79
  • 2
  • 2
  • 2
  • +2
1 Solution
 
gwang77Commented:
JNDI name wrong, you can try "ejb/Emp".
Object empHome = ctx.lookup("ejb/Emp");
0
 
girionisCommented:
 Try to change your lookup to: java:comp/env/ejb/Emp and see what happens.
0
 
TimYatesCommented:
Also, try changing this:

env.put(Context.PROVIDER_URL, "ormi://localhost:23791/Emp");

to this:

env.put(Context.PROVIDER_URL, "ormi://localhost:23791");
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
prem_kumar79Author Commented:
Object empHome = ctx.lookup("ejb/Emp");

java:comp/env/ejb/Emp


env.put(Context.PROVIDER_URL, "ormi://localhost:23791/Emp");

to this:

env.put(Context.PROVIDER_URL, "ormi://localhost:23791");

Did not work. Showed the same error
0
 
TimYatesCommented:
comment out the

env.put(Context.PROVIDER_URL, "ormi://localhost:23791");

line and run the client local to the server...

Same error?
0
 
wide_awakeCommented:
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.
0
 
prem_kumar79Author Commented:
NamingEnumeration n= ctx.list("ormi://localhost:23791");
System.out.println(n.hasMore());

Returns “False”

The problem is only for CMP bean and not for Session or Sessionless beans.
0
 
girionisCommented:
 Are you 100% sure that you have deployed your bean under the name "Emp"? Also, if you are sure that this is the name are you sure that the bean has been deployed properly (any messages in the logs)? I also found this link: http://www.caucho.com/support/ejb-interest/0207/0018.html it might come in handy.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now