[jibx-users] Incompatible binding version

2009-03-30 Thread TGD

Hi!

I have a big problem marshalling/unmarshalling with JiBX. The error I get
is:

Exception in thread main Incompatible binding version for class
com.my.utils.ja.person.Person, recompile binding with current JiBX
distribution
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at
org.jibx.runtime.BindingDirectory.getFactoryFromName(BindingDirectory.java:106)
at 
org.jibx.runtime.BindingDirectory.getFactory(BindingDirectory.java:215)
at com.my.utils.ja.TestMarshallUtils.main(TestMarshallUtils.java:24)
Caused by: java.lang.NoSuchMethodError:
org/jibx/runtime/impl/RuntimeSupport.splitClassNames(ILjava/lang/String;)[Ljava/lang/String;
at com.my.utils.ja.person.JiBX_bindingFactory.init()
at com.my.utils.ja.person.JiBX_bindingFactory.getInstance()
... 7 more


Anyone knows how can I solve this?


XML:
?xml version=\1.0\
encoding=\UTF-8\?Personnamename/namelastNamelastName/lastNamebirth2001-12-31T12:00:00/birth/Person

XSD:
xsd:schema xmlns:xsd=http://www.w3.org/2001/XMLSchema;
xsd:element name=Person
xsd:complexType
xsd:sequence
xsd:element name=name
xsd:simpleType
xsd:restriction 
base=xsd:string
/xsd:restriction
/xsd:simpleType
/xsd:element
xsd:element name=lastName
xsd:simpleType
xsd:restriction 
base=xsd:string
/xsd:restriction
/xsd:simpleType
/xsd:element
xsd:element name=birth
xsd:simpleType
xsd:restriction 
base=xsd:dateTime
/xsd:restriction
/xsd:simpleType
/xsd:element
xsd:element name=age minOccurs=0
xsd:simpleType
xsd:restriction base=xsd:int 
/
/xsd:simpleType
/xsd:element
/xsd:sequence
/xsd:complexType
/xsd:element
/xsd:schema

BINDING XML:
binding name=binding package=com.my.utils.ja.person
  mapping class=com.my.utils.ja.person.Person name=Person
value style=element name=name get-method=getName
set-method=setName/
value style=element name=lastName get-method=getLastName
set-method=setLastName/
value style=element name=birth get-method=getBirth
set-method=setBirth/
value style=element name=age get-method=getAge
set-method=setAge usage=optional/
  /mapping
/binding

JAVA CODE:
String xml = ?xml version=\1.0\
encoding=\UTF-8\?Personnamename/namelastNamelastName/lastNamebirth2001-12-31T12:00:00/birth/Person;

StringReader reader = new StringReader(xml);

Object o = new Object();
try {
IBindingFactory bfact = BindingDirectory.getFactory(Person.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
o = uctx.unmarshalDocument(reader, null);
} finally {
if (reader != null) {
reader.close();
reader = null;
}
}

// to object
Person p = (Person) o;
System.out.println(*** PERSON ***);
System.out.println(name:  + p.getName());
System.out.println(lastName:  + p.getLastName());
System.out.println(birth:  + p.getBirth());
System.out.println(age:  + p.getAge());
-- 
View this message in context: 
http://www.nabble.com/Incompatible-binding-version-tp22772699p22772699.html
Sent from the jibx-users mailing list archive at Nabble.com.


--
___
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users


Re: [jibx-users] Incompatible binding version

2009-03-30 Thread Liu, Zhi-Guo (TSG-GDCC-BJ/CME)
You use different Jibx version, and the eclipse plugin only support 1.1.6A.

Read the release notes, you can find jibx updates its api since 1.2.

Kind Regards

Liu Zhiguo
TSG-GDCC-CMEP-BJ

Tel: +86-10-65506173
北京市朝阳区东四环中路56号远洋国际中心A座7楼   
100025

我思,故我在!
I think; therefore, I am!
-Original Message-
From: TGD [mailto:gasper.raj...@zzi.si] 
Sent: 2009年3月30日 15:56
To: jibx-users@lists.sourceforge.net
Subject: [jibx-users] Incompatible binding version


Hi!

I have a big problem marshalling/unmarshalling with JiBX. The error I get
is:

Exception in thread main Incompatible binding version for class 
com.my.utils.ja.person.Person, recompile binding with current JiBX distribution 
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at
org.jibx.runtime.BindingDirectory.getFactoryFromName(BindingDirectory.java:106)
at 
org.jibx.runtime.BindingDirectory.getFactory(BindingDirectory.java:215)
at com.my.utils.ja.TestMarshallUtils.main(TestMarshallUtils.java:24)
Caused by: java.lang.NoSuchMethodError:
org/jibx/runtime/impl/RuntimeSupport.splitClassNames(ILjava/lang/String;)[Ljava/lang/String;
at com.my.utils.ja.person.JiBX_bindingFactory.init()
at com.my.utils.ja.person.JiBX_bindingFactory.getInstance()
... 7 more


Anyone knows how can I solve this?


XML:
?xml version=\1.0\
encoding=\UTF-8\?Personnamename/namelastNamelastName/lastNamebirth2001-12-31T12:00:00/birth/Person

XSD:
xsd:schema xmlns:xsd=http://www.w3.org/2001/XMLSchema;
xsd:element name=Person
xsd:complexType
xsd:sequence
xsd:element name=name
xsd:simpleType
xsd:restriction 
base=xsd:string
/xsd:restriction
/xsd:simpleType
/xsd:element
xsd:element name=lastName
xsd:simpleType
xsd:restriction 
base=xsd:string
/xsd:restriction
/xsd:simpleType
/xsd:element
xsd:element name=birth
xsd:simpleType
xsd:restriction 
base=xsd:dateTime
/xsd:restriction
/xsd:simpleType
/xsd:element
xsd:element name=age minOccurs=0
xsd:simpleType
xsd:restriction base=xsd:int 
/
/xsd:simpleType
/xsd:element
/xsd:sequence
/xsd:complexType
/xsd:element
/xsd:schema

BINDING XML:
binding name=binding package=com.my.utils.ja.person
  mapping class=com.my.utils.ja.person.Person name=Person
value style=element name=name get-method=getName
set-method=setName/
value style=element name=lastName get-method=getLastName
set-method=setLastName/
value style=element name=birth get-method=getBirth
set-method=setBirth/
value style=element name=age get-method=getAge
set-method=setAge usage=optional/
  /mapping
/binding

JAVA CODE:
String xml = ?xml version=\1.0\
encoding=\UTF-8\?Personnamename/namelastNamelastName/lastNamebirth2001-12-31T12:00:00/birth/Person;

StringReader reader = new StringReader(xml);

Object o = new Object();
try {
IBindingFactory bfact = BindingDirectory.getFactory(Person.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
o = uctx.unmarshalDocument(reader, null); } finally {
if (reader != null) {
reader.close();
reader = null;
}
}

// to object
Person p = (Person) o;
System.out.println(*** PERSON ***);
System.out.println(name:  + p.getName());
System.out.println(lastName:  + p.getLastName());
System.out.println(birth:  + p.getBirth());
System.out.println(age:  + p.getAge());
--
View this message in context: 
http://www.nabble.com/Incompatible-binding-version-tp22772699p22772699.html
Sent from the jibx-users mailing list archive at Nabble.com.


--
___
jibx-users mailing list

Re: [jibx-users] Incompatible binding version

2009-03-30 Thread TGD

Still the same. I replaced both libraries.

Any idea?



Liu, Zhi-Guo (TSG-GDCC-BJ/CME) wrote:
 
 You use different Jibx version, and the eclipse plugin only support
 1.1.6A.
 
 Read the release notes, you can find jibx updates its api since 1.2.
 
 Kind Regards
 
 Liu Zhiguo
 TSG-GDCC-CMEP-BJ
 
 Tel: +86-10-65506173
 北京市朝阳区东四环中路56号远洋国际中心A座7楼   
 100025
 
 我思,故我在!
 I think; therefore, I am!
 -Original Message-
 From: TGD [mailto:gasper.raj...@zzi.si] 
 Sent: 2009年3月30日 15:56
 To: jibx-users@lists.sourceforge.net
 Subject: [jibx-users] Incompatible binding version
 
 
 Hi!
 
 I have a big problem marshalling/unmarshalling with JiBX. The error I get
 is:
 
 Exception in thread main Incompatible binding version for class
 com.my.utils.ja.person.Person, recompile binding with current JiBX
 distribution java.lang.reflect.InvocationTargetException
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
   at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:618)
   at
 org.jibx.runtime.BindingDirectory.getFactoryFromName(BindingDirectory.java:106)
   at
 org.jibx.runtime.BindingDirectory.getFactory(BindingDirectory.java:215)
   at com.my.utils.ja.TestMarshallUtils.main(TestMarshallUtils.java:24)
 Caused by: java.lang.NoSuchMethodError:
 org/jibx/runtime/impl/RuntimeSupport.splitClassNames(ILjava/lang/String;)[Ljava/lang/String;
   at com.my.utils.ja.person.JiBX_bindingFactory.init()
   at com.my.utils.ja.person.JiBX_bindingFactory.getInstance()
   ... 7 more
 
 
 Anyone knows how can I solve this?
 
 
 XML:
 ?xml version=\1.0\
 encoding=\UTF-8\?Personnamename/namelastNamelastName/lastNamebirth2001-12-31T12:00:00/birth/Person
 
 XSD:
 xsd:schema xmlns:xsd=http://www.w3.org/2001/XMLSchema;
   xsd:element name=Person
   xsd:complexType
   xsd:sequence
   xsd:element name=name
   xsd:simpleType
   xsd:restriction 
 base=xsd:string
   /xsd:restriction
   /xsd:simpleType
   /xsd:element
   xsd:element name=lastName
   xsd:simpleType
   xsd:restriction 
 base=xsd:string
   /xsd:restriction
   /xsd:simpleType
   /xsd:element
   xsd:element name=birth
   xsd:simpleType
   xsd:restriction 
 base=xsd:dateTime
   /xsd:restriction
   /xsd:simpleType
   /xsd:element
   xsd:element name=age minOccurs=0
   xsd:simpleType
   xsd:restriction base=xsd:int 
 /
   /xsd:simpleType
   /xsd:element
   /xsd:sequence
   /xsd:complexType
   /xsd:element
 /xsd:schema
 
 BINDING XML:
 binding name=binding package=com.my.utils.ja.person
   mapping class=com.my.utils.ja.person.Person name=Person
 value style=element name=name get-method=getName
 set-method=setName/
 value style=element name=lastName get-method=getLastName
 set-method=setLastName/
 value style=element name=birth get-method=getBirth
 set-method=setBirth/
 value style=element name=age get-method=getAge
 set-method=setAge usage=optional/
   /mapping
 /binding
 
 JAVA CODE:
 String xml = ?xml version=\1.0\
 encoding=\UTF-8\?Personnamename/namelastNamelastName/lastNamebirth2001-12-31T12:00:00/birth/Person;
   
 StringReader reader = new StringReader(xml);
   
 Object o = new Object();
 try {
 IBindingFactory bfact = BindingDirectory.getFactory(Person.class);
 IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
 o = uctx.unmarshalDocument(reader, null); } finally {
 if (reader != null) {
 reader.close();
 reader = null;
 }
 }
   
 // to object
 Person p = (Person) o;
 System.out.println(*** PERSON ***);
 System.out.println(name:  + p.getName());
 System.out.println(lastName:  + p.getLastName());
 System.out.println(birth:  + p.getBirth());
 System.out.println(age:  + p.getAge());
 --
 View this message in context:
 http://www.nabble.com/Incompatible-binding-version-tp22772699p22772699.html
 Sent from the jibx-users mailing list archive at Nabble.com.
 
 
 

[jibx-users] Precompiled binding problem with ant-run plugin

2009-03-30 Thread Karel Alfonso
Hi everyone again,

  Tyring to get a successful binding compilation referencing a precompiled
binding I decided to use the JiBX Ant tasks through the ant-run maven
plugin.

  Again, I ran into the same classloader conflict error, which makes me
think the problem is related to the way Maven and JiBXbinding compiler
load the classes that somehow end up loading IBindingFactory in
different classloaders.

  I could only run a successful binding compilation from the command line,
doing java -cp ... orj.jibx.binding.Compile ..

  The maven JiBX plugin is very simple in its implementation and nothing
in it points to an improper handling of the classloaders. It's only the
combination of the Maven plugin execution and JiBX binding compilation
that generates the issue.

  Has anyone been able to use precompiled bindings using the maven JiBX
plugin?

  Thanks again,

Karel
 Hi everyone,

   I'm working on a simple solution where I have two projects and one
 reuses classes already bound (precompiled) in the other project. I'm
 using JiBX version 1.2.1

   Let's say I have a precompiled binding in projectA, projecta-binding.xml

   binding package=com.projecta
   mapping name=a class=...A
   
   /mapping
   /binding

   Then projectB defines a binding that requires using class A from
 projectA already compiled, projectb-binding.xml

   binding
  include path=projecta-binding.xml precompiled=true /

  mapping name=b class=B
structure  map-as=...A /
  /mapping
   /binding

   However when I do mvn clean install (using the 1.2.1 JiBX maven
 plugin) I get the following error:

   Classloader conflict for binding 'projecta_binding' - factory does not
 implement required interface

   The exception is thrown from BindingDirectory.getFactory() method. I've
 checked the binding factory generated by JiBX does implement
 IBindingFactory, so I'm assumming it is really a class loader issue but
 I'm not doing anything fancy, just a mvn clean install.

   I'd appreciate any help or advice regarding the use of precompiled
 binding as shown in this example.

   Also, as a second suggestion, is it possible to include a precompiled
 binding doing include path=classpath:binding.xml/ ? in that way
 other projects don't have to manually copy the precompiled binding
 definition to the project directory.

   Thanks in advance,

   Karel

 --
 ___
 jibx-users mailing list
 jibx-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/jibx-users



--
___
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users


[jibx-users] Fixed precompiled bindings with maven JiBX plugin

2009-03-30 Thread Karel Alfonso
Hi everyone,

   I managed to run a successful build referencing a precompile binding
from the Maven JiBX plugin, Maven Antrun plugin and also by invoking
directly the binding compiler from the ocmmand line (this last one
always worked).

   I'm working with maven 2.0.9 and JiBX 1.2.1.

   I've reported on the error previously at
http://www.mail-archive.com/jibx-users%40lists.sourceforge.net/msg03932.html

   It's being generated at BindingDirectory.getFactory(String bname,
String pack, ClassLoader loader), line 273

   if (result instanceof IBindingFactory) {

   result is loaded via a class loader initialized in
org.jibx.binding.classes.ClassFile.setPaths(String[] paths), line
2048:

   s_directLoader = new URLClassLoader(urls);

   This classloader's parent classloader is the system class loader.

   However IBindingFactory is loaded by RealmClassLoader which is part of
the Classworks clsas loading framework used by Maven.

   There are two fixes that in both cases should be considered according
to the use of the binding compiler. Both set the parent class loader to
the UrlClassLoader that loads the bindings:

   s_directLoader = new
URLClassLoader(urls,ClassFile.getClass().getClassLoader());

   or

   s_directLoader = new URLClassLoader(urls,
Thread.currentThread().getContextClassLoader());

  In both cases result which is the binding factory generated for the
precompiled project, is loaded via the parent class loaders which
s_directLoader will delegate to, thus, the result instanceof
IBindingFactory succeeds.

  I tested both solutions using the Maven JiBX plugin 1.2.1, Maven Antrun
plugin and invoking directly the compiler via the command line
successfully.

  Please, let me know if this solution is in the right direction and if a
patch is required, however it's just passing the parent class loader to
the UrlClassLoader as described above.

  Cheers,

  Karel



--
___
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users