• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Head first EJB example (running client) and Sun application server 8

 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question about running HFEJB client code,I've read all related threads in this forum but don't find this
kind of error, when I try to compile my Client code I issue:

java -cp .;"%CLASSPATH%;AdviceAppClient.jar" AdviceClient

or

java -cp "%CLASSPATH%;AdviceAppClient.jar" AdviceClient


I put all related file on the same folder (AdviceAppClient.jar, *.ear, AdviceClient.java, AdviceClient.class ) and I
"cd" to that folder before issue that command, and I change the "getAdvice" method name to "sayHello" BUT
I get this message:


Exception in thread "main" java.lang.NoClassDefFoundError: AdviceClient (wrong name: client/AdviceClient)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)


my OS(win XP) settings are:

CLASSPATH = C:\j2sdkee1.3\lib\j2ee.jar
J2EE_HOME = C:\j2sdkee1.3\lib
JAVA_HOME = D:\Reza\JDK\JDK(j2se)1.4.2Lib
PATH = D:\Reza\JDK\JDK(j2se)1.4.2Lib\bin;C:\j2sdkee1.3\bin

I also use Sun application server 8 2005Q1 and my bean deployed fine (I think so)

when I deploy my bean
when I face client compilation error:
NOW after 2 days:
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Everthing works fine for me with Java 2 Platform, Enterprise Edition (J2EE) - Version 1.3.1 Release i.e. the 1.3 RI server. Settings:

CLASSPATH=.;%J2EE_HOME%\lib\j2ee.jar
J2EE_HOME=D:\etc\j2sdkee1.3.1
JAVA_HOME=D:\etc\jdk1.4.2
PATH includes %JAVA_HOME%\bin;%J2EE_HOME%\bin;

and then run with

java -cp %CLASSPATH%;AdviceAppClient.jar AdviceClient

Your J2EE_HOME may need adjusting to "C:\j2sdkee1.3" rather than "C:\j2sdkee1.3\lib". Also I can't tell if your JAVA_HOME is correct (the Lib in the name is throwing me) - but your path suggests that it is correct.

But that makes me wonder - isn't the Sun Application Server a J2EE 1.4 server - why would it be in a directory called "j2sdkee1.3"?
 
Reza Rav.
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I change my J2EE_HOME as you said but still it don't work and I get that error message again


But that makes me wonder - isn't the Sun Application Server a J2EE 1.4 server - why would it be in a directory called "j2sdkee1.3"?"



I change them my self because I think maye with J2EE 1.3 this code work

-----------------------
Reza
A man without EJB
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Reza Ravasizadeh:
I change them my self because I think may with J2EE 1.3 this code work


I think you may have made the problem worse. The Sun Application Server would have its own j2ee.jar and and the J2EE_HOME and CLASSPATH should be referring the its version of J2EE - after all it created your client jar. If you have an isolated machine that you can use for your preparation, uninstall the current J2EE stuff, download the 1.3 RI and follow the instructions in the book exactly. Once you get a hang of how things work together, try the Sun Application Server again - if you have to.
 
Reza Rav.
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank for your help but I also change CLASSPATH and J2EE_HOME (refer to sun app server"J2EE 1.4" not J2EE 1.3) it still gives me that error.
I can't migrate to RI because at developement ,we use SUN ONE App server and JBOSS app server, so for testing my EJB I think SUN APP SERVER(new version of sun ONE app server) is like sun One APP Server,maybe RI 1.3 have more differences.
If you think after my explanation problem relates to app server please inform
me.
Thanx
----------------------
Reza

SCJP 1.4, OCP 9i
 
Reza Rav.
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot to say that:
After changing I compiled Client with new J2ee.jar , but problem remain
 
Reza Rav.
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No body answer !!!
I realy need a client code for compiling my EJB on my job please help me
 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Salam Reza,

halet khoofe .

Can you post your XML deployment descriptor (ejb-jar.xml) here?

Please use the CODE tag when you send your XML for better readability

Regards,
Darya
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reza,

beside the deployment descriptor which we'll take a look now on it, I can only agree with Peer, that you better don't mingle between RI, JBoss and Sun App Server .

Go first through HFEJB as described, and don't try this and that. You will definitely loose time and concentration for struggling with other app servers other than described in HFEJB .

Once you have your SCBCD (which you will get sooner when you follow exactly HFEJB) you can go a step further and try other app servers. That's what I will do. We also use JBoss at our company, but I don't care for now

For now I'm waiting for your deployment descriptor

Regards,
Darya
 
Reza Rav.
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
salam Darya
thank you for your help, maybe you have right I also change the codes I think the pattern is the same so I can write my self an EJB, by the way here is my DD I wish it is usefull:


I name my Bean HelloBean and package Tutorial.

merci

Reza
 
Reza Rav.
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

maybe you have right

= 100% you have right
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Reza,

I meant to post it of course with indentation like beneath:



OK, first of all it seems that the deployment descriptor you posted here does not fit with the error message you posted:


originally posted by Reza Ravasizadeh:

Exception in thread "main" java.lang.NoClassDefFoundError: AdviceClient (wrong name: client/AdviceClient)



Is it possible that you are now mixing everything up . Can we agree upon that you first get the HFEJB p. 28/58 example first run? That means use the RI and exact naming as provided there.

You not even change the app servers you even change the naming provided. That is of course allowed but it makes assisting you impossible and as I said before it only slows down your progress.

Please try first the example exactly as is and tell us your result.

On the other hand the

Exception in thread "main" java.lang.NoClassDefFoundError: AdviceClient (wrong name: client/AdviceClient)

shows that you may start your client app from the wrong directoy. What's the directory you start from?

Regards,
Darya

Regards,
Darya
 
Reza Rav.
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Darya
maybe today is my last try then I should migrate on RI as you said before and write completly what is in HFEJB book and do exactly what is there.
I'm already in my Client (Advice) directory BUT when I don't use "." in my classpath I don't get that error :
Exception in thread "main" java.lang.NoClassDefFoundError: HelloClient
no more detail.

Now I search java forum to find something about appserver but please tell me your idea if you find anything interesting.

best regards

---------
Reza

OCP9i , SCJP 1.4
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Reza,

do you use the following in your AdviceClient.java class:



If so, one idea I have is:

  • 1. cd to your projects folder (there where your client folder is)
  • 2. run java -cp %CLASSPATH%;AdviceAppClient.jar client.AdviceClient


  • Good Luck ,
    Darya
     
    Reza Rav.
    Ranch Hand
    Posts: 177
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thank you but it doesn't work too, I try to study some "Sun app sever" document and when I find something I issue here, if not tomorrow with RI
    I hate oldies

    Reza
     
    Reza Rav.
    Ranch Hand
    Posts: 177
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Now I use RI, I can't imagine that I can't run simple bean.
    again I get the same error here are my OS variables:
    PATH=
    C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Program Files\CatPC\Bin;C:\Program Files\CatPC\Windows\System32;C:\Program Files\CatPC\Windows\System;C:\ClearCase\bin;C:\jdk1.3.1_16\bin;D:\Reza\JDK\JDK(j2se)1.4.2Lib\bin;

    CLASSPATH= C:\j2sdkee1.3\lib\j2ee.jar;D:\Reza\Myproject\EJBexample

    JAVA_HOME= C:\jdk1.3.1_16

    J2EE_HOME= C:\j2sdkee1.3

    I loose my power to believe my self.

    I also issue all of my command from 1.3


     
    Reza Rav.
    Ranch Hand
    Posts: 177
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I find it , I put my client in a package I take it out of package (after 3 day)
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Congratulations

    Regards,
    Darya
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic