Re: Custom Value Generator is not working in 5.2


Hi Andy,

Thanks for the reply.
Following is the plugin.xml that we are using, it has unique=true.
<?xml version="1.0"?>
<plugin id="xyz" name="DataNucleus plug-ins" provider-name="XYZ">
<extension point="org.datanucleus.store_valuegenerator">
<valuegenerator name="XyzValueGenerator" class-name="" unique="true"/>
As I said earlier the same plugin.xml works fine in 5.0

After debugging, the link that you shared in the previous thread is where the bug is
In the Constructor of RDBMSStoreManager the AbstractStoreManger constructor is called
public RDBMSStoreManager(ClassLoaderResolver clr, PersistenceNucleusContext ctx, Map<String, Object> props)
super("rdbms", clr, ctx, props);

The AbstractStoreManger instantiates ValueGenerationManager before the nucleusContext is set in the constructor
protected ValueGenerationManager valueGenerationMgr = new ValueGenerationManagerImpl(this);

protected AbstractStoreManager(String key, ClassLoaderResolver clr, PersistenceNucleusContext nucleusContext, Map<String, Object> props) { this.storeManagerKey = key; this.nucleusContext = nucleusContext;

So in the constructor of ValueGenerationManagerImpl while loading the plugin there is always a NullPointerException (storeMgr.getNucleusContext() == null). Due to this the custom value generator is never added to uniqueGeneratorsByName map.
ConfigurationElement[] elems = storeMgr.getNucleusContext().getPluginManager().getConfigurationElementsForExtension("org.datanucleus.store_valuegenerator",
"unique", "true");
if (elems != null)
for (ConfigurationElement elem : elems)
// Assumed to not take any properties
generator = (ValueGenerator)storeMgr.getNucleusContext().getPluginManager().createExecutableExtension("org.datanucleus.store_valuegenerator",
new String[] {"name", "unique"}, new String[] {elem.getName(), "true"},
"class-name", new Class[] {StoreManager.class, String.class}, new Object[] {this, elem.getName()});
uniqueGeneratorsByName.put(elem.getName(), generator);
catch (Exception e)

Join to automatically receive all group messages.