Hi All,
I cannot get JibX to work in anything other than the default package.
All of my code and bindings work perfectly fine when I remove them from
our package. There are no other files in the package, it is a simple
directory structure:
com
|-- wanadoo
|-- uk
|-- sdc <--- all class files in here
I have separate directories for source files and class files. The above
structure is replicated in a src folder and a bin folder.
I am using the ant task in eclipse to bind my classes:
<-- Ant task -->
<taskdef name="bind" classname="org.jibx.binding.ant.CompileTask"
classpath="c:/jibx/lib/jibx-bind.jar" />
<target name="new-Attribute-Bind">
<bind verbose="true" load="true"
binding="bin/com/wanadoo/uk/sdc/attributebinding.xml">
<classpathset dir="bin/com/wanadoo/uk/sdc/" />
</bind>
</target>
<-- Binding file -->
<binding>
<mapping name="attribute-list" class="SDCAttributeList">
<collection field="attributes"
item-type="SDCAttribute"/>
</mapping>
<mapping name="attribute" class="SDCAttribute">
<value style="attribute" name="name"
field="attributeName"/>
<collection field="attributeValues"
item-type="SDCAttributeValue"/>
</mapping>
<mapping name="attr-value" class="SDCAttributeValue">
<value name="name" field="valName"/>
<value name="count" field="valCount"/>
<value name="url" field="valURL"/>
<value name="url2" field="valURL2"/>
<value name="befid" field="valBefid"/>
</mapping>
</binding>
When I bind the files I get the following output:
Buildfile: C:\ProjectFiles\Workspace3.1\JibxTest\build.xml
new-Attribute-Bind:
[bind] Using the following paths:
[bind] C:\ProjectFiles\Workspace3.1\JibxTest\bin\com\wanadoo\uk\sdc
[bind] Using the following binding paths:
[bind] bin/com/wanadoo/uk/sdc/attributebinding.xml
[bind] Running binding compiler version jibx-rc1
[bind] binding bin_com_wanadoo_uk_sdc_attributebinding:
[bind] context (mp#=3) (cv#=0) (fm#=0)
[bind] mapping class SDCAttributeList to element attribute-list
(#0)
[bind] context (cv#=0) (fm#=0)
[bind] element wrapper attribute-list
[bind] object binding for SDCAttributeList
[bind] structure ordered
[bind] component property attributes (java.util.ArrayList)
[bind] object binding for java.util.ArrayList
[bind] collection ordered (SDCAttribute)
[bind] mapping reference to SDCAttribute using property from
collection (SDCAttribute)
[bind] mapping class SDCAttribute to element attribute (#1)
[bind] context (cv#=0) (fm#=0)
[bind] element wrapper attribute
[bind] object binding for SDCAttribute
[bind] structure ordered
[bind] attribute name from property attributeName
(java.lang.String)
[bind] component property attributeValues (java.util.ArrayList)
[bind] object binding for java.util.ArrayList
[bind] collection ordered (SDCAttributeValue)
[bind] mapping reference to SDCAttributeValue using property from
collection (SDCAttributeValue)
[bind] mapping class SDCAttributeValue to element attr-value (#2)
[bind] context (cv#=0) (fm#=0)
[bind] element wrapper attr-value
[bind] object binding for SDCAttributeValue
[bind] structure ordered
[bind] element name from property valName (java.lang.String)
[bind] element count from property valCount (int)
[bind] element url from property valURL (java.lang.String)
[bind] element url2 from property valURL2 (java.lang.String)
[bind] element befid from property valBefid (int)
[bind] Generating code for mapping SDCAttributeList
[bind] Generating code for mapping SDCAttribute
[bind] Generating code for mapping SDCAttributeValue
[bind] After linking view of binding
bin_com_wanadoo_uk_sdc_attributebinding:
[bind] binding bin_com_wanadoo_uk_sdc_attributebinding:
[bind] context (mp#=3) (cv#=0) (fm#=0)
[bind] mapping class SDCAttributeList to element attribute-list
(#0)
[bind] context (cv#=0) (fm#=0)
[bind] element wrapper attribute-list
[bind] object binding for SDCAttributeList
[bind] structure ordered
[bind] component property attributes (java.util.ArrayList)
[bind] object binding for java.util.ArrayList
[bind] collection ordered (SDCAttribute)
[bind] mapping reference to SDCAttribute using property from
collection (SDCAttribute)
[bind] mapping class SDCAttribute to element attribute (#1)
[bind] context (cv#=0) (fm#=0)
[bind] element wrapper attribute
[bind] object binding for SDCAttribute
[bind] structure ordered
[bind] component property attributeValues (java.util.ArrayList)
[bind] object binding for java.util.ArrayList
[bind] collection ordered (SDCAttributeValue)
[bind] mapping reference to SDCAttributeValue using property from
collection (SDCAttributeValue)
[bind] attribute name from property attributeName
(java.lang.String)
[bind] mapping class SDCAttributeValue to element attr-value (#2)
[bind] context (cv#=0) (fm#=0)
[bind] element wrapper attr-value
[bind] object binding for SDCAttributeValue
[bind] structure ordered
[bind] element name from property valName (java.lang.String)
[bind] element count from property valCount (int)
[bind] element url from property valURL (java.lang.String)
[bind] element url2 from property valURL2 (java.lang.String)
[bind] element befid from property valBefid (int)
[bind] Wrote 8 files
[bind] SDCAttributeList output file size is 2915 bytes
[bind] Error running binding compiler
[bind] java.lang.NoClassDefFoundError: SDCAttributeList (wrong
name: com/wanadoo/uk/sdc/SDCAttributeList)
[bind] at java.lang.ClassLoader.defineClass0(Native Method)
[bind] at java.lang.ClassLoader.defineClass(Unknown Source)
[bind] at java.lang.ClassLoader.defineClass(Unknown Source)
[bind] at
org.jibx.binding.Compile$DirectLoader.load(Compile.java:414)
[bind] at org.jibx.binding.Compile.handleOutput(Compile.java:196)
[bind] at org.jibx.binding.Compile.compile(Compile.java:315)
[bind] at
org.jibx.binding.ant.CompileTask.execute(CompileTask.java:248)
[bind] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[bind] at org.apache.tools.ant.Task.perform(Task.java:364)
[bind] at org.apache.tools.ant.Target.execute(Target.java:341)
[bind] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[bind] at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[bind] at
org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[bind] at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecut
or.java:40)
[bind] at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTar
gets(EclipseDefaultExecutor.java:32)
[bind] at
org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[bind] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAnt
Runner.java:423)
[bind] at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAn
tRunner.java:137)
BUILD FAILED
C:\ProjectFiles\Workspace3.1\JibxTest\build-user.xml:16: JiBXException
in JiBX binding compilation
Total time: 1 second
The interesing part is when I run the ant task again immediately after
the failure:
Buildfile: C:\ProjectFiles\Workspace3.1\JibxTest\build.xml
new-Attribute-Bind:
[bind] Using the following paths:
[bind] C:\ProjectFiles\Workspace3.1\JibxTest\bin\com\wanadoo\uk\sdc
[bind] Using the following binding paths:
[bind] bin/com/wanadoo/uk/sdc/attributebinding.xml
[bind] Running binding compiler version jibx-rc1
[bind] binding bin_com_wanadoo_uk_sdc_attributebinding:
[bind] context (mp#=3) (cv#=0) (fm#=0)
[bind] mapping class SDCAttributeList to element attribute-list
(#0)
[bind] context (cv#=0) (fm#=0)
[bind] element wrapper attribute-list
[bind] object binding for SDCAttributeList
[bind] structure ordered
[bind] component property attributes (java.util.ArrayList)
[bind] object binding for java.util.ArrayList
[bind] collection ordered (SDCAttribute)
[bind] mapping reference to SDCAttribute using property from
collection (SDCAttribute)
[bind] mapping class SDCAttribute to element attribute (#1)
[bind] context (cv#=0) (fm#=0)
[bind] element wrapper attribute
[bind] object binding for SDCAttribute
[bind] structure ordered
[bind] attribute name from property attributeName
(java.lang.String)
[bind] component property attributeValues (java.util.ArrayList)
[bind] object binding for java.util.ArrayList
[bind] collection ordered (SDCAttributeValue)
[bind] mapping reference to SDCAttributeValue using property from
collection (SDCAttributeValue)
[bind] mapping class SDCAttributeValue to element attr-value (#2)
[bind] context (cv#=0) (fm#=0)
[bind] element wrapper attr-value
[bind] object binding for SDCAttributeValue
[bind] structure ordered
[bind] element name from property valName (java.lang.String)
[bind] element count from property valCount (int)
[bind] element url from property valURL (java.lang.String)
[bind] element url2 from property valURL2 (java.lang.String)
[bind] element befid from property valBefid (int)
[bind] Generating code for mapping SDCAttributeList
[bind] Generating code for mapping SDCAttribute
[bind] Generating code for mapping SDCAttributeValue
[bind] After linking view of binding
bin_com_wanadoo_uk_sdc_attributebinding:
[bind] binding bin_com_wanadoo_uk_sdc_attributebinding:
[bind] context (mp#=3) (cv#=0) (fm#=0)
[bind] mapping class SDCAttributeList to element attribute-list
(#0)
[bind] context (cv#=0) (fm#=0)
[bind] element wrapper attribute-list
[bind] object binding for SDCAttributeList
[bind] structure ordered
[bind] component property attributes (java.util.ArrayList)
[bind] object binding for java.util.ArrayList
[bind] collection ordered (SDCAttribute)
[bind] mapping reference to SDCAttribute using property from
collection (SDCAttribute)
[bind] mapping class SDCAttribute to element attribute (#1)
[bind] context (cv#=0) (fm#=0)
[bind] element wrapper attribute
[bind] object binding for SDCAttribute
[bind] structure ordered
[bind] component property attributeValues (java.util.ArrayList)
[bind] object binding for java.util.ArrayList
[bind] collection ordered (SDCAttributeValue)
[bind] mapping reference to SDCAttributeValue using property from
collection (SDCAttributeValue)
[bind] attribute name from property attributeName
(java.lang.String)
[bind] mapping class SDCAttributeValue to element attr-value (#2)
[bind] context (cv#=0) (fm#=0)
[bind] element wrapper attr-value
[bind] object binding for SDCAttributeValue
[bind] structure ordered
[bind] element name from property valName (java.lang.String)
[bind] element count from property valCount (int)
[bind] element url from property valURL (java.lang.String)
[bind] element url2 from property valURL2 (java.lang.String)
[bind] element befid from property valBefid (int)
[bind] Wrote 0 files
[bind] Kept 8 files unchanged:
[bind] SDCAttributeList
[bind] JiBX_bin_com_wanadoo_uk_sdc_attributebindingFactory
[bind]
JiBX_bin_com_wanadoo_uk_sdc_attributebindingSDCAttributeList_access
[bind]
JiBX_bin_com_wanadoo_uk_sdc_attributebindingSDCAttributeValue_access
[bind]
JiBX_bin_com_wanadoo_uk_sdc_attributebindingSDCAttribute_access
[bind] JiBX_MungeAdapter
[bind] SDCAttribute
[bind] SDCAttributeValue
[bind] Deleted 0 files:
BUILD SUCCESSFUL
Total time: 1 second
Now it appears to work!
Now when I run the code to unmarshall the document I get this error:
java.lang.NoClassDefFoundError: SDCAttributeList
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.wanadoo.uk.sdc.AttributeDemo.main(AttributeDemo.java:20)
Exception in thread "main"
Here is the code:
package com.wanadoo.uk.sdc;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Iterator;
import org.jibx.runtime.*;
public class AttributeDemo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
IBindingFactory bfact;
try {
bfact =
BindingDirectory.getFactory(SDCAttributeList.class);
IUnmarshallingContext uctx =
bfact.createUnmarshallingContext();
long before = System.currentTimeMillis();
SDCAttributeList sdcAttributeList =
(SDCAttributeList) uctx
.unmarshalDocument(
new
FileInputStream(
"C:\\ProjectFiles\\Workspace3.1\\JibxTest\\bin\\com\\wanadoo\\uk\\sdc\\a
ttributes.xml"),
null);
long after = System.currentTimeMillis();
System.out.println("Time taken in ms - " +
(after - before));
ArrayList myAttributeList =
sdcAttributeList.getAttributes();
Iterator i = myAttributeList.iterator();
while (i.hasNext()) {
SDCAttribute myAttribute =
(SDCAttribute) i.next();
System.out.println(myAttribute.getAttributeName());
ArrayList myAttrValue =
myAttribute.getAttributeValues();
Iterator j = myAttrValue.iterator();
while (j.hasNext()) {
SDCAttributeValue
theAttributeValue = (SDCAttributeValue) j
.next();
System.out.println(theAttributeValue.getValName());
System.out.println(theAttributeValue.getValCount());
System.out.println(theAttributeValue.getValURL());
System.out.println(theAttributeValue.getValBefid());
}
}
System.out.println();
} catch (JiBXException je) {
// TODO Auto-generated catch block
je.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
As I said before all of this works when it is in the default package
just not in ours. Any help would be very appreciated :)
Adam Hope
Application Designer
Wanadoo UK PLC
This email and the files transmitted with it are meant solely for the use of
the individual addressee(s) named above. They may contain confidential and/or
legally privileged information. If you are not the addressee(s) or responsible
for delivery of the message to the addressee(s), please delete it from your
system and contact the sender right away. The opinions, conclusions and other
information in this message which do not relate to the official business of
Wanadoo UK plc are not necessarily endorsed by it. Wanadoo UK plc has taken
steps to ensure that this email and any attachments are virus-free, but it
remains your responsibility to confirm and ensure this.
Wanadoo UK plc is a subsidiary of France Telecom SA. Our registered office is
at: Verulam Point, Station Way, St. Albans, Herts, AL1 5HE, and we are
registered in England and Wales, as Company No. 3014367
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users