This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes head first ejb pg:57  client problem!!!please help urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "head first ejb pg:57  client problem!!!please help urgent" Watch "head first ejb pg:57  client problem!!!please help urgent" New topic
Author

head first ejb pg:57 client problem!!!please help urgent

pradeep arum
Ranch Hand

Joined: Oct 01, 2003
Posts: 130
hi all,
I tried the search facility and read all the material.. past 3 days i could not solve this problem ..this is my problem..
these are my paths...........
CLASSPATH ->c:\j2sdk1.4.2\jre\lib\rt.jar;c:\j2sdk1.4.2\lib\tools.jar;c:\j2sdk1.4.2\lib;.;c:\j2sdkee1.3.1\lib\j2ee.jar;
PATH->C:\j2sdkee1.3.1\bin;c:\j2sdk1.4.2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
J2EE_HOME->C:\j2sdkee1.3.1
JAVA_HOME->c:\j2sdk1.4.2

C:\projects\advice>javac -classpath %CLASSPATH%:adviceappClient.jar adviceclien.java
adviceclient.java:4: package headfirst does not exist
import headfirst.*;
^
adviceclient.java:21: cannot resolve symbol
symbol : class advicehome
location: class adviceclient
advicehome home=(advicehome) PortableRemoteObject.narrow(O,advicehome.class);
^
adviceclient.java:21: cannot resolve symbol
symbol : class advicehome
location: class adviceclient
advicehome home=(advicehome) PortableRemoteObject.narrow(O,advicehome.class);
^
adviceclient.java:21: cannot resolve symbol
symbol : class advicehome
location: class adviceclient
advicehome home=(advicehome) PortableRemoteObject.narrow(O,advicehome.class);
^
adviceclient.java:22: cannot resolve symbol
symbol : class advice
location: class adviceclient
advice advisor=home.create();
^
5 errors
thanks
Pradeep


SCJP1.4,SCBCD
Failure is not when you fall down; its only when you fail to get up again.
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
On the command line, all paths in the classpath argument should be separated with a semicolon on Windows systems as follows:
javac -classpath %CLASSPATH%;adviceappClient.jar adviceclient.java
I think this should do


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
pradeep arum
Ranch Hand

Joined: Oct 01, 2003
Posts: 130
thanks valentin,
it worked ....then how should i run this .....
please tell the command
thanks
pradeep
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Java applications can be run with the java command
(I think this question would be more appropriate in the Java in General - Beginner forum...)
pradeep arum
Ranch Hand

Joined: Oct 01, 2003
Posts: 130
Valetin,
this is what i got after i did the java command

C:\projects\advice>java adviceclient
Exception in thread "main" java.lang.NoClassDefFoundError: headfirst.advicehome
at adviceclient.class$(adviceclient.java:21)
at adviceclient.go(adviceclient.java:21)
at adviceclient.main(adviceclient.java:11)
please help...i know you can solve it easily
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
please check your classpath is correct or not ?
please see.
CLASSPATH=.;.......;%CLASSPATH%


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Jayant Kulkarni
Ranch Hand

Joined: Dec 02, 2003
Posts: 56
Hi Guys,
I am able to compile the above program on win2k machine with the following command -
D:\home\projects\advice>javac -classpath AdviceAppClient.jar AdviceClient.java
But when I tried to run the client using the following command, I am getting exception
D:\home\projects\advice>java -classpath %CLASSPATH%:AdviceAppClient.jar AdviceClient
Exception in thread "main" java.lang.NoClassDefFoundError: AdviceClient

Please advise.
Thanks in advance,
Jayant
My path settings are -
classpath= d:\j2sdk1.4.1_06\bin;d:\j2sdk1.4.1_06\lib;D:\Oracle\Ora81\orb\classes\yoj.jar;D:\Oracle\Ora81\orb\classes\share.zip;d:\j2sdkee1.3.1\bin;%CLASSPATH%
JAVA_HOME=D:\J2SDK1.4.1_06
J2EE_HOME=D:\j2sdkee1.3.1
[ January 28, 2004: Message edited by: Jayant Kulkarni ]
Magnus Stattin
Ranch Hand

Joined: Jun 05, 2003
Posts: 65
Please make sure that you have a dot in the CLASSPATH to include the current working directory.
Something like this:
CLASSPATH = "c:\j2sdkee1.3.1\lib\j2ee.jar;."
Hope it helps
/Magnus
Jayant Kulkarni
Ranch Hand

Joined: Dec 02, 2003
Posts: 56
No Magnus, it is still not working.
I added the dot and tried with -
D:\home\projects\advice>java -cp %CLASSPATH%:AdviceAppClient.jar AdviceClient
Exception in thread "main" java.lang.NoClassDefFoundError: AdviceClient
Please Help..!!!
Thanks,
Jayant
Magnus Stattin
Ranch Hand

