Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » NullPointerException in EMF code
NullPointerException in EMF code [message #507418] Wed, 13 January 2010 12:35 Go to next message
Robert Wloch is currently offline Robert WlochFriend
Messages: 109
Registered: July 2009
Senior Member
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:
    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.getPluginId(EMFTransactionPlugin.java:62)
    at org.eclipse.emf.transaction.impl.EditingDomainManager.getDomainConfig(EditingDomainManager.java:222)
    at org.eclipse.emf.transaction.impl.EditingDomainManager.createEditingDomain(EditingDomainManager.java:91)
    at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl$RegistryImpl.getEditingDomain(TransactionalEditingDomainImpl.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?

Regards
Rob
Re: NullPointerException in EMF code [message #507460 is a reply to message #507418] Wed, 13 January 2010 15:00 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30620
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
Previous Topic:EMF <-> Source XML Synchronization
Next Topic:childen of a resource
Goto Forum:
  


Current Time: Mon Nov 11 19:40:30 GMT 2019

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

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

Back to the top