JNDI Question org.omg.CosNaming.NamingContextPackage.NotFound

P

purnendu9

Hi,
I am new to JNDI
I created a App client and have deployed 2 ejb beans to the server. I
am getting the org.omg.CosNaming.NamingContextPackage.NotFound
error.
My code is as below

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
import com.titan.travelagent.TravelAgentRemote;
import com.titan.domain.Cabin;

public class Main {
public static void main(String [] args) {
try {
Properties p = new Properties();
p.put(Context.PROVIDER_URL, "iiop://localhost:3700" );
p.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.cosnaming.CNCtxFactory");
InitialContext jndiContext = new InitialContext(p);
// Context jndiContext = getInitialContext( );
Object ref = jndiContext.lookup("TravelAgentRemote");
TravelAgentRemote dao = (TravelAgentRemote)
PortableRemoteObject.narrow(ref,TravelAgentRemote.class);

********************************************************************************************
Now following are the ejbs i have created

package com.titan.travelagent;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;

import javax.persistence.PersistenceContext;

import com.titan.domain.Cabin;

@Stateless
public class TravelAgentBean implements TravelAgentRemote{
@PersistenceContext
(unitName="titan")
private EntityManager manager;

public void createCabin(Cabin cabin) {
manager.persist(cabin);
}

public Cabin findCabin(int pKey) {
return manager.find(Cabin.class, pKey);
}
}
*****************************************************

package com.titan.travelagent;

import javax.ejb.Remote;

import com.titan.domain.Cabin;

@Remote
public interface TravelAgentRemote {

public void createCabin(Cabin cabin);
public Cabin findCabin(int id);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top