PersistentStateComponent with Application level cause Error.

PersistentStateComponent with Application level cause Unable to save settings Error.

 

Before that, I succeeded to use  Project level PersistentStateComponent already.

I just changed `plugin.xml` from

<projectService serviceImplementation="models.PersistentUser" />

to

<applicationService serviceImplementation="models.PersistentUser" />

And when I call

`ServiceManager.getService(PersistentUser.class)`, the error occured.

 

What else I should change codes if I want use Application Level PersistentStateComponent?

 

Error Log

2018/12/08
23:53 Unable to save settings
Failed to save settings. Please restart IntelliJ IDEA
java.lang.RuntimeException: java.lang.Exception: Cannot get PersistentUser component state
at com.intellij.util.ExceptionUtil.rethrow(ExceptionUtil.java:160)
at com.intellij.util.lang.CompoundRuntimeException.throwIfNotEmpty(CompoundRuntimeException.java:153)
at com.intellij.configurationStore.ComponentStoreImpl.save(ComponentStoreImpl.kt:149)
at com.intellij.openapi.components.impl.stores.StoreUtil.save(StoreUtil.java:40)
at com.intellij.openapi.application.impl.ApplicationImpl.saveSettings(ApplicationImpl.java:1432)
at com.intellij.openapi.components.impl.stores.StoreUtil.saveProjectsAndApp(StoreUtil.java:120)
at com.intellij.openapi.components.impl.stores.StoreUtil.saveDocumentsAndProjectsAndApp(StoreUtil.java:113)
at com.intellij.openapi.application.impl.ApplicationImpl.saveAll(ApplicationImpl.java:1441)
at com.intellij.ide.SaveAndSyncHandlerImpl.saveProjectsAndDocuments(SaveAndSyncHandlerImpl.java:126)
at com.in... (show balloon)

4 comments
Comment actions Permalink

 

@State(
name = "PersistentUser"
)
public class PersistentUser implements PersistentStateComponent<PersistentUser> {

...

@Nullable
@Override
public ServiceUser getState() {
return this;
}

@Override
public void loadState(@NotNull ServiceUser state) {
XmlSerializerUtil.copyBean(state, this);
}
}

 

This is my code.

 

<idea-plugin>
...
<extensions defaultExtensionNs="com.intellij">
<applicationService serviceImplementation="models.PersistentUser" />
...
</extensions>

 

This is my plugin.xml.

 

And the code below has error.

 

ServiceManager.getService(PersistentUser.class);

 

0
Comment actions Permalink

Could you please post the full exception stack trace from idea.log file?

0
Comment actions Permalink

I cannot find any log file in my project.

How can I get idea.log file?

 

0
Comment actions Permalink

Use Help | Show Log action to navigate to the log file.

0

Please sign in to leave a comment.