Debugging deeper, the issue is in the context class loaders in
ClassLoaderUtil

        try {
            return loadClass(className, ccl);
        } catch (ClassNotFoundException cnf) {
            return loadClass(className, null);
        }

The second loadClass method there properly loads the class (when forced
to), the first one is where the exception is occurring.




On Sat, Nov 14, 2015 at 8:23 AM Grant Ingersoll <gsing...@apache.org> wrote:

> But wait, there's more:
>
> Here's the code in question:
>  XMLInputFactory factory;
>
>         try {
>             // Woodstox is the only supported and tested StAX
> implementation
>             WstxInputFactory wstxFactory = (WstxInputFactory)
> ClassLoaderUtil.loadClass(
>                     "com.ctc.wstx.stax.WstxInputFactory").newInstance();
>             wstxFactory.configureForSpeed();
>
>             factory = wstxFactory;
>         } catch (Exception e) {
>             // other StAX implementations may work, too
>             factory = XMLInputFactory.newInstance();
>
>             try {
>                 // for the SJSXP parser
>                 factory.setProperty("reuse-instance", Boolean.FALSE);
>             } catch (IllegalArgumentException ex) {
>                 // ignore
>             }
>
>             LOG.warn("Unsupported StAX parser: " +
> factory.getClass().getName() + " (Exception: " + e.toString() + ")",
>                     e);
>         }
>
> The exception occurs in the try block and then we proceed into the catch
> block, where factory = XMLInputFactory.newInstance() kicks in and works!
>
> Guess what StAX parser it loads?  Yep: com.ctc.wstx.stax.WstxInputFactory.
> Go figure.  And everything works fine after that.
>
>
>
> On Sat, Nov 14, 2015 at 7:57 AM Grant Ingersoll <gsing...@apache.org>
> wrote:
>
>> I know I must have some conflicting libraries somewhere on my classpath,
>> but I'm wondering if anyone else has seen the exception below.  As you can
>> see by the message, it is rather perplexing.  My classpath has 2 versions
>> of woodstox on it: 4.4.0 (from CMIS) and 4.4.1 from somewhere else.  I am
>> suspecting I have some classloader isolation issues (e.g. parent is loading
>> one lib, child is loading a diff. one), but I thought I would ask to see if
>> anyone else has seen it.
>>
>> Thanks,
>> Grant
>>
>> 2015-11-14T07:51:26,440 - WARN  [qtp1496724653-21:XMLUtils@74] -
>> {collectionId=alf, datasourceId=alf} - Unsupported StAX parser:
>> com.ctc.wstx.stax.WstxInputFactory (Exception:
>> java.lang.ClassCastException: com.ctc.wstx.stax.WstxInputFactory cannot be
>> cast to com.ctc.wstx.stax.WstxInputFactory)
>>
>> java.lang.ClassCastException: com.ctc.wstx.stax.WstxInputFactory cannot
>> be cast to com.ctc.wstx.stax.WstxInputFactory
>>
>> at
>> org.apache.chemistry.opencmis.commons.impl.XMLUtils.<clinit>(XMLUtils.java:58)
>> [chemistry-opencmis-commons-impl-0.13.0.jar:0.13.0]
>>
>> at
>> org.apache.chemistry.opencmis.client.bindings.spi.atompub.AtomPubParser.parse(AtomPubParser.java:98)
>> [chemistry-opencmis-client-bindings-0.13.0.jar:0.13.0]
>>
>> at
>> org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.parse(AbstractAtomPubService.java:620)
>> [chemistry-opencmis-client-bindings-0.13.0.jar:0.13.0]
>>
>> at
>> org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getRepositoriesInternal(AbstractAtomPubService.java:809)
>> [chemistry-opencmis-client-bindings-0.13.0.jar:0.13.0]
>>
>> at
>> org.apache.chemistry.opencmis.client.bindings.spi.atompub.RepositoryServiceImpl.getRepositoryInfos(RepositoryServiceImpl.java:65)
>> [chemistry-opencmis-client-bindings-0.13.0.jar:0.13.0]
>>
>> at
>> org.apache.chemistry.opencmis.client.bindings.impl.RepositoryServiceImpl.getRepositoryInfos(RepositoryServiceImpl.java:90)
>> [chemistry-opencmis-client-bindings-0.13.0.jar:0.13.0]
>>
>> at
>> org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.getRepositories(SessionFactoryImpl.java:135)
>> [chemistry-opencmis-client-impl-0.13.0.jar:0.13.0]
>>
>> at
>> org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.getRepositories(SessionFactoryImpl.java:112)
>> [chemistry-opencmis-client-impl-0.13.0.jar:0.13.0]
>>
>

Reply via email to