Using StAX in Java 5 plugin
I'm trying to use a StAX parser in a plugin compiled (and running) under Java 5. I get the exception shown below when trying to access the input factory which indicates no StAX imlementations in the class path. This despite the fact that I added the woodstox Stax parser (and also tried sjsxp as well) to the plugin lib dir.
I tried explicitly setting system properties to use woodstox but then sufferedClassDefNotFound exception on com.ctc.wstx.stax.WstxInputFactory. The proper jars are in my plugin lib dir AFAIK, so they should be in the plugin's classpath right?
System.setProperty("javax.xml.stream.XMLInputFactory", "com.ctc.wstx.stax.WstxInputFactory");
System.setProperty("javax.xml.stream.XMLOutputFactory", "com.ctc.wstx.stax.WstxOutputFactory");
System.setProperty("javax.xml.stream.XMLEventFactory", "com.ctc.wstx.stax.WstxEventFactory");
Any tips for using StaX in a plugin like this?
Thanks!
John Lindwall
Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(1553,352),button=1,modifiers=Button1,clickCount=1] on frame1: Provider com.bea.xml.stream.MXParserFactory not found
javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.MXParserFactory not found
at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)
at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
at javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136)
at com.shopzilla.site.templatevariables.ConfigValuesFactory.<clinit>(ConfigValuesFactory.java:45)
at com.shopzilla.ideaplugin.templateVariables.ui.TemplateVariablesUI$GetValueActionListener.getTemplateVariableValue(TemplateVariablesUI.java:118)
at com.shopzilla.ideaplugin.templateVariables.ui.TemplateVariablesUI$GetValueActionListener.actionPerformed(TemplateVariablesUI.java:96)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
at java.awt.Component.processMouseEvent(Component.java:5602)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5367)
at java.awt.Container.processEvent(Container.java:2010)
at java.awt.Component.dispatchEventImpl(Component.java:4068)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
at java.awt.Container.dispatchEventImpl(Container.java:2054)
at java.awt.Window.dispatchEventImpl(Window.java:1801)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at com.intellij.ide.IdeEventQueue.f(IdeEventQueue.java:96)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:30)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:209)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Please sign in to leave a comment.
I'm suspecting the problem is a classloader issue. My theory is that the javax.xml.stream.XMLInputFactory is being loaded from the parent (ie IntelliJ) classloader. This classloader does not have the woodstox classes in its classpath, hence the FactoryConfigurationError.
If there is a StAX parser in the parent classpath I could use system properties to select that implementation and I think everything would be fine. I'm not sure if this is the case.
Luckily the invocation of XMLInputFactory.newInstance() is in code that I have the source for. My workaround was to modify this code to explicitly instantiate the woodstox implementation directly instead of using the XMLInputFactory. This is ham-handed but does the trick for now.