Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » JVM types not found exception.
JVM types not found exception. [message #675210] Mon, 30 May 2011 15:29 Go to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hello,

I have this grammar which extends the xbase grammar, xbase makes use of
JVM types. when I generated the grammar and artifacts, I can't use the
java types, as it seems no resource is available containing the types.

What do I need to do to make this work?


xbase includes this URI

import
"platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.ecore"
as types


the configuration includes:

// provides the necessary bindings for java types integration
fragment = types.TypesGeneratorFragment {}



Is this a plugin dependency missing or perhaps a configuration issue?
What am I doing wrong?

See the stacktrace here.


Caused by: java.lang.UnsupportedOperationException
at
org.eclipse.xtext.common.types.access.jdt.NullJdtTypeProvider.createResource(NullJdtTypeProvider.java:49)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource(ResourceSetImpl.java:425)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandCreateResource(ResourceSetImpl.java:239)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:391)
at
org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:23)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:216)
at
org.eclipse.xtext.common.types.util.TypeReferences.findDeclaredType(TypeReferences.java:180)
at
org.eclipse.xtext.common.types.util.TypeReferences.getTypeForName(TypeReferences.java:143)
at
org.eclipse.xtext.xbase.typing.XbaseTypeProvider._type(XbaseTypeProvider.java:586)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Re: JVM types not found exception. [message #675211 is a reply to message #675210] Mon, 30 May 2011 15:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Christophe

This has given me a fair amount of trouble too.

It's a URI resolution problem.

The workaround is to import the org.eclipse.xtext.common.types plugin
into your workspace.

Regards

Ed Willink

On 30/05/2011 16:29, Christophe Bouhier wrote:
> Hello,
>
> I have this grammar which extends the xbase grammar, xbase makes use
> of JVM types. when I generated the grammar and artifacts, I can't use
> the java types, as it seems no resource is available containing the
> types.
>
> What do I need to do to make this work?
>
>
> xbase includes this URI
>
> import
> "platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.ecore"
> as types
>
>
> the configuration includes:
>
> // provides the necessary bindings for java types integration
> fragment = types.TypesGeneratorFragment {}
>
>
>
> Is this a plugin dependency missing or perhaps a configuration issue?
> What am I doing wrong?
>
> See the stacktrace here.
>
>
> Caused by: java.lang.UnsupportedOperationException
> at
> org.eclipse.xtext.common.types.access.jdt.NullJdtTypeProvider.createResource(NullJdtTypeProvider.java:49)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource(ResourceSetImpl.java:425)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandCreateResource(ResourceSetImpl.java:239)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:391)
> at
> org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:23)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:216)
> at
> org.eclipse.xtext.common.types.util.TypeReferences.findDeclaredType(TypeReferences.java:180)
> at
> org.eclipse.xtext.common.types.util.TypeReferences.getTypeForName(TypeReferences.java:143)
> at
> org.eclipse.xtext.xbase.typing.XbaseTypeProvider._type(XbaseTypeProvider.java:586)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Re: JVM types not found exception. [message #675232 is a reply to message #675211] Mon, 30 May 2011 20:03 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi Ed,

I am embedding this xbase editor in an RCP app, and I am looking for an
alternative to put "org.eclipse.xtext.common.types" in the workspace, so
to drill down to the bottom of this, I investigated and found the
following:

I am now getting a MalformedURLException on the following URI:
'java:/Primitives'. Now what happens is that a so called type provider
is installed on a resource set.

The type provider is ultimately resolved in the class:
AbstractTypeProviderFactory , which looks in the EMF registry:

(IJvmTypeProvider)
resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().get(URIHelperConstants.PROTOCOL);

If the registry lookup fails, we get this type provider:
org.eclipse.xtext.common.types.access.jdt.NullJdtTypeProvider

So, who registers a protocol java? Well, it turns out it's registered by
this this fella: ClasspathTypeProvider

Now, it becomes more apparant, that the Classpathtype provider, is not
used but the NullJdtTypeProvider. This is strange, as the binding for my
generated runtime module tells binding to use the
ClasspathTypeProviderFactory.

// contributed by org.eclipse.xtext.generator.types.TypesGeneratorFragment
public Class<? extends
org.eclipse.xtext.common.types.access.IJvmTypeProvider.Factory>
bindIJvmTypeProvider$Factory() {
return
org.eclipse.xtext.common.types.access.ClasspathTypeProviderFactory.class;
}

So, How come the ClasspathTypeProvider is not used, if the plugin:
"org.eclipse.xtext.common.types" is not on the classpath?

Can someone enlight?

thank You, Christophe Bouhier



On 30-05-11 17:38, Ed Willink wrote:
> Hi Christophe
>
> This has given me a fair amount of trouble too.
>
> It's a URI resolution problem.




>
> The workaround is to import the org.eclipse.xtext.common.types plugin
> into your workspace.
>
> Regards
>
> Ed Willink
>
> On 30/05/2011 16:29, Christophe Bouhier wrote:
>> Hello,
>>
>> I have this grammar which extends the xbase grammar, xbase makes use
>> of JVM types. when I generated the grammar and artifacts, I can't use
>> the java types, as it seems no resource is available containing the
>> types.
>>
>> What do I need to do to make this work?
>>
>>
>> xbase includes this URI
>>
>> import
>> "platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.ecore"
>> as types
>>
>>
>> the configuration includes:
>>
>> // provides the necessary bindings for java types integration
>> fragment = types.TypesGeneratorFragment {}
>>
>>
>>
>> Is this a plugin dependency missing or perhaps a configuration issue?
>> What am I doing wrong?
>>
>> See the stacktrace here.
>>
>>
>> Caused by: java.lang.UnsupportedOperationException
>> at
>> org.eclipse.xtext.common.types.access.jdt.NullJdtTypeProvider.createResource(NullJdtTypeProvider.java:49)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource(ResourceSetImpl.java:425)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandCreateResource(ResourceSetImpl.java:239)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:391)
>>
>> at
>> org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:23)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:216)
>>
>> at
>> org.eclipse.xtext.common.types.util.TypeReferences.findDeclaredType(TypeReferences.java:180)
>>
>> at
>> org.eclipse.xtext.common.types.util.TypeReferences.getTypeForName(TypeReferences.java:143)
>>
>> at
>> org.eclipse.xtext.xbase.typing.XbaseTypeProvider._type(XbaseTypeProvider.java:586)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>
>
Re: JVM types not found exception. [message #675317 is a reply to message #675210] Tue, 31 May 2011 07:12 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Christophe,

you'll have to make sure that a JvmTypeFactory is associated with the
used resource set. This will be transparent for you as long as you use
the IResourceSetProvider to obtain an instance of an XtextResourceSet.
The IResourceSetProvider can be injected by means of dependency injection.

Does that help?
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


Am 30.05.11 17:29, schrieb Christophe Bouhier:
> Hello,
>
> I have this grammar which extends the xbase grammar, xbase makes use of
> JVM types. when I generated the grammar and artifacts, I can't use the
> java types, as it seems no resource is available containing the types.
>
> What do I need to do to make this work?
>
>
> xbase includes this URI
>
> import
> "platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.ecore"
> as types
>
>
> the configuration includes:
>
> // provides the necessary bindings for java types integration
> fragment = types.TypesGeneratorFragment {}
>
>
>
> Is this a plugin dependency missing or perhaps a configuration issue?
> What am I doing wrong?
>
> See the stacktrace here.
>
>
> Caused by: java.lang.UnsupportedOperationException
> at
> org.eclipse.xtext.common.types.access.jdt.NullJdtTypeProvider.createResource(NullJdtTypeProvider.java:49)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource(ResourceSetImpl.java:425)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandCreateResource(ResourceSetImpl.java:239)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:391)
>
> at
> org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:23)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:216)
>
> at
> org.eclipse.xtext.common.types.util.TypeReferences.findDeclaredType(TypeReferences.java:180)
>
> at
> org.eclipse.xtext.common.types.util.TypeReferences.getTypeForName(TypeReferences.java:143)
>
> at
> org.eclipse.xtext.xbase.typing.XbaseTypeProvider._type(XbaseTypeProvider.java:586)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
Re: JVM types not found exception. [message #675364 is a reply to message #675317] Tue, 31 May 2011 09:21 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi Sebastian,

Well, I can't find any reference to an IResourceSetProvider in the
generated RT and UI modules. So does it mean, I need to add it to the
bindings of my generated modules?

I am trying to get going with xbase for some time, but it's a lot of
trial and error. Could you please perhaps highlight what is needed to
get a simple xbase editor going in an RCP app?

What I have done sofar:

1) Generate a default xtext project.
2) Extend the xbase grammar.
grammar com.netxforge.Netxscript with org.eclipse.xtext.xbase.Xbase
3) commented out the referenced xbase and jvm model:
fragment = ecore.EcoreGeneratorFragment {
referencedGenModels =
"platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel,

platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel"
}

