• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Compile problem with client code

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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


And does your AdviceHome.java file contain AdviceHome?
 
mooooooo ..... tiny ad ....
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic