Posted By:
Purnendu_Das
Posted On:
Friday, October 13, 2006 01:36 PM
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.INITIA
More>>
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);
<<Less