Local Interface Error - Client to Session Bean

Hi,

I am trying out local interfaces and cannot get my example to work.

In summary I am using WebLogic and am getting the following error

javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundException: remaining name: /app/ejb/ejb20_basic_statefulSession.jar#statefulSession/local-home

<<no stack trace available>>

Can anyone see what I am doing wrong?

thanks in advance,

Kevin

my ejb-jar.xml file looks as follows ...

<ejb-jar>

<enterprise-beans>

<session>

<ejb-name>statefulSession</ejb-name>

<local-home>examples.ejb20.basic.statefulSession.LocalTraderHome</local-home>

<local>examples.ejb20.basic.statefulSession.LocalTrader</local>

<ejb-class>examples.ejb20.basic.statefulSession.TraderBean</ejb-class>

<session-type>Stateful</session-type>

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

....

</ebj-jar>

My weblogic-ejb-jar file looks as follows ....

<weblogic-ejb-jar>

<weblogic-enterprise-bean>

<ejb-name>statefulSession</ejb-name>

<local-jndi-name>ejb20-statefulSession-TraderHome</local-jndi-name>

</weblogic-enterprise-bean>

</weblogic-ejb-jar>

My Client code looks as follows ...

// Lookup the beans home using JNDI

Context ctx = getInitialContext();

try {

Object home = ctx.lookup("ejb20-statefulSession-TraderHome");

return (LocalTraderHome) narrow(home, LocalTraderHome.class);

} catch (NamingException ne) {

ne.printStackTrace();

throw ne;

}

private Context getInitialContext() throws NamingException {

try {

// Get an InitialContext

Properties h = new Properties();

h.put(Context.INITIAL_CONTEXT_FACTORY,

"weblogic.jndi.WLInitialContextFactory");

h.put(Context.PROVIDER_URL, url);

return new InitialContext(h);

} catch (NamingException ne) {

log("We were unable to get a connection to the WebLogic server at "+url);

log("Please make sure that the server is running.");

ne.printStackTrace();

throw ne;

}

[2311 byte] By [kkelleher] at [2007-9-27 14:06:02]
# 1

Hi,

A local client view of an EJB can be accessed only from a local client (which can be a entity,session, message driven bean). Or in other words, a local client should be located in the same JVM as the bean providing the local views. You can write another session bean which calls your TraderBean's local views and this new bean can be called remotely from your standalone program.

Cheers

clementv at 2007-7-5 21:55:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Thanks but my client is in the same VM ( deployed on the same machine!)

Kevin

> Hi,

> A local client view of an EJB can be accessed only

> ly from a local client (which can be a entity,session,

> message driven bean). Or in other words, a local

> client should be located in the same JVM as the bean

> providing the local views. You can write another

> session bean which calls your TraderBean's local views

> and this new bean can be called remotely from your

> standalone program.

> Cheers

kkelleher at 2007-7-5 21:55:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Hi Kevin,

OK, this is what I tried. I tried accessing a perfectly working CMP EJB through its local view from a standalone client program. Both the client program and the application server are on the same machine.

It threw the following error on the context lookup.

-

javax.naming.ConfigurationException. Root exception is java.rmi.MarshalException: error marshalling return; nested exception is:

java.io.NotSerializableException: ejb20test1.DeptBean_19krp_LocalHomeImpl

-

Even though its the same machine, looking up a local view from outside the server namespace gives this exception because its still a remote call involving serialization. My EJB's local view works fine when its called from another session bean.

Cheers

clementv at 2007-7-5 21:55:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

Hi,

while starting the weblogic, if u see the startWeblogic.bat file, they will use "java -hotspot -64 bit then class file",so weblogic already started the JVM.(when jvm will active..? only at the time of calling the java exe). and now u r trying to access that local bean from the standalone program.ie u r also giving "java client" so there is no connection between these two memory area then where the point is coming for the pass by refenece and local Object..?

--Mahendran

vkm_xy at 2007-7-5 21:55:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...