So this runs in an RCP, but the JVM types aren't found.
4) Add IResourceSetProvider binding ?
5) ??

Thanks!
p.s. I will otherwise need to contract you guys, but this will eat into
my narrow budget!


On 31-05-11 09:12, Sebastian Zarnekow wrote:
> Hi Christophe,
>
> you'll have to make sure that a JvmTypeFactory is associated with the
> used resource set. This will be transparent for you as long as you use
> the IResourceSetProvider to obtain an instance of an XtextResourceSet.
> The IResourceSetProvider can be injected by means of dependency injection.
>
> Does that help?
> Sebastian
Re: JVM types not found exception. [message #675443 is a reply to message #675364] Tue, 31 May 2011 14:37 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Christophe,

the IResourceSetProvider is bound in the DefaultUIModule. The binding
should be available in your ui bundle.
You need an IJavaProject in order to make JvmTypes resolvable.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 31.05.11 11:21, schrieb Christophe Bouhier:
> Hi Sebastian,
>
> Well, I can't find any reference to an IResourceSetProvider in the
> generated RT and UI modules. So does it mean, I need to add it to the
> bindings of my generated modules?
>
> I am trying to get going with xbase for some time, but it's a lot of
> trial and error. Could you please perhaps highlight what is needed to
> get a simple xbase editor going in an RCP app?
>
> What I have done sofar:
>
> 1) Generate a default xtext project.
> 2) Extend the xbase grammar.
> grammar com.netxforge.Netxscript with org.eclipse.xtext.xbase.Xbase
> 3) commented out the referenced xbase and jvm model:
> fragment = ecore.EcoreGeneratorFragment {
> referencedGenModels =
> "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel,
> platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel"
>
> }
>
> So this runs in an RCP, but the JVM types aren't found.
> 4) Add IResourceSetProvider binding ?
> 5) ??
>
> Thanks!
> p.s. I will otherwise need to contract you guys, but this will eat into
> my narrow budget!
>
>
> On 31-05-11 09:12, Sebastian Zarnekow wrote:
>> Hi Christophe,
>>
>> you'll have to make sure that a JvmTypeFactory is associated with the
>> used resource set. This will be transparent for you as long as you use
>> the IResourceSetProvider to obtain an instance of an XtextResourceSet.
>> The IResourceSetProvider can be injected by means of dependency
>> injection.
>>
>> Does that help?
>> Sebastian
>
Re: JVM types not found exception. [message #675533 is a reply to message #675443] Tue, 31 May 2011 15:24 Go to previous message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi Sebastian,

Ok, spotted the binding, in your previous post you mentioned, it would
be transparant:

"This will be transparent for you as long as you use
the IResourceSetProvider to obtain an instance of an XtextResourceSet.
The IResourceSetProvider can be injected by means of dependency
injection. "

So with this binding, isn't it transparent?

public Class<? extends IResourceSetProvider> bindIResourceSetProvider() {
return XtextResourceSetProvider.class;
}

With IJavaProject, do you mean the jvmtypes will have to be in a java
project has known with JDT? If so, is there a provider at hand, which
can be used to create an IJavaProject from the jvm types? Sorry for the
many questions, If only I had a hint on where to look.

thanks Christophe


On 31-05-11 16:37, Sebastian Zarnekow wrote:
> Hi Christophe,
>
> the IResourceSetProvider is bound in the DefaultUIModule. The binding
> should be available in your ui bundle.
> You need an IJavaProject in order to make JvmTypes resolvable.
>
> Regards,
> Sebastian
Previous Topic:Issue with Xtend2 ListExtensions
Next Topic:[Xtext 2.0] Custom hyperlinks in XtextEditor
Goto Forum:
  


Current Time: Wed Apr 24 23:57:56 GMT 2024

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

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

Back to the top