Home » Support » Forum » NullPointerException while setting a new property value

NullPointerException while setting a new property value


we are using ObjectDB version 2.4.4 and we are unable to resolve following NPE on enhanced entity:

at com.objectdb.o.ENT.beforeModifyMember(ENT.java:1099)
at model.PluginMetaData.__odbSet_maxAllowedDownloads(PluginMetaData.java:1)
at model.PluginMetaData.setMaxAllowedDownloads(PluginMetaData.java:268)
at model.PluginMetaData.setPluginDescriptor(PluginMetaData.java:94)

PluginMetaData looks like this (nothing extraordinary, no relationship to other @entities):

final public class PluginMetaData {

    private Long dbId;

    //persisted info
    private String id;
    private boolean updatesEnabled;
    private boolean enabled;
    private int pluginPriority;
    private int maxAllowedDownloads;
    private boolean clipboardMonitored;
    private boolean removeCompleted;

    //some other @Transient properties
    // 2 constructors

Can somebody help me?

Thank you.


Please check your ObjectDB log file (mainly on the client side, but server side as well) for more details. It should include a more complete stack trace.

The exception may indicate incomplete enhancement (i.e. rebuilding the project and enhancing all the classes may solve the problem), or changing schema without restarting the server - but more details are required.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

I forgot to mention we are using ObjectDB in embedded mode.

Enhancing was made successfully without any error.

Here is the log file in DEBUG mode, but there is nothing special or detailed error description.


(attaching files seems to be broken too...)

java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) Client VM (build 23.5-b02, mixed mode, sharing)


I am trying to attach the log file.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Please try a new build - 2.4.4_02.

It will not solved the problem yet, but hopefully will generate a better stack trace.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Offtopic - upload file error screenshot (FF 16.0.1)



This was changed:

at com.objectdb.o.ENT.aa(ENT.java:1162)
at com.objectdb.o.ENT.beforeModifyMember(ENT.java:1096)
at cz.vity.freerapid.model.PluginMetaData.__odbSet_removeCompleted(PluginMetaData.java:1)

OK. Please try now 2.4.4_03.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

The ObjectDB code was changed, but NPE still persists.

Tue Oct 23 22:57:34 CEST 2012 SEVERE:
at com.objectdb.o.ENT.aa(ENT.java:1164)
at com.objectdb.o.ENT.beforeModifyMember(ENT.java:1096)
at cz.vity.freerapid.model.PluginMetaData.__odbSet_removeCompleted(PluginMetaData.java:1)
at cz.vity.freerapid.model.PluginMetaData.setRemoveCompleted(PluginMetaData.java:118)

This is a strange issue. Please try build 2.4.4_04. Thank you for your patient.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

No problem. We will try it tomorrow. Time to sleep for now :-).

Thank you for your support.


We are back, here it is - 2.4.4_04

Just a note - it fails on another property in the Entity.

Wed Oct 24 17:30:44 CEST 2012 SEVERE:
at com.objectdb.o.ENT.aa(ENT.java:1165)
at com.objectdb.o.ENT.beforeModifyMember(ENT.java:1097)
at cz.vity.freerapid.model.PluginMetaData.__odbSet_maxAllowedDownloads(PluginMetaData.java:1)
at cz.vity.freerapid.model.PluginMetaData.setMaxAllowedDownloads(PluginMetaData.java:265)
at cz.vity.freerapid.model.PluginMetaData.setPluginDescriptor(PluginMetaData.java:94)

If you can demonstrate the problem with a test case it would help, because somehow your application brings ObjectDB to an unexpected state, and it is unclear how.

Build 2.4.4_05 is another attempt to solve problem (but still without understanding the exact cause).

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Thanks, we will check that and I will let you know ASAP.

I guess it's a thread issue, it's not easy to reproduce it in the small scale for a test case.

We got also another report from one of our tester today - we were also encountering NPE on another place (not sure on which ObjectDB version).

In my theory, this is a (possible) cause and what we are doing - concurrent access to entities from 2 threads:

1. Creating a list of entities, default values are set from imported file

2. "Sending" this list on the special thread (ThreadPoolExecution, 1 thread, LinkedBlockingQueue) to make database access for write.

Nothing special here I guess:

public synchronized void saveCollection(Collection<? extends Identifiable> entityCollection) {
        final EntityManager em = getEntityManager();
        try {

            for (Identifiable o : entityCollection) {
                if (o.getIdentificator() == null) {
                } else {
        } finally {
            if (em.getTransaction().isActive())

3. The code continues with a revalidation and re-setting some properties to entities from the collection. NPE is thrown at some point while database thread is writing new data. I guess that the enhanced code should handle it somehow.



When using JPA with multi threads each thread should have its own EntityManager and entities.

According to the JPA specification: "An entity manager must not be shared among multiple concurrently executing threads, as the entity manager and persistence context are not required to be threadsafe. Entity managers must only be accessed in a single-threaded manner."

Actually there is an attempt to provide thread safe EntityManager and persistence context in ObjectDB, but since this is not the usual way of working with JPA, you may have some difficulties like this NullPointerException (that hopefully could be solved).

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

A friend of mine successfully tested 2.4.4_05 and the NPE is gone. We plan more testing.

We create new EntityManager for every operation on database , so it should be thread safe.

public EntityManager getEntityManager() {
        return factory.createEntityManager();

We just share the entities among threads, but database operation is always made in its own single thread only.

Thanks for the patch anyway.




That is good, but be aware that entities (which are part of a persistence context) are also not expected to be shared by threads, except maybe after detachment.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login