Hi there,
I'm trying to serialize a settings class with xml serializer and get the following error: java.lang.reflect.InvocationTargetException
Here is my settings implementation:
@State( name = "Typo3StormSettings", // must be equal to the class name I think storages = { // @Storage(id = "default", file = StoragePathMacros.PROJECT_FILE), // @Storage(id = "default", file = "/tmp/test/"), // @Storage(id = "dir", file = StoragePathMacros.PROJECT_CONFIG_DIR + "/typo3storm.xml", scheme = StorageScheme.DIRECTORY_BASED) @Storage(id = "dir", file = "/tmp/test/typo3storm.xml", scheme = StorageScheme.DIRECTORY_BASED) }
)publicclass Typo3StormSettings implements PersistentStateComponent<Typo3StormSettings> { // Those fields should be serialized publicboolean enabled = true; public String pathToTypo3; @Transient // Do not serialize this field! protected Project project; publicstatic Typo3StormSettings getInstance(Project project) { Typo3StormSettings settings = ServiceManager.getService(project, Typo3StormSettings.class); if(settings == null){ IdeHelper.logError("Cannot find Typo3Storm Settings"); } settings.project = project; return settings; } @Override public Typo3StormSettings getState() { returnthis; } @Override publicvoid loadState(Typo3StormSettings typo3StormSettings) { try{ XmlSerializerUtil.copyBean(typo3StormSettings, this); } catch(Exception e){ // IdeHelper.logError(e.getMessage()); // IdeHelper.showDialog(null,"Cannot read the saved settings for Magicento. Please try saving them again from File > Settings > Magicento", "Error in Magicento Settings"); } // autoSetPathToMage(); } publicboolean isEnabled() { return enabled; } public String getPathToTypo3() { return getPathToTypo3(); } publicvoid setPathToTypo3(String pathToTypo3) { this.pathToTypo3 = pathToTypo3; } }
And here is a simple testcase, I set up to reproduce the error:
publicclass Typo3StormSettingsTests { @Test publicvoid settingsCanBeSerialized() { Typo3StormSettings settings = new Typo3StormSettings(); settings.setPathToTypo3("/tmp"); XmlSerializer.serialize(settings); } }
I'm getting the same error, if I run the plugin from within PHPStorm Application, if I uncomment the annotations and use the following @State annotation:
*/
@State( name = "Typo3StormSettings", // must be equal to the class name I think storages = { @Storage(id = "default", file = StoragePathMacros.PROJECT_FILE), @Storage(id = "dir", file = StoragePathMacros.PROJECT_CONFIG_DIR + "/typo3storm.xml", scheme = StorageScheme.DIRECTORY_BASED) }
)
It would be really great if you could help me out on that issue!
Best regards,
Mimi