diff --git a/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java b/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java
index 3b697c48398127f1904c40c69d6b3547492b9d04..69d8e9c9da8582cc552b81a12483229bef744320 100644
--- a/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java
+++ b/service/src/main/java/lcsb/mapviewer/services/impl/LayoutService.java
@@ -10,7 +10,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.annotation.PostConstruct;
 import javax.mail.MessagingException;
 
 import org.apache.commons.io.IOUtils;
@@ -121,14 +120,6 @@ public class LayoutService implements ILayoutService {
    */
   private EmailSender emailSender;
 
-  /**
-   * Method called after spring initialized all interfaces.
-   */
-  @PostConstruct
-  public void springInit() {
-    emailSender = new EmailSender(configurationService);
-  }
-
   @Override
   public boolean userCanAddLayout(Model model, User user) {
     // if we don't have privileges to view the object then we cannot add layouts
@@ -396,7 +387,7 @@ public class LayoutService implements ILayoutService {
           layoutDao.update(layout);
 
           try {
-            emailSender.sendEmail("MapViewer status", "There was a problem with generating layout " + params.getName()
+            getEmailSender().sendEmail("MapViewer status", "There was a problem with generating layout " + params.getName()
                 + ". Contact administrator to solve this issue.", params.getUser());
           } catch (MessagingException e1) {
             logger.error("Problem with sending email", e1);
@@ -566,7 +557,7 @@ public class LayoutService implements ILayoutService {
       throws MessagingException {
     StringBuilder content = new StringBuilder(
         "Layout " + layoutName + " in map " + projectId + " was successfully removed.<br/>");
-    emailSender.sendEmail("MapViewer notification", content.toString(), email);
+    getEmailSender().sendEmail("MapViewer notification", content.toString(), email);
   }
 
   /**
@@ -588,7 +579,7 @@ public class LayoutService implements ILayoutService {
     content.append(table);
     String email = params.getModel().getProject().getNotifyEmail();
     if (params.getUser() != null) { // send email to a user who owns the layout
-      emailSender.sendEmail("MapViewer notification", content.toString(), params.getUser());
+      getEmailSender().sendEmail("MapViewer notification", content.toString(), params.getUser());
 
       // send email to the model owner
       if (email != null && !email.equals(params.getUser().getEmail())) {
@@ -600,11 +591,11 @@ public class LayoutService implements ILayoutService {
         content.append(
             "User " + username + " created layout in " + params.getModel().getProject().getProjectId() + " map.");
 
-        emailSender.sendEmail("MapViewer notification", content.toString(), email);
+        getEmailSender().sendEmail("MapViewer notification", content.toString(), email);
       }
     } else if (email != null) {
       // if nobody owns the layout then send it to the model owner
-      emailSender.sendEmail("MapViewer notification", content.toString(), email);
+      getEmailSender().sendEmail("MapViewer notification", content.toString(), email);
     }
   }
 
@@ -909,6 +900,9 @@ public class LayoutService implements ILayoutService {
 
   @Override
   public EmailSender getEmailSender() {
+    if (emailSender==null) {
+      emailSender = new EmailSender(configurationService);
+    }
     return emailSender;
   }