Hi Drew, The "instanceof" is used in this case because the code needs to cast the returned object to the IBindingFactory interface, and this test checks if the cast is valid. The reason the cast might *not* be valid is because if multiple classloaders are in use you can get the JiBX runtime classes loaded in more than one branch of the classloader tree, and when this happens the JVM sees the different copies as completely separate classes and refuses to cast a class which implements the IBindingFactory(1) interface to the IBindingFactory(2) interface.
There should be no way to get to that code with a null value without an exception being thrown by the prior method call, and the exception case is checked. But if you think this is what is happening, either debug into the code to verify or just make a copy of the BindingDirectory class and use that with added tests. If you can show me that you're getting a null value it'll mean there's an error in the generated binding factory code, and I'll make sure it gets fixed. - Dennis Dennis M. Sosnoski SOA and Web Services in Java Training and Consulting http://www.sosnoski.com - http://www.sosnoski.co.nz Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117 Smith,Drew wrote: > > Per my previous email, I've been trying to compile bindings from > different archives using the 1.2 <include precompiled="true"/> > feature. That part seemed to work, it imported the mappings and > didn't try to compile them again, but it appears that this brought > another error when compiling the parent object containing the included > mappings: > > Error running binding compiler > > *** Error during code generation for file 'claims-binding.xml' - > please enter a > bug report for this error in Jira if the problem is not listed as > fixed on the o > nline status page *** > > org.jibx.runtime.JiBXException: Classloader conflict for binding > 'common_message > _binding' - factory does not implement required interface > at > org.jibx.runtime.BindingDirectory.getFactory(BindingDirectory.java:27 > 0) > at > org.jibx.binding.def.BindingBuilder.unmarshalInclude(BindingBuilder.j > ava:2005) > at > org.jibx.binding.def.BindingBuilder.unmarshalBindingDefinition(Bindin > gBuilder.java:2084) > at org.jibx.binding.Utility.loadBinding(Utility.java:314) > at org.jibx.binding.Utility.loadFileBinding(Utility.java:431) > at org.jibx.binding.Compile.compile(Compile.java:212) > at org.jibx.binding.Compile.main(Compile.java:374) > > common-message-binding is the name of the binding file obviously: > > public class JiBX_common_message_bindingFactory extends > BindingFactoryBase implements IBindingFactory > { > private static IBindingFactory m_inst; > } > > I ran the compiler command with the verbose command, and it definitely > is pulling in the 1.2 BindingDirectory, BindingBuilder, etc. classes, > and the including, previously compiled binding was run with the same. > > Looking at the BindingDirectory code, we see this snippet: > > if (result instanceof IBindingFactory) { > > That if statement will evaluate to false if result == null, and there > is no null check, so the printed stack trace might not be the actual > error. Also, is instanceof the best evaluator? Wouldn't it be better > to use the reflections api with something like: > > Class clazz = Class./forName/(className); > List<Class> interfacesList = Arrays.asList(clazz.getInterfaces()); > if(!interfacesList.contains(IBindingFactory.class)) > { > throw new Exception(clazz.getName() + " does not implement " + > IBindingFactory.class.getName()); > } > > Or > > if (result != null && result instanceof IBindingFactory) { > > Thanks, > Drew > > ------------------------------------------------------------------------ > CONFIDENTIALITY NOTICE This message and any included attachments are > from Cerner Corporation and are intended only for the addressee. The > information contained in this message is confidential and may > constitute inside or non-public information under international, > federal, or state securities laws. Unauthorized forwarding, printing, > copying, distribution, or use of such information is strictly > prohibited and may be unlawful. If you are not the addressee, please > promptly delete this message and notify the sender of the delivery > error by e-mail or you may call Cerner's corporate offices in Kansas > City, Missouri, U.S.A at (+1) (816)221-1024. > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) > software. With Adobe AIR, Ajax developers can use existing skills and code to > build responsive, highly engaging applications that combine the power of local > resources and data with the reach of the web. Download the Adobe AIR SDK and > Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com > ------------------------------------------------------------------------ > > _______________________________________________ > jibx-users mailing list > jibx-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jibx-users > ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users