Assuming you have only one mapping to the class "Customer" (e.g. you
have a line in your binding file such as:

<mapping name="xxx" class="com.mycompany.test.data.Customer">
), you don't need a binding name at all.  You can just call:

IBindingFactory jibxBFact =
BindingDirectory.getFactory( Customer.class );

If this isn't working, my suspicion would be that you're pointing to a
different version of Customer.class than jibx compiled.

When the jibx compiler runs, it modifies the actual .class file and
inserts (among other things) a public static constant named
"JiBX_bindingList" whose contents are used at runtime to locate the
binding classes.  The BindingDirectory class introspects your target
class to instantiate the appropriate binding.

One thing that I've seen come up is that a build script runs the java
compiler, jars up the results, and *then* runs jibx.  Jibx will then
modify the unjarred .class files, but when you try to invoke the
runtime, it will be looking at the pre-jibx jarred binary, and won't be
able to find its required data members.

An easy way to check is to run the following (with the classpath set to
the exact same classpath that your JVM is using):

javap com.mycompany.test.data.Customer

If you see something like:

public class Customer extends java.lang.Object implements
org.jibx.runtime.impl.ITrackSourceImpl,org.jibx.runtime.IUnmarshallable{
    public static final java.lang.String JiBX_bindingList;
    public Customer();

then you're looking at the right version of the Customer class -
otherwise, you probably need to reorder your build script (to run jibx
before you jar up the results).

On Wed, 2008-02-06 at 10:13 -0800, dev dev wrote:
> I'm using maven-jibx-plugin v. 1.1.5 for my Maven 2.
> 
> My Java object is Customer.java under src/main/java/com/mycompany
> /test/data and my binding file (customer-binding.xml) is
> under /src/main/java/com/mycompany
> /test.
> 
> I ran through the maven test and the jibx binding compiler works
> fine. 
> 
> I then need to call the binding factory. What would the bindingName be
> in my case and I presume the bindingClass would be "Customer.class".
> 
>  IBindingFactory jibxBFact =
> BindingDirectory.getFactory(bindingName(??????), Customer.class);
> 
> 
> Thanks
> dev
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________ jibx-users mailing list 
> jibx-users@lists.sourceforge.net 
> https://lists.sourceforge.net/lists/listinfo/jibx-users

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to