• Post Reply Bookmark Topic Watch Topic
  • New Topic

error while compiling in sample ejb program  RSS feed

 
ashok ganesan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i m try to compile the client side program as specified in head first ejb but i get the following error

javac AdviceClient.java
AdviceClient.java:4: package javax.ejb does not exist
import javax.ejb.*;
^
AdviceClient.java:17: cannot resolve symbol
symbol : class IntialContext
location: class AdviceClient
Context ic = new IntialContext();
^
AdviceClient.java:19: cannot access AdviceHome
bad class file: E:\projects\advice\classes\headfirst\AdviceHome.class
class file contains wrong class: headfirst.AdviceHome
Please remove or make sure it appears in the correct subdirectory of the classpath.
AdviceHome home = (AdviceHome)PortableRemoteObject.narrow(o,AdviceHome.class);


i could not understand what error is this pls someone could help me out

thanks in advance
 
Sumit Malik
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ashok ganesan,

What i can find out from your compilation error is that you haven't added necessary jar's(contains required class) in you classpath and hence the error. One more error you are getting over here is the name clashing of package name... So do check that also.....

Do change the package name and add necessary jar's to your classpath then you wont get this error..

Do let me know if i can assist you more.

Cheers !!!
Sumit Malik
 
ashok ganesan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i think there are some problem in classpath variable. i m not sure what are the directory paths that i should add to the classpath. at present my classpath variable contains e:\projects\advice\AdviceAppClient.jar;E:\Sun\AppServer\jdk\bin;C:\j2sdk1.4.2_04\bin;.;
my application server path is E:\Sun\AppServer

my client program (AdviceClient.java) ,AdviceApp.ear ,AdviceAppClient.jar
are placed in the folder E:\projects\advice

my actual bean programs ( Advice.class,AdviceBean.class,AdviceHome.class ) are in the folder E:\projects\advice\classes\headfirst
 
ashok ganesan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
malik could you tell me what things i should add to get my client program compiled
 
Sumit Malik
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Ashok Ganesan,

As per you classpath variable i dont understand why you have added jdk bin directory two times(ofcourse they are different one).. Do add ejb3.x jar with fully classified name because you importing javac.ejb.*; once you done with adding jars to classpath then close current command prompt and open new one. Do echo new classpath and if you see you added jar in that then do compile you java source file with updated classpath.

Do change you package name also and then compile it. I hope by making these modification you can compile you source.
 
ashok ganesan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
thanks malik

my client program is

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


public class AdviceClient
{
public static void main(String[] arg)
{
new AdviceClient().go();
}
public void go()
{
try{
Context ic = new IntialContext();
Object o = ic.lookup("Advisor");
AdviceHome home = (AdviceHome)PortableRemoteObject.narrow(o,AdviceHome.class);
Advice advisor = home.create();
System.out.println(advisor.getAdvice());


}catch(Exception e)
{
e.printStackTrace();
}
}
}

here the IntialContext() is presnt in javax.naming package but in my Sun Java System Application Server Platform Edition 9 lib folder i have javaee.jar file which doesnt have the naming package .. where should i get the jars that supports this package

thanks

ashok
 
ashok ganesan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sorry for the trouble got it by adding both j2ee and javaee jar files i got it and thanks malik
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!