Two Laptop Bag*
The moose likes EJB and other Java EE Technologies and the fly likes Compile problem with client code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Compile problem with client code" Watch "Compile problem with client code" New topic
Author

Compile problem with client code

Chris Voge
Ranch Hand

Joined: Jul 25, 2005
Posts: 34
Hello. I am having an issue with compiling my client code.

What I have done so far...

-Compiled my java files.
-Created the jar from the class files
-Deployed the bean to the server and returned a client jar stub to my
code directory

I am creating a client program to interface with the bean and when I attempt to compile, I get:

C:\EJB\AdviceClient.java:21: cannot access AdviceHome
bad class file: .\AdviceHome.java
file does not contain class AdviceHome
Please remove or make sure it appears in the correct subdirectory of the classpath.
AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);
^
1 error

Tool completed with exit code 1

As you can see, I'm using textpad.

Here is my client code:

import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import headfirst.*;
import javax.ejb.*;

public class AdviceClient
{
public static void main(String[] args)
{
new AdviceClient().go();
}

public void go()
{
try
{
Context ic = new InitialContext();
Object o = ic.lookup("AdviceBean");

AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);

Advice advicebean = home.create();
System.out.println(advicebean.getAdvice() );
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}

I am using Head First EJB as a reference. You can probably download the rest
of the code from www.wickedlysmart.com if you like.

Let me know if you need anything else.

Thanks

Chris.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


bad class file: .\AdviceHome.java
file does not contain class AdviceHome

And does your AdviceHome.java file contain AdviceHome?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
 
subject: Compile problem with client code
 
Similar Threads
New to EJB
Running the headfirst ejb 1st chapter
Error compiling the AdviceClient.java
JBOSS - need help with my first ejb deployment and testing
Runtime error with AviceBean from HFE