cancel
Showing results for 
Search instead for 
Did you mean: 

JNDI lookup problem

Former Member
0 Kudos

Hi,

I've got a problem with JNDI lookup. I am running the Preview of NetWeaver Application Server JEE 5 Edition and have created a stateless Session Bean SupplierAgentBean with local am remote interface (SupplierAgentLocal, SupplierAgentRemote). To test it from an external client I am using the following code:


        public static Context getInitialContext() throws javax.naming.NamingException {
		Properties props = new Properties();
		props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
		props.put(Context.PROVIDER_URL, "localhost:50004");
		Context jndiContext = new InitialContext(props);
		return jndiContext;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Supplier supplier = new Supplier();
			supplier.setSupplierName("Testname");
			supplier.setSupplierStreet("Teststreet");
			supplier.setSupplierZipcode(12345);
			supplier.setSupplierCity("Testcity");
			Context jndiContext = getInitialContext();
			//SupplierAgentLocal supplierAgentLocal = (SupplierAgentLocal) jndiContext.lookup("localejbs/SupplierAgent");
			SupplierAgentRemote supplierAgentRemote = (SupplierAgentRemote) PortableRemoteObject.narrow(jndiContext.lookup("SupplierAgent"), SupplierAgentRemote.class);
			supplierAgentLocal.createSupplier(supplier);
		} catch (NamingException ex) {
			ex.printStackTrace();
		}
	}

I am getting a NameNotFoundException (Object not found in lookup of SupplierAgent.) Calling the local interface (which has been commented out) does not work either. Any ideas?

Thanks

Arne

Accepted Solutions (1)

Accepted Solutions (1)

Vlado
Advisor
Advisor
0 Kudos

Hi Arne,

Hopefully this article gets your questions answered: <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/605ff5f2-e589-2910-3ead-e558376e6f3d">Accessing Enterprise JavaBeans Using JNDI in SAP NetWeaver AS, Java EE 5 Edition</a>.

Cheers,

Vladimir

PS: I'll move this thread to the forum dedicated to Java EE 5 @ SAP.

Answers (0)