|
Re: NullPointerException in EMF code [message #507460 is a reply to message #507418] |
Wed, 13 January 2010 15:00 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Robert,
Comments below.
Robert Wloch wrote:
> Hi
>
> I'm about to write unit tests for my EMF code and one of my tests
> failed with a NullPointerException in EMF code. The NPE is
> reproducible with this little sample code:
I think you use do a plugin JUnit test.
>
> public static void main(String[] args) {
> Registry registry = TransactionalEditingDomain.Registry.INSTANCE;
> if (registry == null) {
> System.out.println("no registry available");
> } else {
> System.out.println("registry available");
> TransactionalEditingDomain editingDomain =
> registry.getEditingDomain("my.sharedEditingDomain");
> if (editingDomain == null) {
> System.out.println("no editing domain available");
> } else {
> System.out.println("editing domain available");
> }
> }
> }
>
>
> The output with stacktrace is:
>
> registry available
> Exception in thread "main" java.lang.NullPointerException
> at
> org.eclipse.emf.transaction.internal.EMFTransactionPlugin.ge tPluginId(EMFTransactionPlugin.java:62)
>
> at
> org.eclipse.emf.transaction.impl.EditingDomainManager.getDom ainConfig(EditingDomainManager.java:222)
>
> at
> org.eclipse.emf.transaction.impl.EditingDomainManager.create EditingDomain(EditingDomainManager.java:91)
>
> at
> org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl$RegistryImpl.getEditingDomain(TransactionalEditingDomain Impl.java:1218)
>
> at Test.main(TestBrowserUtil.java:14)
>
>
> Now I know, that the extension point for editing domains can't be read
> by the registry when not running inside of Eclipse. But since the
> registry object is not null its add(id, editingDomain) method suggests
> that I could add a missing editing domain programmatically. However,
> as there's no way to check if an id is already registered the only way
> to find out is by calling getEditingDomain(id). That however, will
> cause the NullPointerException.
>
> Is this something I really should not do at all? Should I file it as a
> bug?
I don't think the transactional framework can generally work without a
workspace and you can't have a workspace running standalone.
>
> Regards
> Rob
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.25061 seconds