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

Reply via email to