Skip to main content



      Home
Home » Modeling » TMF (Xtext) » update from 2.1 to 2.6.2 problem(null pointer replacing EclipseResourceFileSystemAccess by EclipseResourceFileSystemAccess2)
update from 2.1 to 2.6.2 problem [message #1404900] Wed, 06 August 2014 01:26 Go to next message
Eclipse UserFriend
Hello,

I'm porting my plugin source code from xtext 2.1 to 2.6.2.
Specifically, I'd like to replace the following code because class EclipseResourceFileSystemAccess has been deprecated:

EclipseResourceFileSystemAccess fsa = new EclipseResourceFileSystemAccess();
fsa.setRoot(project.getWorkspace().getRoot());
fsa.setOutputPath(filePathF);

for (Resource r : model.getResources()) {
generator.doGenerate(fileNameF, functionName, subfunctionName, r, fsa);
}


My new code is very similar:

EclipseResourceFileSystemAccess2 fsa2 = new EclipseResourceFileSystemAccess2();
fsa2.setOutputPath(filePathF);
fsa2.setMonitor(monitor);
fsa2.setProject(project);

for (Resource r : model.getResources()) {
generator.doGenerate(fileNameF, functionName, subfunctionName, r, fsa2);
}


Unfortunately the new code rises a NullPointer Exception in EclipseResourceFileSystemAccess2.generateFile(String fileName, String outputName, CharSequence contents).
This is the stack trace:

java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:423)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:527)
at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:284)
at org.eclipse.ui.internal.progress.ProgressManager$3.run(ProgressManager.java:983)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:1018)
at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:993)
at com.nttdata.ansaldosts.wslmplugin.report.handlers.GenReportDetailsHandler.execute(GenReportDetailsHandler.java:125)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:247)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:229)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:149)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:825)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.handleWidgetSelection(HandledContributionItem.java:701)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.access$6(HandledContributionItem.java:685)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem$4.handleEvent(HandledContributionItem.java:613)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)

Caused by: java.lang.NullPointerException
at org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2.getTraceFile(EclipseResourceFileSystemAccess2.java:483)
at org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2.generateFile(EclipseResourceFileSystemAccess2.java:173)
at org.eclipse.xtext.generator.AbstractFileSystemAccess.generateFile(AbstractFileSystemAccess.java:97)
at com.nttdata.ansaldosts.wslmplugin.report.template.GenReportDetails.generateReport(GenReportDetails.java:69)
at com.nttdata.ansaldosts.wslmplugin.report.template.GenReportDetails.doGenerate(GenReportDetails.java:47)
at com.nttdata.ansaldosts.wslmplugin.report.template.GenReportDetails.doGenerate(GenReportDetails.java:43)
at com.nttdata.ansaldosts.wslmplugin.report.handlers.GenReportDetailsHandler$1.run(GenReportDetailsHandler.java:156)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)


The null pointer is due to the fact that fileBasedTraceInformation (in EclipseResourceFileSystemAccess2) is not initialized.


Can anybody suggest me where is my mistake?

Thank you.
Silvia
Re: update from 2.1 to 2.6.2 problem [message #1404946 is a reply to message #1404900] Wed, 06 August 2014 03:58 Go to previous messageGo to next message
Eclipse UserFriend
you should create your instance of EclipseResourceFileSystemAccess2 via guice: http://koehnlein.blogspot.de/2012/11/xtext-tip-how-do-i-get-guice-injector.html

Re: update from 2.1 to 2.6.2 problem [message #1404968 is a reply to message #1404946] Wed, 06 August 2014 05:06 Go to previous messageGo to next message
Eclipse UserFriend
Thank you Christian for your answer but I'm lost.
I cannot find any references contained in the tutorial you show me.

May be my problem is that I don't have a xtext grammar so I don't have any ExecutableExtensionFactory class.


My plugin has an EMF model which contains data.
The plugin provides a menu item in order to generate a report.

The report is built starting from the analysis of data contained in the EMF model, aggregated in a different way.
At the present day, the GenerateReportHandler class instantiate the EclipseResourceFileSystemAccess to pass it to the generator class.
The generator class is an xtend class implementing IGenerator interface; it scans the EMF model, analyses data and produces output data to be written in the output report file.


In this context I don't understand how to get injector from Activator class.
I'm sorry.

Silvia








Re: update from 2.1 to 2.6.2 problem [message #1404972 is a reply to message #1404968] Wed, 06 August 2014 05:19 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

you can create a EceutableExtensionFactory yourself.

just have a look what xtext creates for UI Projects

and habe a look at http://kthoms.wordpress.com/2011/09/28/moving-an-xtend-generator-into-its-own-plugin/
Re: update from 2.1 to 2.6.2 problem [message #1737878 is a reply to message #1404900] Wed, 13 July 2016 14:25 Go to previous messageGo to next message
Eclipse UserFriend
I'm in the same painful spot.

I'm trying to manually call doGenerate() because I have no control over when it's happening, and it's doing it at a bad time for my DSL model (which I modify in a afterModelLinked hook)

Found this blog:

https://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/

replaced the deprecated EclipseResourceFileSystemAccess with EclipseResourceFileSystemAccess2 and then I have confusing Injection errors.


!ENTRY org.eclipse.ui 4 0 2016-07-13 14:23:16.495
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.NullPointerException
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:68)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:252)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:234)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:493)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:486)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
Re: update from 2.1 to 2.6.2 problem [message #1737880 is a reply to message #1737878] Wed, 13 July 2016 14:35 Go to previous messageGo to next message
Eclipse UserFriend
I do have a MyDslExecutableExtensionFactory.

The only other references I can find to EclipseResourceFileSystemAccess2 is in org.eclipse.xtext.builder.

To me it looks like the builder is doing the "same Injector magic" as my handler.
Re: update from 2.1 to 2.6.2 problem [message #1737884 is a reply to message #1737880] Wed, 13 July 2016 14:49 Go to previous messageGo to next message
Eclipse UserFriend
Can you give more context what you are doing
Re: update from 2.1 to 2.6.2 problem [message #1737889 is a reply to message #1737878] Wed, 13 July 2016 15:08 Go to previous messageGo to next message
Eclipse UserFriend

my fsa had a null monitor. <doh>
Re: update from 2.1 to 2.6.2 problem [message #1737893 is a reply to message #1737889] Wed, 13 July 2016 15:43 Go to previous messageGo to next message
Eclipse UserFriend
so is there still a problem or not?
Re: update from 2.1 to 2.6.2 problem [message #1737967 is a reply to message #1404972] Thu, 14 July 2016 09:40 Go to previous message
Eclipse UserFriend
Thanks for the follow up Christian. For the most part we have this manual invocation of the doGenerate() working now. I'm having some small issues with gettting he context menu on the ProjectExplorer to pop.

We did have to add the following 3 lines of code slightly different from your original blog - but that's expected after 5 years authoring it.

final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get();
fsa.setMonitor(new NullProgressMonitor());
fsa.setProject(project);
fsa.setOutputPath(srcGenFolder.getName());

We have other issues with the doGenerate() and when it's getting called in our GUI and command line builds - especially w.r.t. when we are using afterModelLinked() in our subclassed LazyLinker, but that's probably more appropriate for a separate thread.

Thanks and thanks for the original blog post!

[Updated on: Thu, 14 July 2016 09:40] by Moderator

Previous Topic:Xtext auto content assist not working for underscore
Next Topic:Complementing EMF/GMF-based Editor with Xtext
Goto Forum:
  


Current Time: Sat Jul 05 05:56:09 EDT 2025

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

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

Back to the top