Thanks for your quick response.
MissingClass is a RuntimeException. It extends java.lang.RuntimeException and nothing extends MissingClass. However, I discovered that a method in one of the (indirect) ancestor classes of SerializerClass throws this exception (not declares it since MissingClass is a runtime exception, but not really sure if it matters at the level of getDeclaredMethods0...).
Since no class extends MissingClass the problem might be with the way I specified the classpath for JiBX. Here is the Ant target for the JiBX binding. Can someone check it?
<target name="target-name" description="Description.">
<path id="jibx-classpath">
<fileset file="jarfile.jar"/>
<path refid="other-classpath-ref"/>
</path>
<available property="missingClass.present" classpathref="jibx-classpath"
classname="p.a.c.k.a.g.e.MissingClass"/>
<echo message="${missingClass.present}"/>
<taskdef name="bind" classname="org.jibx.binding.ant.CompileTask"
classpathref="jibx-classpath"/>
<bind verbose="true" load="true" binding="jibx-bindings.xml">
<classpathset dir="classes"/>
<classpathset file="jarfile.jar"/>
</bind>
</target>
The echo task prints out "true" so jibx-classpath contains MissingClass.
Many thanks again,
I.
> From:: "Mocky Habeeb" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Subject: RE: [jibx-users] NoClassDefFoundError with optional value
> Date: Wed, 14 Sep 2005 10:49:59 -0400
MissingClass is a RuntimeException. It extends java.lang.RuntimeException and nothing extends MissingClass. However, I discovered that a method in one of the (indirect) ancestor classes of SerializerClass throws this exception (not declares it since MissingClass is a runtime exception, but not really sure if it matters at the level of getDeclaredMethods0...).
Since no class extends MissingClass the problem might be with the way I specified the classpath for JiBX. Here is the Ant target for the JiBX binding. Can someone check it?
<target name="target-name" description="Description.">
<path id="jibx-classpath">
<fileset file="jarfile.jar"/>
<path refid="other-classpath-ref"/>
</path>
<available property="missingClass.present" classpathref="jibx-classpath"
classname="p.a.c.k.a.g.e.MissingClass"/>
<echo message="${missingClass.present}"/>
<taskdef name="bind" classname="org.jibx.binding.ant.CompileTask"
classpathref="jibx-classpath"/>
<bind verbose="true" load="true" binding="jibx-bindings.xml">
<classpathset dir="classes"/>
<classpathset file="jarfile.jar"/>
</bind>
</target>
The echo task prints out "true" so jibx-classpath contains MissingClass.
Many thanks again,
I.
> From:: "Mocky Habeeb" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Subject: RE: [jibx-users] NoClassDefFoundError with optional value
> Date: Wed, 14 Sep 2005 10:49:59 -0400
This is interesting. The reason
it only happens when your value is optional is because there is
special code generated for optional values that checks to see if the
optional value is equal to the default value. It's in this code where the error
is thrown, as your deserializer method is being looked up. My guess is
that an argument to a method in SerializerClass has a dependency on MissingClass (maybe it has a member variable of type MissingClass, etc.) and that one of the
classes that MissingClass depends on is not in the classpath. In this case these
extra classes would only be required for doing the method search at bind
time and not at runtime.
That is where I would start
looking. One easy way to see what other classes MissingClass is pulling in is to
write a one line program that loads MissingClass and run it with the java.exe
command line switch "-verbose:class". Then you can see if any of those
classes are not in your jibx-classpath. Alternately you could try to track down
and sever the (elusive) dependency between SerializerClass and
MissingClass.
Mocky
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ivan.gorcsev
Sent: Wednesday, September 14, 2005 9:02 AM
To: [email protected]
Subject: [jibx-users] NoClassDefFoundError with optional valueHi All,
I have the following JiBX binding definition:
<mapping name="name1" value-style="attribute"
class="p.a.c.k.a.g.e.ErrorClass"
extends="p.a.c.k.a.g.e.AbstractClass">
<structure map-as="p.a.c.k.a.g.e.AbstractClass"/>
<value name="name2" usage="required"
get-method="getName2" set-method="setName2"/>
<value name="name3" usage="optional"
get-method="isName3" set-method="setName3"
serializer="p.a.c.k.a.g.e.SerializerClass.name3Serializer"
deserializer="p.a.c.k.a.g.e.SerializerClass.name3Deserializer"/>
</mapping>
Which during JiBX compilation produces the following error:
[bind] Generating code for mapping p.a.c.k.a.g.e.OtherClass
[bind] Generating code for mapping p.a.c.k.a.g.e.ErrorClass
[bind] Error running binding compiler
[bind] java.lang.NoClassDefFoundError: p/a/c/k/a/g/e/MissingClass
[bind] at java.lang.Class.getDeclaredMethods0(Native Method)
[bind] at java.lang.Class.privateGetDeclaredMethods(Class.java:1655)
[bind] at java.lang.Class.getDeclaredMethod(Class.java:1262)
[bind] at org.jibx.binding.def.PrimitiveStringConversion.genToOptionalText(PrimitiveStringConversion.java:336)
[bind] at org.jibx.binding.def.StringConversion.genWriteOptional(StringConversion.java:326)
[bind] at org.jibx.binding.def.ValueChild.genMarshal(ValueChild.java:566)
[bind] at org.jibx.binding.def.ValueChild.genAttributeMarshal(ValueChild.java:653)
[bind] at org.jibx.binding.def.NestedStructure.genAttributeMarshal(NestedStructure.java:134)
[bind] at org.jibx.binding.def.ObjectBinding.genMarshalAttributeCall(ObjectBinding.java:679)
[bind] at org.jibx.binding.def.ObjectBinding.genAttributeMarshal(ObjectBinding.java:899)
[bind] at org.jibx.binding.def.ElementWrapper.genContentMarshal(ElementWrapper.java:343)
[bind] at org.jibx.binding.def.MappingDefinition.generateCode(MappingDefinition.java:632)
[bind] at org.jibx.binding.def.DefinitionContext.generateCode(DefinitionContext.java:604)
[bind] at org.jibx.binding.def.BindingDefinition.generateCode(BindingDefinition.java:611)
[bind] at org.jibx.binding.Compile.compile(Compile.java:305)
[bind] at org.jibx.binding.ant.CompileTask.execute(CompileTask.java:248)
The JiBX compilation is done through an Ant task:
<taskdef name="bind" classname="org.jibx.binding.ant.CompileTask"
classpathref="jibx-classpath"/>
<bind verbose="true" load="true" binding="jibx-bindings.xml">
<classpathset dir="classes"/>
<classpathset file="jarfile.jar"/>
</bind>
The jibx-classpath definitely contains p.a.c.k.a.g.e.MissingClass, so does jarfile.jar.
p.a.c.k.a.g.e.SerializerClass does not reference to p.a.c.k.a.g.e.MissingClass (at least not in a trivial way, I could not find the link between them, but this is a big system, anything can happen).
The interesting thing is that if I set the usage of name3 to be required instead of optional everything compiles fine.
Can anyone help me what to check or change?
Many thanks,
I.G.
Lycos email has now 300 Megabytes of free storage... Get it now at mail.lycos.co.uk
Lycos email has now 300 Megabytes of free storage... Get it now at mail.lycos.co.uk
