commit 6f5e1f0c901ba3b2c0de15e842cd10508e6d78cb
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Thu Jul 27 10:50:32 2017 +0200

    ref #6852 using the DummyDataInserter to avoid NPEs in the Spring ApplicationListener intitialization

diff --git a/src/main/java/eu/etaxonomy/cdm/addon/config/CdmVaadinConfiguration.java b/src/main/java/eu/etaxonomy/cdm/addon/config/CdmVaadinConfiguration.java
index f646d2f6..7c6f641a 100644
--- a/src/main/java/eu/etaxonomy/cdm/addon/config/CdmVaadinConfiguration.java
+++ b/src/main/java/eu/etaxonomy/cdm/addon/config/CdmVaadinConfiguration.java
@@ -36,7 +36,9 @@ import com.vaadin.spring.annotation.UIScope;
 import com.vaadin.spring.server.SpringVaadinServlet;
 import com.vaadin.ui.UI;
 
+import eu.etaxonomy.cdm.api.application.AbstractDataInserter;
 import eu.etaxonomy.cdm.api.application.CdmRepository;
+import eu.etaxonomy.cdm.api.application.DummyDataInserter;
 import eu.etaxonomy.cdm.common.ConfigFileUtil;
 import eu.etaxonomy.cdm.dataInserter.RegistrationRequiredDataInserter;
 import eu.etaxonomy.cdm.opt.config.DataSourceConfigurer;
@@ -159,14 +161,17 @@ public class CdmVaadinConfiguration implements ApplicationContextAware  {
     }
 
     @Bean
-    public RegistrationRequiredDataInserter registrationRequiredDataInserter() throws BeansException{
-        RegistrationRequiredDataInserter inserter = null;
+    public AbstractDataInserter registrationRequiredDataInserter() throws BeansException{
         if(isUIEnabled(RegistrationUI.class)){
-            inserter = new RegistrationRequiredDataInserter();
+            RegistrationRequiredDataInserter inserter = new RegistrationRequiredDataInserter();
             inserter.setRunAsAuthenticationProvider((AuthenticationProvider) applicationContext.getBean("runAsAuthenticationProvider"));
             inserter.setCdmRepository((CdmRepository) applicationContext.getBean("cdmRepository"));
+            return inserter;
+        } else {
+            // the return type implements ApplicationListener and thus must not be null,
+            // therefore we return a empty dummy implementation.
+            return new DummyDataInserter();
         }
-        return inserter;
     }
 
     @Bean
diff --git a/src/main/java/eu/etaxonomy/cdm/dataInserter/RegistrationRequiredDataInserter.java b/src/main/java/eu/etaxonomy/cdm/dataInserter/RegistrationRequiredDataInserter.java
index b37d5d8b..9b712260 100644
--- a/src/main/java/eu/etaxonomy/cdm/dataInserter/RegistrationRequiredDataInserter.java
+++ b/src/main/java/eu/etaxonomy/cdm/dataInserter/RegistrationRequiredDataInserter.java
@@ -21,7 +21,6 @@ import java.util.UUID;
 import org.apache.log4j.Logger;
 import org.joda.time.DateTime;
 import org.joda.time.format.DateTimeFormatter;
-import org.springframework.context.ApplicationListener;
 import org.springframework.context.event.ContextRefreshedEvent;
 import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
 import org.springframework.security.core.GrantedAuthority;
@@ -31,8 +30,8 @@ import com.fasterxml.jackson.core.JsonParseException;
 import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
+import eu.etaxonomy.cdm.api.application.AbstractDataInserter;
 import eu.etaxonomy.cdm.api.application.CdmRepository;
-import eu.etaxonomy.cdm.api.application.RunAsAuthenticator;
 import eu.etaxonomy.cdm.api.service.pager.Pager;
 import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.cdm.model.agent.Institution;
@@ -53,7 +52,7 @@ import eu.etaxonomy.cdm.vaadin.security.RolesAndPermissions;
  * @since May 9, 2017
  *
  */
-public class RegistrationRequiredDataInserter extends RunAsAuthenticator implements ApplicationListener<ContextRefreshedEvent>{
+public class RegistrationRequiredDataInserter extends AbstractDataInserter {
 
     protected static final String PARAM_NAME_CREATE = "registrationCreate";
 
diff --git a/src/main/java/org/springframework/context/event/README b/src/main/java/org/springframework/context/event/README
index 395e45a9..22892f22 100644
--- a/src/main/java/org/springframework/context/event/README
+++ b/src/main/java/org/springframework/context/event/README
@@ -1,4 +1,4 @@
-This package contains the PojoEventListenerManager which manages the event lsiterner methodfs in mvp popup presenter instances. 
+This package contains the PojoEventListenerManager which manages the event listerner methods in mvp popup presenter instances. 
 Presenter instances are created in turn of the calls to NavigationManagerBean.findPopupView()
 The PojoEventListenerManager creates ApplicationListener instances for each method annotated with @EventListner 
 and adds them to the EventMulticaster.
