Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF-IncQuery » java.lang.Override is not on the classpath
java.lang.Override is not on the classpath [message #1386780] Fri, 20 June 2014 12:05 Go to next message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 136
Registered: July 2009
Senior Member
Hi,
currently I try to migrate my stuff to IncQuery 0.8. As already
mentioned in other discussions I use the generic IncQuery API to load
patterns and to execute queries. When my tool is to be used then some
pattern resources are intended to be loaded. The loading is done in the
normal EMF way:

URI uri = URI.createPlatformPluginURI(bundle.getSymbolicName() + "/" +
patternResourcePathInBundle, true);
ResourceSet rs = new ResourceSetImpl();
resource = rs.getResource(uri, true);
EObject model = resource.getContents().get(0);
if(model instanceof PatternModel){
// something with the loaded pattern
}

The problem is that I get the following exceptions when the contents is
tried to be loaded (getContents().get(0)). The resource itself is not
null and inspecting the contents while debugging suggests that it was
correctly loaded and contains patterns.

!MESSAGE Error initializing JvmElement

!STACK 0
java.lang.IllegalArgumentException: The type java.lang.Override is not
on the classpath.
at
org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.toAnnotation(JvmTypesBuilder.java:979)
at
org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.toAnnotation(JvmTypesBuilder.java:958)
at
org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.toAnnotation(JvmTypesBuilder.java:928)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.PatternMatchProcessorClassInferrer$3.apply(PatternMatchProcessorClassInferrer.java:108)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.PatternMatchProcessorClassInferrer$3.apply(PatternMatchProcessorClassInferrer.java:1)
at
org.eclipse.incquery.patternlanguage.emf.util.EMFJvmTypesBuilder.initializeSafely(EMFJvmTypesBuilder.java:103)
at
org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder.toMethod(JvmTypesBuilder.java:622)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.PatternMatchProcessorClassInferrer.inferProcessorClassMethods(PatternMatchProcessorClassInferrer.java:141)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.PatternMatchProcessorClassInferrer.inferProcessorClass(PatternMatchProcessorClassInferrer.java:71)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.EMFPatternLanguageJvmModelInferrer.inferPublic(EMFPatternLanguageJvmModelInferrer.java:200)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.EMFPatternLanguageJvmModelInferrer.infer(EMFPatternLanguageJvmModelInferrer.java:150)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.EMFPatternLanguageJvmModelInferrer._infer(EMFPatternLanguageJvmModelInferrer.java:315)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.EMFPatternLanguageJvmModelInferrer.infer(EMFPatternLanguageJvmModelInferrer.java:337)
at
org.eclipse.xtext.xbase.jvmmodel.JvmModelAssociator.installDerivedState(JvmModelAssociator.java:302)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.EMFPatternJvmModelAssociator.installDerivedState(EMFPatternJvmModelAssociator.java:46)
at
org.eclipse.xtext.resource.DerivedStateAwareResource.installDerivedState(DerivedStateAwareResource.java:145)
at
org.eclipse.xtext.xbase.resource.BatchLinkableResource.getContents(BatchLinkableResource.java:130)

and

java.lang.NullPointerException: type
at
org.eclipse.xtext.common.types.util.TypeReferences.createTypeRef(TypeReferences.java:98)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.PatternGroupClassInferrer.inferSpecificationGetter(PatternGroupClassInferrer.java:238)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.PatternGroupClassInferrer.initializePatternGroup(PatternGroupClassInferrer.java:112)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.EMFPatternLanguageJvmModelInferrer$8.apply(EMFPatternLanguageJvmModelInferrer.java:309)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.EMFPatternLanguageJvmModelInferrer$8.apply(EMFPatternLanguageJvmModelInferrer.java:1)
at
org.eclipse.xtext.xbase.jvmmodel.JvmModelAssociator.installDerivedState(JvmModelAssociator.java:305)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.EMFPatternJvmModelAssociator.installDerivedState(EMFPatternJvmModelAssociator.java:46)
at
org.eclipse.xtext.resource.DerivedStateAwareResource.installDerivedState(DerivedStateAwareResource.java:145)
at
org.eclipse.xtext.xbase.resource.BatchLinkableResource.getContents(BatchLinkableResource.java:130)



I found out that the exceptions won't appear if I execute the following
before loading the resource (source code above):

new
EMFPatternLanguageStandaloneSetup().createInjectorAndDoEMFRegistration();

But, normally this should not be done when IncQuery tooling is loaded,
as can be seen here:

https://wiki.eclipse.org/EMFIncQuery/UserDocumentation/API/Advanced#Sample_code

And if I invoke the createInjectorAndDoEMFRegistration() method then I
get the following exceptions if I want to load a pattern model via the
Query Explorer with the play button:

!ENTRY org.eclipse.ui 4 0 2014-06-20 13:59:41.945
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable
(java.lang.NullPointerException: type)
at org.eclipse.swt.SWT.error(SWT.java:4397)
at org.eclipse.swt.SWT.error(SWT.java:4312)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4145)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3762)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
at
org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
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:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.lang.NullPointerException: type
at
org.eclipse.xtext.common.types.util.TypeReferences.createTypeRef(TypeReferences.java:98)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.PatternGroupClassInferrer.inferSpecificationGetter(PatternGroupClassInferrer.java:238)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.PatternGroupClassInferrer.initializePatternGroup(PatternGroupClassInferrer.java:112)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.EMFPatternLanguageJvmModelInferrer$8.apply(EMFPatternLanguageJvmModelInferrer.java:309)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.EMFPatternLanguageJvmModelInferrer$8.apply(EMFPatternLanguageJvmModelInferrer.java:1)
at
org.eclipse.xtext.xbase.jvmmodel.JvmModelAssociator.installDerivedState(JvmModelAssociator.java:305)
at
org.eclipse.incquery.patternlanguage.emf.jvmmodel.EMFPatternJvmModelAssociator.installDerivedState(EMFPatternJvmModelAssociator.java:46)
at
org.eclipse.xtext.resource.DerivedStateAwareResource.installDerivedState(DerivedStateAwareResource.java:145)
at
org.eclipse.xtext.xbase.resource.BatchLinkableResource.getContents(BatchLinkableResource.java:130)
at
org.eclipse.incquery.tooling.ui.queryexplorer.util.DisplayUtil.extractPatternModelFromResource(DisplayUtil.java:323)
at
org.eclipse.incquery.tooling.ui.queryexplorer.util.DisplayUtil.parseEPM(DisplayUtil.java:387)
at
org.eclipse.incquery.tooling.ui.queryexplorer.handlers.RuntimeMatcherRegistrator.registerPatternsFromPatternModel(RuntimeMatcherRegistrator.java:122)
at
org.eclipse.incquery.tooling.ui.queryexplorer.handlers.RuntimeMatcherRegistrator.run(RuntimeMatcherRegistrator.java:76)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)


