Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Read-only session for image exporting
Read-only session for image exporting [message #1827922] Wed, 27 May 2020 05:37 Go to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 259
Registered: August 2013
Senior Member
Hi

I'm using such a code to export a diagram to an external image file:
        Session session = SessionManager.INSTANCE.getSession(reprURI, new NullProgressMonitor());
        ExportFormat exportFormat = new ExportFormat(ExportDocumentFormat.NONE, ImageFileFormat.PNG,
                ScalingPolicy.AUTO_SCALING, 50);
        DialectUIManager.INSTANCE.export(desc.getRepresentation(), session, imagePath,
                exportFormat, new NullProgressMonitor());


An aird file is contained inside a plugin's jar file. So it should not me modified. reprURI has the following form: platform:/plugin/...

The problem is that I get the following exception:
java.lang.RuntimeException: Session creation failed
	at org.eclipse.sirius.business.internal.session.SessionManagerImpl.getSession(SessionManagerImpl.java:269)
...
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: org.eclipse.core.runtime.CoreException: Session creation failed
	at org.eclipse.sirius.business.internal.session.SessionFactoryImpl.prepareDAnalysis(SessionFactoryImpl.java:281)
	at org.eclipse.sirius.business.internal.session.SessionFactoryImpl.createSessionResource(SessionFactoryImpl.java:237)
	at org.eclipse.sirius.business.internal.session.SessionFactoryImpl.createSession(SessionFactoryImpl.java:89)
	at org.eclipse.sirius.business.internal.session.SessionManagerImpl.getSession(SessionManagerImpl.java:262)
	... 5 more
Caused by: java.net.UnknownServiceException: protocol doesn't support output
	at java.net.URLConnection.getOutputStream(Unknown Source)
	at org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createOutputStream(URIHandlerImpl.java:154)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createOutputStream(ExtensibleURIConverterImpl.java:347)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1041)
	at org.eclipse.sirius.business.internal.session.SessionFactoryImpl.prepareDAnalysis(SessionFactoryImpl.java:279)
	... 8 more


Is it possible to create a read-only session? Or is there an alternative way to export an image?
Re: Read-only session for image exporting [message #1828256 is a reply to message #1827922] Fri, 05 June 2020 06:58 Go to previous messageGo to next message
Florian Barbin is currently offline Florian BarbinFriend
Messages: 246
Registered: August 2010
Senior Member
Hi,

Sorry for the delay.

It is unexpected since image export should not modify the Sirius Session and trigger the Session saving.
The stack suggests that your code attempted to create a new resource (EMF) in the Session. It's hard yo say more without the complete call stack.

Regards,

Florian
Re: Read-only session for image exporting [message #1828494 is a reply to message #1828256] Wed, 10 June 2020 18:16 Go to previous message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 496
Registered: July 2009
Location: Nantes, France
Senior Member
Hi Denis,

Regarding the call stack, it seems that there is no existing aird file corresponding to your reprURI. This triggers the session resource creation and the save attempt.
Could you check your uri ? do you execute the code from a runtime or form a built product (regarding how you built your uri, you might be impacted by https://bugs.eclipse.org/bugs/show_bug.cgi?id=160133)

Regards


(The code checking the existence is done with ted.getResourceSet().getURIConverter().exists(sessionResourceURI, null);)


Maxime Porhel - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius

Join the Sirius community at SiriusCon. Register for free: Nov. 9th Paris
http://www.siriuscon.org/
Previous Topic:Determining the order
Next Topic:Domain Model Migration and Sirius
Goto Forum:
  


Current Time: Wed Oct 28 06:54:45 GMT 2020

Powered by FUDForum. Page generated in 0.01623 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top