Joined: Jun 05, 2003
Posts: 65
The problem seems to be that AdviceClient.class is not found. Make sure it is in the D:\home\projects\advice folder.
On windows you should use semicolons instead of colons between files on the classpath like this:
java -cp %CLASSPATH%;AdviceAppClient.jar AdviceClient
You are very close
/Magnus
[ January 28, 2004: Message edited by: Magnus Stattin ]
David Harrigan
Ranch Hand

Joined: Sep 16, 2003
Posts: 43
The ":" in your classpath is incorrect. This is a unix way of separating the classpath (or environment variables). In Windows/Dos you need to use the ";" version.
-=david=-
Jayant Kulkarni
Ranch Hand

Joined: Dec 02, 2003
Posts: 56
I tried all and am exhausted -
D:\home\projects\advice>java -cp %CLASSPATH%;AdviceAppClient.jar AdviceClient
Exception in thread "main" java.lang.NoClassDefFoundError: AdviceClient
I ensured that the file AdviceClient.class is in \home\projects\advice..
But no..it looks that some other problem.....
Again help..!!
Jayant
Jayant Kulkarni
Ranch Hand

Joined: Dec 02, 2003
Posts: 56
Hi All,
I tried again, restarted J2EE server and the class has been found.
Now when I run the client using -
D:\home\projects\advice>java -cp %CLASSPATH%;AdviceAppClient.jar AdviceClient
javax.naming.NoInitialContextException: Need to specify class name in environmen
t or system property, or as an applet parameter, or in an application resource f
ile: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
40)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
a:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at AdviceClient.go(AdviceClient.java:22)
at AdviceClient.main(AdviceClient.java:13)

I am getting above exception..!!
Please advise
Thanks,
Jayant :roll:
Jayant Kulkarni
Ranch Hand

Joined: Dec 02, 2003
Posts: 56
Ok,
I got the solution on this and I am able to successfully run the client -
Here what I found.
1.The classpath variable should be set propoerly.
Now on *win2k* the setting goes as ,
CLASSPATH= D:\j2sdk1.4.1_06\bin;d:\j2sdk1.4.1_06\lib;d:\j2sdkee1.3.1\bin;.;%CLASSPATH%;D:\j2sdkee1.3.1\lib\j2ee.jar;
The most important is D:\j2sdkee1.3.1\lib\j2ee.jar; and I had missed that, because of which I faced lot of erros and exceptions.
J2EE_HOME=D:\j2sdkee1.3.1
JAVA_HOME=D:\J2SDK1.4.1_06
The j2ee.jar has all the game in it..!!
2. You compile the client file using the following command -
D:\home\projects\advice>javac -classpath %CLASSPATH%;AdviceAppClient.jar AdviceClient.java
3. You run it as -
D:\home\projects\advice>java -cp %CLASSPATH%;AdviceAppClient.jar AdviceClient
You will get the advise randomly.
4. I did faced the problem of CORBA.BAD_OPERATION and I did exactly what it is mentioned on -
http://wickedlysmart.com/HeadFirst/HeadFirstEJB/HeadFirstEJBNotes.html

Hope beginners would find this useful.
Now I got the peace of mind and I will proceed to next pages.....
Cheers,
Jayant
Frederic Filiatrault
Ranch Hand

Joined: Jul 12, 2004
Posts: 69
Hi there,

I'm getting the same error BUT the classpath is not the problem. I tried it out manually to make sure :

C:\filiatr\SCBCD\projects\advice>java -cp c:\Sun\AppServer\lib\j2ee.jar;AdviceAppClient.jar;. AdviceClient

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at AdviceClient.main(AdviceClient.java:16)

Any Idea ?
paul kadi
Greenhorn

Joined: Aug 05, 2004
Posts: 1
I am using NetBeans 3.6 IDE. In the IDE I have successfuly established an oracle connection. The compile is also fine. But when I execute the program. I get the big Bang!!!

Error Opening DataBase
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

Any Ideas !!! is it still the classpath or ???
Frederic Filiatrault
Ranch Hand

Joined: Jul 12, 2004
Posts: 69
Hi Paul,

Start a new thread for that, if you want to have more reply on this matter.
And even, maybe you should change channel. I think JNDI or JDBC should be more appropriate.

Are you using a pool connection ?
Show us a little bit of code, to know if you're using any J2EE features. Thk !
Tim Tim
Greenhorn

Joined: Nov 20, 2004
Posts: 10
but my error is Cannot insgtantiate the class. Have u guy ever had this error?

******************************************************

javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterp
rise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundE
xception: com.sun.enterprise.naming.SerialInitContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
52)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:195)
at AdviceClient.go(AdviceClient.java:23)
at AdviceClient.main(AdviceClient.java:14)
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialIni
tContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
a:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
49)
... 5 more
Press any key to continue...
 
Don't get me started about those stupid light bulbs.
 
subject: head first ejb pg:57 client problem!!!please help urgent
 
Similar Threads
HFEJB AdviceClient.java Compilation Error
help!: AdviceClient.java does not compile
Error compiling the AdviceClient.java
how to run a client?
AdviceAppClient.jar and AdviceClient.java compilation failure...again;-)