isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Gurr <>
Subject NullPointerException when trying to persist a domain entity
Date Tue, 10 Sep 2013 18:08:02 GMT
I'm getting this when trying to run a test I'm making:

at org.apache.isis.applib.AbstractContainedObject.persist(

These line numbers are from a fresh pull performed this morning, so it's likely they will
still be correct if you are looking at the head of the master branch.

I'm sure I've misconfigured something, but I'm trying to understand what's happening here
so I can fix it. It would also be nice if nulls were checked for in this part of code and
a more useful error message thrown. Here is the code throwing the exception:

    public void persist(final Object transientObject) {
        final ObjectAdapter adapter = getAdapterManager().getAdapterFor(transientObject);
        // TODO check aggregation is supported
        if (adapter.isParented()) {

In this case, the adapter is null, and so the isParented method is called on a null object,
throwing the exception.

The transientObject being passed in here is an instance of my model class named ServiceClass.
The service class which contains methods to create new instances and perform various searches
is called ServiceClassService (analogous to TodoItems). I stepped through this code and can
see the map it is looking in for the getAdapterFor method contains the services I registered,
and so it could look up ServiceClassService, but not ServiceClass. But I'm trying to persist
a data entity (ServiceClass), so I'm not sure what's supposed to be happening here.

I have a class which extends AbstractFactoryAndRepository which of course has a persist method.
I call that method to persist a newly created transient entity, but this exception is thrown.
Persist seems to be the method I'm looking for, but why does it look to the service list to
find which adapter to use to persist the entity? And how do I either get the correct service
registered, or change the ServiceClassService so that it recognizes the ServiceClass entity
as something it can work with? Sorry this probably doesn't make much sense, because I don't
quite understand what the persistence code is trying to do here. Any help would be greatly
appreciated :)

-- Jeremy

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message