RSyntaxTextArea icon indicating copy to clipboard operation
RSyntaxTextArea copied to clipboard

SAX Parser error on load

Open erikist opened this issue 10 years ago • 3 comments

Getting this error whenever I try to load a theme via XML

[   9847]  ERROR - pplication.impl.LaterInvocator - org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory 
java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory
    at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
    at org.fife.ui.rsyntaxtextarea.Theme$XmlHandler.load(Theme.java:603)

For the load I am using the example from the wiki:

        try {
            Theme theme = Theme.load(getClass().getResourceAsStream(
                    "/org/fife/ui/rsyntaxtextarea/themes/eclipse_theme.xml"));
            theme.apply(responseBodyEditorPane);
        } catch (IOException ioe) { // Never happens
            ioe.printStackTrace();
        }

erikist avatar Sep 27 '16 20:09 erikist

Sounds like a dependency issue. Is this an OSGi app, or some other classloadery framework-based app? Whether it is or isn't, the issue is likely more than one Xerces on your classpath and one causing trouble.

Hopefully some starting points:

  • http://stackoverflow.com/questions/6596218/parser-error-on-xpand-saxparserfactoryimpl-cannot-be-cast-to-saxparserfactory
  • https://answers.atlassian.com/questions/104121/im-blocked-help-cannot-be-cast-to-javax.xml.parsers.saxparserfactory

bobbylight avatar Sep 27 '16 22:09 bobbylight

Ahhh, I am using this within an intellij plugin because there's zero documentation on how to or whether or not it is possible to use internal intellij syntax highlighting. So maybe there's a collision in there?

erikist avatar Sep 28 '16 18:09 erikist

Interesting, I didn't know there was a plugin - which one exactly? I see some IntelliJ plugins that use RSTA - soapUI, JSON formatting, etc.

My guess is yes - IntelliJ has xerces on its classpath. Unfortunately I won't be much help diagnosing it. :( It might be that getClass().getClassLoader() is the wrong classloader (if IntelliJ threads its plugin loading or gives each plugin its own classpath in some other way).

bobbylight avatar Sep 29 '16 02:09 bobbylight