File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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\ cannot access AdviceHome
bad class file: .\
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()
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)

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

Let me know if you need anything else.


Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

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

And does your file contain AdviceHome?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Compile problem with client code
It's not a secret anymore!