Bug 439095 - SAX2 driver class org.apache.xerces.parsers.SAXParser not found
Summary: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 1.0.0   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 2.0.0   Edit
Assignee: Maxime Porhel CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
: 441755 446928 (view as bug list)
Depends on:
Blocks: 448495
  Show dependency tree
 
Reported: 2014-07-08 03:05 EDT by Jonathan Dumont CLA
Modified: 2017-06-08 10:11 EDT (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Dumont CLA 2014-07-08 03:05:14 EDT
Hi,

I try to build a feature containing a graphical editor based on Sirius, to be able to install it in an existing RCP application.

The problem is that when I try to open an editor containing 'Dot' representations, I have the following exception :

[code]
    java.io.IOException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
	at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown Source)
	at org.apache.batik.dom.util.SAXDocumentFactory.createDocument(Unknown Source)
	at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown Source)
	at org.eclipse.sirius.diagram.ui.tools.api.figure.SVGFigure.loadDocument(SVGFigure.java:90)
	at org.eclipse.sirius.diagram.ui.tools.api.figure.SVGFigure.getDocument(SVGFigure.java:105)
	at org.eclipse.sirius.diagram.ui.tools.api.figure.BundledImageFigure.updateDocumentColors(BundledImageFigure.java:194)
	at org.eclipse.sirius.diagram.ui.tools.api.figure.BundledImageFigure.updateColors(BundledImageFigure.java:147)
	at org.eclipse.sirius.diagram.ui.tools.api.figure.BundledImageFigure.refreshFigure(BundledImageFigure.java:311)
	at org.eclipse.sirius.diagram.ui.tools.api.figure.BundledImageFigure.createImageFigure(BundledImageFigure.java:119)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.BundledImageEditPart.createNodeShape(BundledImageEditPart.java:133)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.BundledImageEditPart.createNodeFigure(BundledImageEditPart.java:189)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart.createFigure(ShapeNodeEditPart.java:90)
[/code]


If I don't misunderstood, my plugins included in this feature depend on the Sirius plugins, which depend themself on the Apache Batik plugins. But the Batik plugin references the Apache Xerces driver as an optional Import-Package :

[code]
Bundle-SymbolicName: org.apache.batik.dom
(...)
Import-package: org.w3c.dom,org.apache.xerces.parsers;resolution:=optional
[/code]


Is it normal that the Sirius plugin doesn't depend on the Xerces plugin to ensure that the optional package is resolved ?

Regards,
Jonathan
Comment 1 Maxime Porhel CLA 2014-07-08 05:23:21 EDT
Note that RCP is not a primary target for Sirius, and so be aware that various parts of Sirius depend on the workspace and workbench. 


See various aspects of using Xerces in Eclipse in the "Xerces in Eclipse" wiki page: https://wiki.eclipse.org/Orbit/Xerces_in_Eclipse . Note that "It's not always easy" as said in the page.
Comment 2 Jonathan Dumont CLA 2014-07-08 05:32:45 EDT
I have a workaround : I have create my own plugin containing the jar provided by Orbit to offer the needed packages. 

It's not the best solution I think but when I just add the dependencies to the Orbit plugins in my plugin, it doesn't work. The Apache Xerces plugin from Orbit is well included during my feature installation, but the driver is still not found.
Comment 3 Charlie Mordant CLA 2014-07-25 17:04:16 EDT
Same here with the Modeling product testing EcoreTools2 and UML designer on a Mac.

What do you mean when you say "Note that RCP is not a primary target for Sirius"?
Comment 4 Cedric Brun CLA 2014-07-28 05:25:59 EDT
Jonathan , we are trying to narrow down the cases where Eclipse does not find a xerces parser. Were you building on a Mac ? if so which version with which JVM ?

