Follow via:
RSS
Email Alert
Question
0 Votes
+ -

EJB client side code (Stateless Session Bean)

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());
}
Tags: programming
27th Dec 2004

Answers (5)

0 Votes
+ -
Point value changed by question poster.
27th Dec 2004
0 Votes
+ -
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.
11th Jan 2005
0 Votes
+ -
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.
30th Nov 2005
0 Votes
+ -
You have to copy the remote/home class files into client folder and import them in the client java file.

See http://www.theserverside.com/discussions/thread.tss?thread_id=9197.
21st Jun 2006
0 Votes
+ -
Jndi Properties for eclips server
Hi all,
i wanna know the jndi properties string for Eclips server.can any one help ??
29th Nov 2006
Answer the question
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.