Scott, Sean
2003-08-06 16:16:31 UTC
Last night I ran across JiBX and thought it may meet some of our XML
requirements. So I am trying to write a simple test case in one of our
existing projects that utilizes it.
My problems started while trying to add the bind task to our build.xml file
following the instructions provided with JiBX and continued once I got the
JiBX compiler to run. When bind ran, it always failed with a
java.lang.IncompatibleClassChangeError. Our ant scripts do a lot of stuff
with weblogic and other crap so I figured it was some sort of class
incompatibility with stuff that JiBX uses. So I tried running the compile
from the command line and got it to work, and ended up adding this fragment
to our compile target in our build.xml.
All substitutions contain fully qualified paths.
<java classname="org.jibx.binding.Compile" fork="true">
<classpath>
<pathelement path="${build.dest.classes}"/>
<pathelement path="${build.classpath}" />
<pathelement location="${build.lib.3rdParty}/bcel.jar"/>
<pathelement location="${build.lib.3rdParty}/jibx-bind.jar"/>
<pathelement location="${build.lib.3rdParty}/jibx-run.jar"/>
<pathelement location="${build.lib.3rdParty}/xpp3.jar"/>
</classpath>
<arg line="${build.src.conf}/binding.xml" />
</java>
Here is my binding.xml:
<!DOCTYPE binding SYSTEM "binding.dtd">
<binding forwards="false">
<mapping name="campaign"
class="com.thc.ids.domainobjects.ams.Campaign">
<value style="attribute" name="name" field="_name"/>
<value style="attribute" name="startDate" field="_startDate"/>
<value style="attribute" name="endDate" field="_endDate"/>
</mapping>
</binding>
The binding compiler modifies the Campaign.class file and creates 2 more
classes in the same package:
JiBX_bindingCampaign_access.class
JiBX_bindingFactory.class
!! THIS IS THE POINT OF THE EMAIL !!
I deploy the app in weblogic and run my cactus test case ( Below ) and get
this exception:
1) testIt(com.thc.ids.api.services.business.ams.test.TestJiBX)
org.jibx.runtime.JiBXException: Unable to access binding information for
class com.thc.ids.domainobj
ects.ams.Campaign
Root cause: java.lang.ClassNotFoundException:
com.thc.ids.domainobjects.ams.JiBX_AdMgmtSvc_conf_bind
ingFactory
at
org.jibx.runtime.BindingDirectory.getFactory(BindingDirectory.java:141)
at
com.thc.ids.api.services.business.ams.test.TestJiBX.testIt(TestJiBX.java:45)
at
org.apache.cactus.AbstractTestCase.runServerTest(AbstractTestCase.java:491)
It looks like the information implanted in Campaign.class for the binding
factory is com.thc.ids.domainobjects.ams.JiBX_AdMgmtSvc_conf_bindingFactory
but the class that was generated was called
com.thc.ids.domainobjects.ams.JiBX_bindingFactory.
Test case:
public void testIt() throws Exception
{
String campaignXML = "<campaign name='name'
startDate='2003-03-21T01:33:00' endDate='2003-08-21T01:33:00'/>";
IBindingFactory bfact = BindingDirectory.getFactory(Campaign.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
Campaign campaign = (Campaign) uctx.unmarshalDocument(new
StringReader(campaignXML));
insertCampaign(campaign);
System.out.println( campaign.toString() );
IMarshallingContext ictx = bfact.createMarshallingContext();
ictx.marshalDocument( campaign, null, null, System.out );
}
Thanks,
-sean
Sean Scott
Senior Software Engineer
Thomson MICROMEDEX
***@mdx.com
303-486-6403
requirements. So I am trying to write a simple test case in one of our
existing projects that utilizes it.
My problems started while trying to add the bind task to our build.xml file
following the instructions provided with JiBX and continued once I got the
JiBX compiler to run. When bind ran, it always failed with a
java.lang.IncompatibleClassChangeError. Our ant scripts do a lot of stuff
with weblogic and other crap so I figured it was some sort of class
incompatibility with stuff that JiBX uses. So I tried running the compile
from the command line and got it to work, and ended up adding this fragment
to our compile target in our build.xml.
All substitutions contain fully qualified paths.
<java classname="org.jibx.binding.Compile" fork="true">
<classpath>
<pathelement path="${build.dest.classes}"/>
<pathelement path="${build.classpath}" />
<pathelement location="${build.lib.3rdParty}/bcel.jar"/>
<pathelement location="${build.lib.3rdParty}/jibx-bind.jar"/>
<pathelement location="${build.lib.3rdParty}/jibx-run.jar"/>
<pathelement location="${build.lib.3rdParty}/xpp3.jar"/>
</classpath>
<arg line="${build.src.conf}/binding.xml" />
</java>
Here is my binding.xml:
<!DOCTYPE binding SYSTEM "binding.dtd">
<binding forwards="false">
<mapping name="campaign"
class="com.thc.ids.domainobjects.ams.Campaign">
<value style="attribute" name="name" field="_name"/>
<value style="attribute" name="startDate" field="_startDate"/>
<value style="attribute" name="endDate" field="_endDate"/>
</mapping>
</binding>
The binding compiler modifies the Campaign.class file and creates 2 more
classes in the same package:
JiBX_bindingCampaign_access.class
JiBX_bindingFactory.class
!! THIS IS THE POINT OF THE EMAIL !!
I deploy the app in weblogic and run my cactus test case ( Below ) and get
this exception:
1) testIt(com.thc.ids.api.services.business.ams.test.TestJiBX)
org.jibx.runtime.JiBXException: Unable to access binding information for
class com.thc.ids.domainobj
ects.ams.Campaign
Root cause: java.lang.ClassNotFoundException:
com.thc.ids.domainobjects.ams.JiBX_AdMgmtSvc_conf_bind
ingFactory
at
org.jibx.runtime.BindingDirectory.getFactory(BindingDirectory.java:141)
at
com.thc.ids.api.services.business.ams.test.TestJiBX.testIt(TestJiBX.java:45)
at
org.apache.cactus.AbstractTestCase.runServerTest(AbstractTestCase.java:491)
It looks like the information implanted in Campaign.class for the binding
factory is com.thc.ids.domainobjects.ams.JiBX_AdMgmtSvc_conf_bindingFactory
but the class that was generated was called
com.thc.ids.domainobjects.ams.JiBX_bindingFactory.
Test case:
public void testIt() throws Exception
{
String campaignXML = "<campaign name='name'
startDate='2003-03-21T01:33:00' endDate='2003-08-21T01:33:00'/>";
IBindingFactory bfact = BindingDirectory.getFactory(Campaign.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
Campaign campaign = (Campaign) uctx.unmarshalDocument(new
StringReader(campaignXML));
insertCampaign(campaign);
System.out.println( campaign.toString() );
IMarshallingContext ictx = bfact.createMarshallingContext();
ictx.marshalDocument( campaign, null, null, System.out );
}
Thanks,
-sean
Sean Scott
Senior Software Engineer
Thomson MICROMEDEX
***@mdx.com
303-486-6403