So the notice is right that createInjectorAndDoEMFRegistration() should
not be invoked when IncQuery tooling is loaded. But my problem remains.
How can I avoid the exceptions and how to get both working?

cheers,
Jan
Re: java.lang.Override is not on the classpath [message #1386790 is a reply to message #1386780] Fri, 20 June 2014 13:25 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 255
Registered: July 2009
Senior Member
Hi Jan,

basically, the following is the problem: EMF-IncQuery relies on the Xtext Model Inference process that requires all referenced classes available on the classpath; and this inference process is always executed when parsing an eiq file. In case of the headless Xtext environment (available using the #createInjector... method) the classloader of the running JVM is reused; while in case of the tooling it is assumed that the eiq file is inside a Java projects classpath (e.g. in its source folder).

In other words, the simplest workaround is to put the opened eiq file into a Java project (or preferably IncQuery project) in the workspace. If this does not work for you, I have to think further about what can be done...

Cheers,
Zoltán
Re: java.lang.Override is not on the classpath [message #1386796 is a reply to message #1386790] Fri, 20 June 2014 14:15 Go to previous messageGo to next message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 136
Registered: July 2009
Senior Member
Hi Zoltan,
thanks for your response.

Zoltan Ujhelyi wrote:
> basically, the following is the problem: EMF-IncQuery relies on the
> Xtext Model Inference process that requires all referenced classes
> available on the classpath; and this inference process is always
> executed when parsing an eiq file. In case of the headless Xtext
> environment (available using the #createInjector... method) the
> classloader of the running JVM is reused; while in case of the tooling
> it is assumed that the eiq file is inside a Java projects classpath
> (e.g. in its source folder).
Well, I'm not in a headless context. So why do I get exceptions if I
don't invoke the createInjectorAndDoEMFRegistration() method before
loading my eiq files programmatically?

> In other words, the simplest workaround is to put the opened eiq file
> into a Java project (or preferably IncQuery project) in the workspace.
> If this does not work for you, I have to think further about what can be
> done...
Unfortunately, the open eiq file is inside an IncQuery project in the
source folder. But the exceptions are only thrown if my tool tries to
load the other eiq files programmatically first before pressing play in
the Query Explorer for the open eiq file.

cheers,
Jan
Re: java.lang.Override is not on the classpath [message #1386798 is a reply to message #1386796] Fri, 20 June 2014 14:50 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 255
Registered: July 2009
Senior Member
Hi,

when the tooling is loaded (in Eclipse terms, the corresponding bundle is activated), it registers a lot of stuff that is in conflict with the headless stuff.

However, I have no idea right now why using the Query Explorer solves the problem for loading - this feels like a bug. Can you please open a ticket in Bugzilla for this issue (if possible, with steps to reproduce the concrete issue)? I will try to figure out something shortly.

Cheers,
Zoltán
Re: java.lang.Override is not on the classpath [message #1387022 is a reply to message #1386798] Mon, 23 June 2014 14:07 Go to previous message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 136
Registered: July 2009
Senior Member
I opened a bug report with a small demonstrating plugin:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=437942

cheers,
Jan
Previous Topic:plugin.xml is not being generated automatically
Next Topic:Compare values
Goto Forum:
  


Current Time: Thu Jul 02 08:13:43 GMT 2015

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

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