?
Solved

javax.naming.NameNotFoundException

Posted on 2003-03-16
8
Medium Priority
?
2,664 Views
Last Modified: 2013-11-24
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
Comment
Question by:prem_kumar79
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 1

Expert Comment

by:gwang77
ID: 8149540
JNDI name wrong, you can try "ejb/Emp".
Object empHome = ctx.lookup("ejb/Emp");
0
 
LVL 35

Expert Comment

by:girionis
ID: 8150585
 Try to change your lookup to: java:comp/env/ejb/Emp and see what happens.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 8151030
Also, try changing this:

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

to this:

env.put(Context.PROVIDER_URL, "ormi://localhost:23791");
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:prem_kumar79
ID: 8151041
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
 
LVL 35

Expert Comment

by:TimYates
ID: 8151563
comment out the

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

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

Same error?
0
 
LVL 3

Expert Comment

by:wide_awake
ID: 8153561
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
 

Author Comment

by:prem_kumar79
ID: 8165233
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
 
LVL 35

Accepted Solution

by:
girionis earned 1000 total points
ID: 8165295
 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question