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: 343
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: 270
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 messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
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
Re: Read-only session for image exporting [message #1847494 is a reply to message #1827922] Fri, 29 October 2021 03:23 Go to previous message
Ts Bao is currently offline Ts BaoFriend
Messages: 7
Registered: August 2021
Junior Member
Hi Denis,
I replied to this topic one year later, because I also encountered similar problems in the process of exporting images. Have you finally solved your problem? Could you tell me your solution?
I explained my problem in the topichttps://www.eclipse.org/forums/index.php/t/1109277/

[Updated on: Fri, 29 October 2021 03:25]

Report message to a moderator

Previous Topic:Broken looking diagram image exports on Linux
Next Topic:CreateRepresentation API call fails with 'No handler found for event: CreateRepresentationInput'
Goto Forum:
  


Current Time: Tue Apr 23 15:18:53 GMT 2024

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

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

Back to the top