We also need to figure out what "harm" could be done if explicitely requiring the Xerces bundles in the Sirius features (or have a specific "required third parties" feature)  accross the JVM range we support (from 1.6), os environment(windows, linux and macos) and Eclipse platforms (3.8 and 4.4.)..
Comment 5 Pierre-Charles David CLA 2014-08-04 10:00:18 EDT
(In reply to Charlie Mordant from comment #3)
> What do you mean when you say "Note that RCP is not a primary target for
> Sirius"?

Well, for example org.eclipse.sirius.ui depends on org.eclipse.ui.ide which defines the 'project nature' extension point, but that plug-in is not part of RCP (https://wiki.eclipse.org/RCP_FAQ#What_is_included_in_the_Rich_Client_Platform.3F). There are probably others. Basically we currently assume we run under a mostly standard Eclipse IDE and may depend on stuff from that context which are not available in a pure/minimal RCP setting.
Comment 6 Jonathan Dumont CLA 2014-08-13 10:18:18 EDT
Sorry for the delay, but to answer to your question we do not build on Mac, only on Windows and Linux, for 32 and 64b platforms. And we use a JVM 1.7.0_17.

Regards
Comment 7 Maxime Porhel CLA 2014-10-22 04:55:01 EDT
I currently reproduce the issue on my dev environment:
Luna SR1
Mac OS Yosemite
java.vm.name=Java HotSpot(TM) 64-Bit Server VM
java.vm.specification.name=Java Virtual Machine Specification
java.vm.specification.vendor=Oracle Corporation
java.vm.specification.version=1.7
java.vm.vendor=Oracle Corporation
java.vm.version=24.71-b01

It same I have the same issue than reported in https://bugs.openjdk.java.net/browse/JDK-8017491

In some situations I am able to load and see SVG images on my diagrams, but in other cases it fails to open an existing diagram with SVG Images (define in the VSM or user defined, and when using the new Ecore Modeling Project which opens a diagram).

I observed some difference between working and KO situations: 
 . KO: Thread.currentThread().getContextClassLoader() is null and 
 . OK: Thread.currentThread().getContextClassLoader() is a org.eclipse.osgi.internal.framework.ContextFinder
               

If I add the following draft workaround code in SVGImageFigure, it allows to avoid the error:
 if (Thread.currentThread().getContextClassLoader() == null) {
     Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
 }
 document = factory.createDocument(uri);

When I run the same scenario on my previous machin (Win8), I always have a context class loader, but I have detected a difference between my two computers:
 . On windows, the current thread is a ModalContext$ModalContextThread
 . On Mac OS, 
     . when it fails, in the stack I can SEE that the current thread is the AppKit main thread, (sometimes I see org.eclipse.jface.operation.ModalContext.runInCurrentThread where on Win8 I have a ModalContextThread),
     . when it works (reopen a runtime with an already open Diagram with svg), there is no Modal context in the stack, and the Thread.currentThread().getContextClassLoader() is a org.eclipse.osgi.internal.framework.ContextFinder
Comment 8 Maxime Porhel CLA 2014-10-22 08:09:47 EDT
See https://git.eclipse.org/r/35319
 . Avoid several NPE when transcoder is null (side effects of the SAXParser not found error)
 . If the SaxParser is not found and if the current thread context class loader is null, retry once with the class loader of SVGImageFigure.
Comment 9 Maxime Porhel CLA 2014-10-22 10:58:48 EDT
The proposed fix has been merged on master for 2.0.0, see commit afbfffda43118dc4dc244f64b5eaa97df8a093c0
Comment 10 Jonathan Dumont CLA 2014-10-22 11:11:04 EDT
Great news !

I will wait the 2.0.0 release (October 24, 2014 if I don't make a mistake) and confirm the correction.
Comment 11 Cedric Brun CLA 2014-10-23 05:39:45 EDT
*** Bug 446928 has been marked as a duplicate of this bug. ***
Comment 12 Maxime Porhel CLA 2014-10-23 08:55:30 EDT
With a nightly build which contains the submitted fix, I do not get the exception anymore and the diagram shows my svg image.
Comment 13 Charlie Mordant CLA 2014-10-23 09:24:52 EDT
Well done, thanks!
I'll test this patch as sooner as possible
Comment 14 Laurent Redor CLA 2014-10-24 09:17:11 EDT
Verified with Sirius 2.0.0-S20141024-041312
Comment 15 Pierre-Charles David CLA 2014-10-27 06:52:23 EDT
Available in Sirius 2.0.0.
Comment 16 Maxime Porhel CLA 2014-11-06 10:05:26 EST
*** Bug 441755 has been marked as a duplicate of this bug. ***
Comment 17 Aurelien Pupier CLA 2015-12-17 04:26:34 EST
Hi,

we applied the same kind of fix in our product based on GMF. Some users based on the last Mac OS version, El Capitan, are complaining about the issue to be back. Do you encounter the issue back too?
Comment 18 Maxime Porhel CLA 2016-01-04 08:22:26 EST
(In reply to Aurelien Pupier from comment #17)
> Hi,
> 
> we applied the same kind of fix in our product based on GMF. Some users
> based on the last Mac OS version, El Capitan, are complaining about the
> issue to be back. Do you encounter the issue back too?

Hi Aurélien, 

I currently use El Capitan and I do encounter the issue back. I do not reproduce the issue (with Mars or Neon as target platform) and for the moment no user complained about the issue to be back. 

Regards; 

Maxime
Comment 19 Maxime Porhel CLA 2016-01-04 09:40:28 EST
It seems that a "not" disappeared from my comment. 

I do NOT encounter the issue back.

(In reply to Maxime Porhel from comment #18)
> (In reply to Aurelien Pupier from comment #17)
> > Hi,
> > 
> > we applied the same kind of fix in our product based on GMF. Some users
> > based on the last Mac OS version, El Capitan, are complaining about the
> > issue to be back. Do you encounter the issue back too?
> 
> Hi Aurélien, 
> 
> I currently use El Capitan and I do NOT encounter the issue back. I do not
> reproduce the issue (with Mars or Neon as target platform) and for the
> moment no user complained about the issue to be back. 
> 
> Regards; 
> 
> Maxime
Comment 20 Eclipse Genie CLA 2017-06-08 10:11:59 EDT
New Gerrit change created: https://git.eclipse.org/r/98911