Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext runtime tries to access internet at application startup(Xtext runtime tries to access internet at application startup)
Xtext runtime tries to access internet at application startup [message #1064227] Tue, 18 June 2013 10:37 Go to next message
FJ  Stöver is currently offline FJ StöverFriend
Messages: 25
Registered: July 2011
Location: Aachen, Germany
Junior Member
Dear colleagues,

in our Xtext grammar we 'import "http://www.eclipse.org/emf/2002/Ecore" as ecore'.

Now we detected that - at startup - the Xtext runtime tries to access exactly that address. The platform for our application however has no internet access.

Is there a way to disable internet access of the Xtext runtime?

kind regards

Franz-Josef
Re: Xtext runtime tries to access internet at application startup [message #1064303 is a reply to message #1064227] Tue, 18 June 2013 15:01 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
That should not be the case, when the EcorePackage is correctly
registered. Could you file a bug with a stacktrace and maybe a
reproducible example?

Am 18.06.13 12:37, schrieb FJ Stöver:
> Dear colleagues,
>
> in our Xtext grammar we 'import "http://www.eclipse.org/emf/2002/Ecore"
> as ecore'.
>
> Now we detected that - at startup - the Xtext runtime tries to access
> exactly that address. The platform for our application however has no
> internet access.
>
> Is there a way to disable internet access of the Xtext runtime?
>
> kind regards
>
> Franz-Josef
>


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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Xtext runtime tries to access internet at application startup [message #1064431 is a reply to message #1064303] Wed, 19 June 2013 08:52 Go to previous messageGo to next message
FJ  Stöver is currently offline FJ StöverFriend
Messages: 25
Registered: July 2011
Location: Aachen, Germany
Junior Member
Good morning Jan,

Thank you for your prompt reply.

> That should not be the case, when the EcorePackage is correctly
registered.

For registration we use the generated code in BaseStandaloneSetupGenerated.java:
 ...
 if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
 Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
 "ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
 ...


That seemed to be ok, and we tried to replace in the grammar
import "http://www.eclipse.org/emf/2002/Ecore" as ecore

by
import "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore"

which gave the warning "Fix the bogus package import; import 'http://www.eclipse.org/emf/2002/Ecore'".

When compiling the grammar however it gave the error "Couldn't resolve reference to EPackage 'platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore' ..."

Any idea how to go the 'import from platform' approach ?

Whatever: If the 'import from platform' approach is not successful, or the problem persists, then the next well probably be to produce a repro.

kind regards Franz-Josef
Re: Xtext runtime tries to access internet at application startup [message #1064435 is a reply to message #1064431] Wed, 19 June 2013 09:08 Go to previous messageGo to next message
FJ  Stöver is currently offline FJ StöverFriend
Messages: 25
Registered: July 2011
Location: Aachen, Germany
Junior Member
Please note that we are running our Xtext applications not from an OSGI container, but rather standalone or hosted by jBoss.

Franz-Josef
Re: Xtext runtime tries to access internet at application startup [message #1064503 is a reply to message #1064431] Wed, 19 June 2013 14:16 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
That's the registration of the ResourceFactory, but I mean the
registration of the EcorePackage. It should happen automatically as soon
as you access the EcorePackage.eINSTANCE, but you can of course do it
explicitly:

org.eclipse.emf.ecore.impl.EcorePackageImpl.init()

Am 19.06.13 10:52, schrieb FJ Stöver:
> Good morning Jan,
>
> Thank you for your prompt reply.
>
>> That should not be the case, when the EcorePackage is correctly
> registered.
>
> For registration we use the generated code in
> BaseStandaloneSetupGenerated.java:
>
> ...
> if
> (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
> "ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
> ...
>
>
> That seemed to be ok, and we tried to replace in the grammar
>
> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>
> by
>
> import "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore"
>
> which gave the warning "Fix the bogus package import; import
> 'http://www.eclipse.org/emf/2002/Ecore'".
>
> When compiling the grammar however it gave the error "Couldn't resolve
> reference to EPackage
> 'platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore' ..."
>
> Any idea how to go the 'import from platform' approach ?
>
> Whatever: If the 'import from platform' approach is not successful, or
> the problem persists, then the next well probably be to produce a repro.
>
> kind regards Franz-Josef
>


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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Xtext runtime tries to access internet at application startup [message #1064504 is a reply to message #1064435] Wed, 19 June 2013 14:26 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The http: import should give no trouble provided you register the Ecore
package, which happens automatically if you just touch the EcorePackage
class by accessing EcorePackage.eINSTANCE.

For your own models you may need to use platform:/resource which Xtext
no longer likes but at least continues to tolerate. For instance one of
my grammars has:

import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import
"platform:/resource/org.eclipse.ocl.examples.xtext.base/model/BaseCST.ecore"
as base
import
"platform:/resource/org.eclipse.ocl.examples.xtext.essentialocl/model/EssentialOCLCST.ecore"
as essentialocl
import
"platform:/resource/org.eclipse.ocl.examples.pivot/model/Pivot.ecore" as
pivot
import
"platform:/resource/org.eclipse.qvtd.pivot.qvtbase/model/QVTbase.ecore"
as qvtbase
import
"platform:/resource/org.eclipse.qvtd.pivot.qvtcorebase/model/QVTcoreBase.ecore"
as qvtcorebase
import
"platform:/resource/org.eclipse.qvtd.pivot.qvtcore/model/QVTcore.ecore"
as qvtcore
import
"platform:/resource/org.eclipse.qvtd.xtext.qvtcore/model/QVTcoreCST.ecore"

Regards

Ed Willink




On 19/06/2013 11:08, FJ Stöver wrote:
> Please note that we are running our Xtext applications not from an
> OSGI container, but rather standalone or hosted by jBoss.
>
> Franz-Josef
>
Re: Xtext runtime tries to access internet at application startup [message #1064584 is a reply to message #1064503] Thu, 20 June 2013 06:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Jan,

A better idiom for forcing package initialization is
XyzPackage.eINSTANCE.eClass(); it's better to write code that assumes
the generated Impls are private.

On 19/06/2013 4:16 PM, Jan Koehnlein wrote:
> That's the registration of the ResourceFactory, but I mean the
> registration of the EcorePackage. It should happen automatically as
> soon as you access the EcorePackage.eINSTANCE, but you can of course
> do it explicitly:
>
> org.eclipse.emf.ecore.impl.EcorePackageImpl.init()
>
> Am 19.06.13 10:52, schrieb FJ Stöver:
>> Good morning Jan,
>>
>> Thank you for your prompt reply.
>>
>>> That should not be the case, when the EcorePackage is correctly
>> registered.
>>
>> For registration we use the generated code in
>> BaseStandaloneSetupGenerated.java:
>>
>> ...
>> if
>> (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
>>
>>
>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
>> "ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
>> ...
>>
>>
>> That seemed to be ok, and we tried to replace in the grammar
>>
>> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>>
>> by
>>
>> import "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore"
>>
>> which gave the warning "Fix the bogus package import; import
>> 'http://www.eclipse.org/emf/2002/Ecore'".
>>
>> When compiling the grammar however it gave the error "Couldn't resolve
>> reference to EPackage
>> 'platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore' ..."
>>
>> Any idea how to go the 'import from platform' approach ?
>>
>> Whatever: If the 'import from platform' approach is not successful, or
>> the problem persists, then the next well probably be to produce a repro.
>>
>> kind regards Franz-Josef
>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Xtext runtime tries to access internet at application startup [message #1064619 is a reply to message #1064584] Thu, 20 June 2013 09:14 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
In terms of readability, my solution feels a bit more explicit. Yours
would definitively need a comment that you are just doing it for a
magical side-effect in order not to be removed in the next refactoring.
I'd prefer an even more explicit statement (involving the
EPackage.Registry), but then we are likely introducing some obsolete
action.

Am 20.06.13 08:30, schrieb Ed Merks:
> Jan,
>
> A better idiom for forcing package initialization is
> XyzPackage.eINSTANCE.eClass(); it's better to write code that assumes
> the generated Impls are private.
>
> On 19/06/2013 4:16 PM, Jan Koehnlein wrote:
>> That's the registration of the ResourceFactory, but I mean the
>> registration of the EcorePackage. It should happen automatically as
>> soon as you access the EcorePackage.eINSTANCE, but you can of course
>> do it explicitly:
>>
>> org.eclipse.emf.ecore.impl.EcorePackageImpl.init()
>>
>> Am 19.06.13 10:52, schrieb FJ Stöver:
>>> Good morning Jan,
>>>
>>> Thank you for your prompt reply.
>>>
>>>> That should not be the case, when the EcorePackage is correctly
>>> registered.
>>>
>>> For registration we use the generated code in
>>> BaseStandaloneSetupGenerated.java:
>>>
>>> ...
>>> if
>>> (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
>>>
>>>
>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
>>> "ecore", new org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
>>> ...
>>>
>>>
>>> That seemed to be ok, and we tried to replace in the grammar
>>>
>>> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>>>
>>> by
>>>
>>> import "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore"
>>>
>>> which gave the warning "Fix the bogus package import; import
>>> 'http://www.eclipse.org/emf/2002/Ecore'".
>>>
>>> When compiling the grammar however it gave the error "Couldn't resolve
>>> reference to EPackage
>>> 'platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore' ..."
>>>
>>> Any idea how to go the 'import from platform' approach ?
>>>
>>> Whatever: If the 'import from platform' approach is not successful, or
>>> the problem persists, then the next well probably be to produce a repro.
>>>
>>> kind regards Franz-Josef
>>>
>>
>>
>


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


---
Get professional support from the Xtext committers at www.typefox.io
Re: Xtext runtime tries to access internet at application startup [message #1064632 is a reply to message #1064619] Thu, 20 June 2013 10:43 Go to previous messageGo to next message
FJ  Stöver is currently offline FJ StöverFriend
Messages: 25
Registered: July 2011
Location: Aachen, Germany
Junior Member
Dear colleagues !

Thank you for the valuable comments; I'll do my best to integrate it into our software.

Meanwhile we have found out more:

* If we have one Xtext parser instance everything works fine, and we observe no internet traffic. So I assume that package registration seems to be ok - though I'll look into your suggestions to improve the software.

* If we have two Xtext parser instances then we observe Internet traffic ! Seems like they influence each other. We looked for static fields in our source, and in the Xtext generated sources, but didn't find anything.

Any ideas ?

kind regards

Franz-Josef
Re: Xtext runtime tries to access internet at application startup [message #1064633 is a reply to message #1064619] Thu, 20 June 2013 10:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Jan,

EPackage.Registry.INSTANCE.getEPackage(XyzPackage.eNS_URI) works too.
Accessing model implementation classes shouldn't be encouraged...


On 20/06/2013 11:14 AM, Jan Koehnlein wrote:
> In terms of readability, my solution feels a bit more explicit. Yours
> would definitively need a comment that you are just doing it for a
> magical side-effect in order not to be removed in the next
> refactoring. I'd prefer an even more explicit statement (involving the
> EPackage.Registry), but then we are likely introducing some obsolete
> action.
>
> Am 20.06.13 08:30, schrieb Ed Merks:
>> Jan,
>>
>> A better idiom for forcing package initialization is
>> XyzPackage.eINSTANCE.eClass(); it's better to write code that assumes
>> the generated Impls are private.
>>
>> On 19/06/2013 4:16 PM, Jan Koehnlein wrote:
>>> That's the registration of the ResourceFactory, but I mean the
>>> registration of the EcorePackage. It should happen automatically as
>>> soon as you access the EcorePackage.eINSTANCE, but you can of course
>>> do it explicitly:
>>>
>>> org.eclipse.emf.ecore.impl.EcorePackageImpl.init()
>>>
>>> Am 19.06.13 10:52, schrieb FJ Stöver:
>>>> Good morning Jan,
>>>>
>>>> Thank you for your prompt reply.
>>>>
>>>>> That should not be the case, when the EcorePackage is correctly
>>>> registered.
>>>>
>>>> For registration we use the generated code in
>>>> BaseStandaloneSetupGenerated.java:
>>>>
>>>> ...
>>>> if
>>>> (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
>>>>
>>>>
>>>>
>>>> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
>>>> "ecore", new
>>>> org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl());
>>>> ...
>>>>
>>>>
>>>> That seemed to be ok, and we tried to replace in the grammar
>>>>
>>>> import "http://www.eclipse.org/emf/2002/Ecore" as ecore
>>>>
>>>> by
>>>>
>>>> import "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore"
>>>>
>>>> which gave the warning "Fix the bogus package import; import
>>>> 'http://www.eclipse.org/emf/2002/Ecore'".
>>>>
>>>> When compiling the grammar however it gave the error "Couldn't resolve
>>>> reference to EPackage
>>>> 'platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore' ..."
>>>>
>>>> Any idea how to go the 'import from platform' approach ?
>>>>
>>>> Whatever: If the 'import from platform' approach is not successful, or
>>>> the problem persists, then the next well probably be to produce a
>>>> repro.
>>>>
>>>> kind regards Franz-Josef
>>>>
>>>
>>>
>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Xtext runtime tries to access internet at application startup [message #1064635 is a reply to message #1064632] Thu, 20 June 2013 10:56 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Maybe a breakpoint in
org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createInputStream(URI, Map<?,
?>) would help track it down.


On 20/06/2013 12:43 PM, FJ Stöver wrote:
> Dear colleagues !
>
> Thank you for the valuable comments; I'll do my best to integrate it
> into our software.
>
> Meanwhile we have found out more:
>
> * If we have one Xtext parser instance everything works fine, and we
> observe no internet traffic. So I assume that package registration
> seems to be ok - though I'll look into your suggestions to improve the
> software.
>
> * If we have two Xtext parser instances then we observe Internet
> traffic ! Seems like they influence each other. We looked for static
> fields in our source, and in the Xtext generated sources, but didn't
> find anything.
>
> Any ideas ?
>
> kind regards
>
> Franz-Josef
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Accessing global constant data
Next Topic:After linking|Scoping but before Generator and second language
Goto Forum:
  


Current Time: Thu Mar 28 09:40:55 GMT 2024

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

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

Back to the top