cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to lookup home: Path to object does not exist at : java:comp#

Former Member
0 Kudos

Hallo,

I do not understand why I am getting the exception:

Unable to lookup home: Path to object does not exist at : java:comp#

if i have defined in the ejb-j2ee-engine.xml the jndi name:

<enterprise-beans>

<enterprise-bean>

<ejb-name>MyConverterBean</ejb-name>

<jndi-name>MyConverterBean</jndi-name>

<session-props/>

</enterprise-bean>

</enterprise-beans>

and in the ejb-jar.xml :

<enterprise-beans>

<session>

<description>the converter bean</description>

<display-name>MyConverter</display-name>

<ejb-name>MyConverterBean</ejb-name>

<home>converter.MyConverterHome</home>

<remote>converter.MyConverter</remote>

<local-home>converter.MyConverterLocalHome</local-home>

<local>converter.MyConverterLocal</local>

<ejb-class>converter.MyConverterBean</ejb-class>

<session-type>Stateless</session-type>

<transaction-type>Container</transaction-type>

</session>

</enterprise-beans>

I am creating the EJB in this way:

ic = new InitialContext();

objRef = ic.lookup("java:comp/env/ejb/MyConverter");

home = (MyConverterHome)PortableRemoteObject.narrow(objRef, MyConverterHome.class);

converter = home.create();

I checked in the Administrator tool under JDNI / ejbContext and I can see MyConverterBean in the list.

Do you have any idea what I am doing wrong?

thanks a lot for your help,

SAPLernen

Accepted Solutions (1)

Accepted Solutions (1)

Vlado
Advisor
Advisor
0 Kudos

Hi SAPLernen,

I guess you're doing the lookup from a standalone java program. Then I can see two errors in your coding:

1) You have to provide parameters when creating the InitialContext in the following way:

Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
p.put(Context.PROVIDER_URL, "<server_host>:<p4_port>");
p.put(Context.SECURITY_PRINCIPAL, "<admin_user>");
p.put(Context.SECURITY_CREDENTIALS, "<password>");
InitialContext ic = new InitialContext(p);

2) A standalone client doesn't have the "java:comp/env" JNDI environment that J2EE (server-side) components have. Which means that you have to pass just the jndi-name of your EJB in the lookup operation, like this:

objRef = ic.lookup("MyConverterBean");

Hope that helps!

Vladimir

Former Member
0 Kudos

Hallo Vladimir,

I am calling this code from a jsp Page, which it is in a WAR file contained in the EAR file. I have the following code:

<%@ page import="converter.MyConverter, converter.MyConverterHome, javax.ejb., java.math., javax.naming.*, javax.rmi.PortableRemoteObject, java.rmi.RemoteException" %>

<%!

private MyConverter converter = null;

private Object objRef = null;

private MyConverterHome home = null;

private InitialContext ic = null;

public void jspInit() {

try {

ic = new InitialContext();

objRef = ic.lookup("java:comp/env/ejb/MyConverter");

home = (MyConverterHome)PortableRemoteObject.narrow(objRef, MyConverterHome.class);

converter = home.create();

} catch (RemoteException ex) {

ex.printStackTrace();

} catch (CreateException ex) {

ex.printStackTrace();

} catch (NamingException ex) {

ex.printStackTrace();

} catch( Exception e ) {

e.printStackTrace();

}

}

public void jspDestroy() {

converter = null;

}

%>

do you have any idea, what is going wrong?

best regards and thanks!

SAPLernen

Vlado
Advisor
Advisor
0 Kudos

Hi SAPLernen,

OK, then your code is just fine. Please check your web.xml - there you must have an ejb-ref declared:

<ejb-ref>
  <ejb-ref-name>ejb/MyConverter</ejb-ref-name>
  <ejb-ref-type>Session</ejb-ref-type>
  <home>converter.MyConverterHome</home>
  <remote>converter.MyConverter</remote>
</ejb-ref>

Hope that helps!

Vladimir

Former Member
0 Kudos

Hi Vladimir,

do you have some example or tutorial of how can i implement java proxies from a java stand alone application.

i allready make everyting but i'm still having problem.

this line give me a null

queryOutLocalHome = (UsersSyncMI_PortTypeLocalHome)ctx.lookup("java:comp/env/ejb/UsersSyncMI_PortTypeBean");

this is my java class that invoke my ejb java proxy

package com.gsk.xi.demo;

import java.util.Properties;

import javax.naming.Context;

import javax.naming.InitialContext;

import com.sap.aii.proxy.xiruntime.core.MessageSpecifier;

public class InvokeProxy {

private Object objRef = null;

private InitialContext ic = null;

public String getRole(String name, String pwd){

String role="0";

UsersSyncMI_PortTypeLocalHome queryOutLocalHome=null;

UsersSyncMI_PortTypeLocal queryOutLocal=null;

try{

Context ctx = null;

Object ref = null;

Properties p = new Properties();

p.put(Context.INITIAL_CONTEXT_FACTORY,"com.sap.engine.services.jndi.InitialContextFactoryImpl");

p.put(Context.PROVIDER_URL, "buasapp012.gwamericas.corpnet1.com:50004");

p.put(Context.SECURITY_PRINCIPAL, "J2EE_ADMIN");

p.put(Context.SECURITY_CREDENTIALS, "was1234");

ctx = new InitialContext();

//objRef = ic.lookup("java:comp/env/ejb/UsersSyncMI_PortTypeBean");

//queryOutLocalHome = (UsersSyncMI_PortTypeLocalHome)PortableRemoteObject.narrow(objRef, UsersSyncMI_PortTypeLocalHome.class);

queryOutLocalHome = (UsersSyncMI_PortTypeLocalHome)ctx.lookup("java:comp/env/ejb/UsersSyncMI_PortTypeBean");

queryOutLocal = queryOutLocalHome.create();

MessageSpecifier msg = queryOutLocal.$messageSpecifier();

msg.setSenderService("JAVA");

queryOutLocal.$messageSpecifier(msg);

UserDT_Type reqtype = new UserDT_Type();

reqtype.setUsername(name);

reqtype.setPassword(pwd);

UsersDBMTResponse_Type response = new UsersDBMTResponse_Type();

response = queryOutLocal.usersSyncMI(reqtype);

role = role + response.getStatementResponse().getRow().getRole();

}

catch(Exception ex){

System.out.println(ex.getMessage());

}

return role;

}

} //end of class

thanks for your time

Lionel

Answers (0)