PersistentStateComponent throws NPE (unable to find the solution)

Hello, I am the first time writer here. And if current topic should be in the another section - please move it.

I am getting exception

[  15939]  ERROR - .components.ComponentStoreImpl - null
     at com.intellij.openapi.components.impl.stores.ComponentStoreImpl.getComponentStorageSpecs(
     at com.intellij.openapi.components.impl.stores.ComponentStoreImpl.initPersistentComponent(
     at com.intellij.openapi.components.impl.stores.ComponentStoreImpl.access$000(
     at com.intellij.openapi.components.impl.stores.ComponentStoreImpl$
     at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(
     at com.intellij.openapi.components.impl.stores.ComponentStoreImpl.initComponent(
     at com.intellij.openapi.application.impl.ApplicationImpl.initializeComponent(
     at com.intellij.openapi.components.impl.ServiceManagerImpl$MyComponentAdapter.initializeInstance(
     at com.intellij.openapi.components.impl.ServiceManagerImpl$MyComponentAdapter$1.compute(
     at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(
     at com.intellij.openapi.components.impl.ServiceManagerImpl$MyComponentAdapter.getComponentInstance(
     at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(
     at com.intellij.util.pico.DefaultPicoContainer.getInstance(
     at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(
     at org.picocontainer.alternatives.AbstractDelegatingMutablePicoContainer.getComponentInstance(
     at com.intellij.openapi.components.ServiceManager.getService(

My persistent component:

@State(name = "CodeReviewRemarks",
        storages = {
                @Storage(id = "default", file = StoragePathMacros.PROJECT_FILE),
                @Storage(id = "dir", file = StoragePathMacros.PROJECT_CONFIG_DIR + "/code-review-remarks.xml", scheme = StorageScheme.DIRECTORY_BASED)
public class StorageComponent implements PersistentStateComponent {
    public StorageComponent getState() {
        return this;

    public void loadState(Object state) {
        XmlSerializerUtil.copyBean(state, this);

And how it is registered in plugin.xml:

<extensions defaultExtensionNs="com.intellij">
        <applicationService id="CodeReview.StorageService"

When i try to get this component like
StorageComponent compl = ServiceManager.getService(StorageComponent.class);

I've got the exception described at the beginning of this topic.

I was searching for the answers, but unable to get why i have this error.


Comment actions Permalink

You're registering an application service and requesting that its state needs to be stored in the project. This won't work. To store state in the project, you need to create a project service.

Comment actions Permalink

Thanks, could you give an example how to make correct call?

I want to use persistent component on application level.

And where is the actual documentation about persistence?
I have searched on the forum, but most answers from 2006 and not actual anymore.


Comment actions Permalink

Are you sure that you can't use a project service? I would expect that code review activity is always associated with a specific project.

The plugin development documentation is here:
Specifically, the PersistentStateComponent interface is documented here:


Please sign in to leave a comment.