• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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?
 
I once met a man from Nantucket. He had a tiny ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic