• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
pradeep arum
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks valentin,
it worked ....then how should i run this .....
please tell the command
thanks
pradeep
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please check your classpath is correct or not ?
please see.
CLASSPATH=.;.......;%CLASSPATH%
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic