cancel
Showing results for 
Search instead for 
Did you mean: 

NameNotFoundException during JNDI lookup

Former Member
0 Kudos

Hi !

I am really new in developing java on SAP Netweaver 7.1. In the past i used JBOSS.

Unfortunately i dont find the solution that fixes my problem in the forums here.

My problem is as follows:

I created a stateless session bean (EJB 3.0) in the developerstudio named "WorkerBean.java" and the interface "WorkerRemote.java". Its only a hello world bean.

Then I deployed the WorkerEAR with the DeveloperStudio on my NetWeaver 7.1 without problems. The Netweaver stans in the local network in the company.

Now I wrote a java client to call and test the WorkerBean via remote over JNDI lookup.

The client looks this way:


public class Main {
public static void main(String[] args){
        
try{	
      Properties props = new Properties();
      props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
      props.put(Context.PROVIDER_URL, "10.XXX.17.XXX:50004");
        
        Context ctx = new InitialContext(props);
			
        Object o = ctx.lookup("ejb:/sap.com/WorkerEAR/REMOTE/WorkerBean/WorkerRemote");
        WorkerRemote ref = (WorkerRemote)PortableRemoteObject.narrow(o, WorkerBean.class);
        String msg = ref.sayHello();
        System.out.println(">>>"+ ref.sayHello());
.....
...

So now I get a Error when I execute the main class:

com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException:

Path to object does not exist at ejb:, the whole lookup name is ejb:/sap.com/WorkerEAR/REMOTE/WorkerBean/WorkerRemote.

at com.sap.engine.services.jndi.implserver.ServerContextImpl.getLastContainer(ServerContextImpl.java:241)

at com.sap.engine.services.jndi.implserver.ServerContextImpl.lookup(ServerContextImpl.java:559)

at com.sap.engine.services.jndi.implserver.ServerContextRedirectableImpl.lookup(ServerContextRe

I dont understand, where the problem is, because i did the same as described on this sap help page:

http://help.sap.com/saphelp_nwce10/helpdata/en/45/e692b2cfaa5591e10000000a1553f7/frameset.htm

note: I dont setup any ejb-j2ee-engine.xml or application-j2ee-engine.xml because I thought its not nesscerary.

Can anybody help me please ?

Thanks in advance and sry for my english,

hendrik

Accepted Solutions (1)

Accepted Solutions (1)

former_member589677
Discoverer
0 Kudos

Hi Henne,

I would propose you to use the simplest format of the ejb scheme lookup strings, try just:

"ejb:/interfaceName=test.WorkerRemote"

/you are right the interface name property is the name of the EJB business interface you want to use as client view after the lookup operation/

or

"ejb:/beanName=WorkerBean,interfaceName=test.WorkerRemote"

/beanName property is the name of the bean. By default the bean name in ejb 3.0 is the bean class name (without the package)/

Best Regards,

Krasimir Topchiyski

Former Member
0 Kudos

Hi,

so many thx for your answers, problem solved.

The final lookupstring was now:

"Object o = ctx.lookup("ejb:/interfaceName=de.itinformatik.mes.ejb.WorkerRemote")"

I guess the interface is to look up with its full qualified name.

so the package path has to be written in front of the remoteInterface.

But I had to include a ejb3xxx.jar in the project build path otherwise there was a "ClassDefNotFondException".

For example JBOSS comes with such a jboss-ejb3x.jar which I included. Its no JBOSS spezific I guess.

many thanks and greetz,

hendrik

Answers (2)

Answers (2)

former_member589677
Discoverer
0 Kudos

Hi Henne,

Yes you need to add the server's client libraries to the classpath:

<drive>:/usr/sap/XXX/YYY/j2ee/j2eeclient/sap.comtcjeclientlibimpl.jar

<drive>:/usr/sap/XXX/YYY/j2ee/j2eeclient/sap.comtcexception~impl.jar

<drive>:/usr/sap/XXX/YYY/j2ee/j2eeclient/sap.comtcloggingjavaimpl.jar

The jar names depend on the server version you use but I am sure that you will recognize them correctly.

And also don't forget to add the business interfaces ...

Best Regards,

Krasimir Topchiyski

Former Member
0 Kudos

Hi Henne,

Some points from the quoted help.sap.com page:

1. In addition to the standard properties you have to set the new property: props.put(Context.URL_PKG_PREFIXES, "com.sap.engine.services"), which is obligatory when you use the EJB lookup scheme. Comes as the first point in the Procedure.

2.The remote interface in the whole help.sap.com discussion has been referred to as test.RemoteInterface , while you have mentioned it as WorkerRemote . I've not worked on EJB 3.0 but, doesn't this apply to your case too, like the <some>.WorkerRemote...

Hope it helps.

Regards,

Alka.

Former Member
0 Kudos

Hi Alka,

thanks for your quick answer!

You are right with your hint at number 1:

... et the new property: props.put(Context.URL_PKG_PREFIXES, "com.sap.engine.services"), which is obligatory when you use the EJB lookup scheme....

I forgott this property and add this to my java client. Now the exception changed to:

......

javax.naming.NamingException: Error occurs while the EJB Scheme Context Factory trying to resolve ejb from scheme ejb:/sap.com/WorkerEAR/REMOTE/WorkerBean/WorkerRemote

at com.sap.engine.services.ejb3.runtime.impl.JNDIejbResolverContext.lookup(JNDIejbResolverContext.java:122)

at javax.naming.InitialContext.lookup(Unknown Source)

at de.itinformatik.mes.BeanClient.Main.main(Main.java:39)

.....

But what the realy confusing thing is to me at the sap.help.page linked above:

Why the remote interface is named "test.RemoteInterface" ???

Means this, that my remote Interface has to be named "test.WorkerRemote" ?

I changed my lookup string to:

"Object o = ctx.lookup("ejb:/sap.com/WorkerEAR/REMOTE/WorkerBean/test.WorkerRemote");" but the error still exsists. I dont know what the clue with the "test.RemoteInterface".

Thanks so far, Hendrik.

Edited by: henne123 on May 14, 2009 10:04 AM

Edited by: henne123 on May 14, 2009 10:09 AM