I see 2 things that don't seem right with your build environment
(numbered 0 and 1) and I'll just give you a few other suggestions as
well. You have most likely tried one or all of these already, but
sometimes simple things get missed.

0) take /home/hegedus/prg/javas/org/biohegedus/myprj out of your
classpath, classpath entries should point to jar files and to the root
of package hierarchies.

1) I would recommend not compiling or running your program from the
/home/hegedus/prg/javas/org/biohegedus/myprj directory. For the same
reason as above, because you have '.' in your classpath first.

2) also because under certain (rare) circumstances, if java finds your
source files in your classpath first it may re-compile them (in the
wrong directory potentially); I recommend keeping your source files and
class files separate. One option would be to create a directory
specifically for your output files /home/hegedus/prg/javas/out/ and
compile using 
javac -D /home/hegedus/prg/javas/out/
/home/hegedus/prg/javas/org/biohegedus/myprj/*.java
The -D option will force the compiler to create subdirectories for your
packages. Then you would want /home/hegedus/prg/javas/out/ to be in your
classpath (and not the dir that contains your source files)

3) you're not compiling multiple bindings are you? 

4) I'd just check to make sure that the extra classes that JiBX creates
are present alongside the existing classes

5) Make sure you don't have any old versions of .java or .class files
sitting in another directory that you forgot about or that were compiled
to the wrong directory, or that had a different package name before,
etc.

6) either use the $CLASS_PATH environment variable or the -cp option for
running both the JiBX compiler and your program, don't use environment
for one and command line option for the other. This will prevent subtle
differences from causing you problems. I keep my $CLASS_PATH environment
variable blank, and set my -cp explicitly in script files to avoid
surprises, but this is not necessary.

I hope one of these things helps you.

Mocky



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tamas
Hegedus
Sent: Tuesday, August 02, 2005 11:29 AM
To: [email protected]
Subject: [jibx-users] NoClassDefFoundError


Hi!

This message contains 2 parts as my prev email was not accepted by the 
maillist system.
===================
=> My main problem.
=> The same problem but with the output of compile running with -v
option.
===================

Hi!

I would like to use JiBX. This is the !PACKAGE! what I was looking for!
I came back to java, started to refresh it after 5-6 years of break (I
am biologist). I can not sleep well for 3 days in order to learn
java/JiBX and see a simple working example.

But if I insert the "BindingDirectory.getFactory(MyClass.class)" into
the code I get a java.lang.NoClassDefFoundError. See below.
I tried to solve this in the last days, but I can not step forward.

Thanks for your help in advance,
Tamas


//===================================
// FILE SwissProt.java
package org.biohegedus.myprj;

public class SwissProt {
     public String entry_name;

     public SwissProt() {
         this.entry_name = "default_value";
     };
};

//===================================
// FILE Proba.java (version A)
package org.biohegedus.myprj;

//import java.io.*;
import org.jibx.runtime.*;

public class Proba {
     public static void main(String[] args) {
         try{
             //IBindingFactory bfact = BindingDirectory.getFactory
(SwissProt.class);
             //IUnmarshallingContext uctx =
bfact.createUnmarshallingContext();
             //Object obj = uctx.unmarshalDocument( new FileInputStream
("sw_test.xml"), null);

             SwissProt sp = new SwissProt();
             System.out.println( sp.entry_name);
         }
         catch(Exception e){
             e.printStackTrace();
         }
     }
}
[EMAIL PROTECTED] myprj]$ javac Proba.java
[EMAIL PROTECTED] myprj]$ javac SwissProt.java
[EMAIL PROTECTED] myprj]$ java org.biohegedus.myprj.Proba
default_value
[EMAIL PROTECTED] myprj]$

The base code seems to work well. But:
//===================================
// !!!! Proba.java (Version B)
package org.biohegedus.myprj;

//import java.io.*;
import org.jibx.runtime.*;

public class Proba {
     public static void main(String[] args) {
         try{
             IBindingFactory bfact = BindingDirectory.getFactory
(SwissProt.class); // line 9
             //IUnmarshallingContext uctx =
bfact.createUnmarshallingContext();
             //Object obj = uctx.unmarshalDocument( new FileInputStream
("sw_test.xml"), null);

             SwissProt sp = new SwissProt();
             System.out.println( sp.entry_name);
         }
         catch(Exception e){
             e.printStackTrace();
         }
     }
}
[EMAIL PROTECTED] myprj]$ javac SwissProt.java
[EMAIL PROTECTED] myprj]$ javac Proba.java
[EMAIL PROTECTED] myprj]$ java -cp .:/usr/java/jibx/lib/jibx-
run.jar:/home/hegedus/prg/javas:/usr/java/jibx/lib/bcel.jar:/usr/java/ji
bx/lib/jibx-bind.jar org.jibx.binding.Compile SwissProt_bndg.xml
[EMAIL PROTECTED] myprj]$ java org.biohegedus.myprj.Proba
Exception in thread "main" java.lang.NoClassDefFoundError: SwissProt
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Class.java:141)
         at org.biohegedus.myprj.Proba.class$(Proba.java:9)
         at org.biohegedus.myprj.Proba.main(Proba.java:9)
[EMAIL PROTECTED] myprj]$

$JAVA_HOME=/usr/java/j2sdk1.4.2_08
$CLASS_PATH=.:/usr/java/jibx/lib/jibx-run.jar:/home/hegedus/prg/javas
(note: 'javas' dir contains the dirs org/biohegedus/myprj; all my files
are in the org/biohegedus/myprj and I am performing the compilation and
running from that dir; I do not use IDE (but emacs))

=======================================================
I tried compiled the bindings from different locations ( ROOT (javas); 
ROOT/../myprj dir) with a lot of classpath definitions with the '-v'
switch.

I get still the same error.

Thanks,
Tamas

PS: I do not give up! But it would be great to have it functional w/o 
much more hassle.

========================================================================
==
[EMAIL PROTECTED] javas]$ java -cp 
.:/usr/java/jibx/lib/jibx-run.jar:/home/hegedus/prg/javas:/home/hegedus/
prg/javas/org/biohegedus/myprj:/usr/java/jibx/lib/bcel.jar:/usr/java/jib
x/lib/jibx-bind.jar 
org.jibx.binding.Compile -v org/biohegedus/myprj/SwissProt_bndg.xml
Using paths:
  .
  /usr/java/jibx/lib/jibx-run.jar
  /home/hegedus/prg/javas
  /home/hegedus/prg/javas/org/biohegedus/myprj
  /usr/java/jibx/lib/bcel.jar
  /usr/java/jibx/lib/jibx-bind.jar
  /usr/java/jibx/lib/xpp3.jar
  .
Using bindings:
  org/biohegedus/myprj/SwissProt_bndg.xml
Running binding compiler version jibx-rc1
binding SwissProt_bndg:
  context (mp#=1) (cv#=0) (fm#=0)
   mapping class SwissProt to element entry (#0)
    context (cv#=0) (fm#=0)
    element wrapper entry
     object binding for SwissProt
      structure ordered
       element name from property entry_name (java.lang.String)
Generating code for mapping SwissProt
After linking view of binding SwissProt_bndg:
binding SwissProt_bndg:
  context (mp#=1) (cv#=0) (fm#=0)
   mapping class SwissProt to element entry (#0)
    context (cv#=0) (fm#=0)
    element wrapper entry
     object binding for SwissProt
      structure ordered
       element name from property entry_name (java.lang.String)

Wrote 2 files

  JiBX_SwissProt_bndgSwissProt_access output file size is 1785 bytes

  JiBX_SwissProt_bndgFactory output file size is 2239 bytes

Kept 1 files unchanged:
  SwissProt

Deleted 0 files:
[EMAIL PROTECTED] javas]$ java org.biohegedus.myprj.Proba
Exception in thread "main" java.lang.NoClassDefFoundError: SwissProt
etc...

-- 
Tamas Hegedus, PhD          | phone: (1) 919-966 0329
UNC - Biochem & Biophys     | fax:   (1) 919-966 5178
5007A Thurston-Bowles Bldg  | mailto:[EMAIL PROTECTED]
Chapel Hill, NC, 27599-7248 | http://biohegedus.org


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=ick
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to