Discussion Locked

EJB client side code (Stateless Session Bean)

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

i have created a jar file for ejb but I am getting error in creating client side code. The error is:
C:\PRAMODJ\EJB\HELLO>javac -d . HelloClient.java
HelloClient.java:25: cannot resolve symbol
symbol : class HelloHome
location: class hello.HelloClient
HelloHome home = (HelloHome)PortableRemoteObject.narrow(
obj,HelloHome.class);
^
HelloClient.java:25: cannot resolve symbol
symbol : class HelloHome
location: class hello.HelloClient
HelloHome home = (HelloHome)PortableRemoteObject.narrow(
obj,HelloHome.class);
^
HelloClient.java:25: cannot resolve symbol
symbol : class HelloHome
location: class hello.HelloClient
HelloHome home = (HelloHome)PortableRemoteObject.narrow(
obj,HelloHome.class);

^
HelloClient.java:26: cannot resolve symbol
symbol : class Hello
location: class hello.HelloClient
Hello hello = home.create();
^
4 errors

And the Code for the program is:

Program for Client:
package hello;

import java.rmi.RemoteException;
import java.util.Properties;

import javax.ejb.CreateException;
import javax.ejb.RemoveException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

public class HelloClient
{
public static void main(String args[])
{
try
{
System.out.println("In client Code .... ");
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
props.put(Context.PROVIDER_URL,"t3://localhost:7001");
Context ctx = new InitialContext(props);
Object obj = ctx.lookup("MyHello");
HelloHome home = (HelloHome)PortableRemoteObject.narrow(obj,HelloHome.class);
Hello hello = home.create();
System.out.println("In Client " +hello.hello());
}

5 replies

by g...

Looks like you have a problem with the class HelloHome. The program certainly cannot find what HelloHome is. Looks like you need a creator or something like that.

by chellaganesh

It seems like a class path problom (If the name of the class and file names are not different).

Solution:
1. You may have to package all the files.
2. Otherwise import the files.

by zieshen

Hi all,
i wanna know the jndi properties string for Eclips server.can any one help ??

This discussion is closed to new replies.