EJB client side code (Stateless Session Bean) - TechRepublic
General discussion
December 27, 2004 at 02:40 AM
pramodbpatel

EJB client side code (Stateless Session Bean)

by pramodbpatel . Updated 19 years, 7 months ago

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());
}

This discussion is locked

All Comments