title: How to solve "Exception evaluating SpringEL expression" in Spring Boot?
body: <p>I am using Microsoft SQL with my Spring boot application. I have everything figured out and now I am trying to pass data from my SQL database to my front-end. However, when I pass the information via <code>thymeleaf</code> it does not work. I have a app repository as well as a DTO class that actually passes the data. Though I keep getting the same error. Sorry to bombard everyone with so much code, but I have been trying to figure a solution for a while and still can't think of a way to solve it. I believe it has to do with the TestApp class but not sure where.</p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>
      org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'dtoTiername' cannot be found on object of type 'com.John.model.TestApp' - maybe not public or not valid?
  </code></pre>
  
  <p><strong>App Repository:</strong></p>
  
  <pre><code>
          @Query("SELECT new com.John.model.TestApp(t.tiername, t.system) FROM AppSelectorTier t")
          List&lt;TestApp&gt;getServerInfo();
  
  </code></pre>
  
  <p><strong>Service Layer:</strong></p>
  
  <pre><code>
  
      public List&lt;TestApp&gt; getServerInfo() {
                  List&lt;TestApp&gt; myList = appRepository.getServerInfo();
                  System.out.println(myList.size());
                  return myList;
              }
  
  </code></pre>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>        @RequestMapping("/edit")
          public ModelAndView editTab(Model model) {
  
              ModelAndView modelAndView = new ModelAndView();
              List&lt;TestApp&gt;ary4 = new ArrayList&lt;TestApp&gt;();
              try {
                  System.out.println("Hello Code");
                  ary4 = joinQueryService.getServerInfo();
                  modelAndView.setViewName("create");             
  
              } catch (Exception e) {
                  e.printStackTrace();
                  modelAndView.setViewName("test");           
              }
              modelAndView.addObject("ary4",ary4);
              return modelAndView;                                
          }
  
  </code></pre>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>
      &lt;table class="table table-bordered table-striped"&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                        &lt;th&gt;Tiername&lt;/th&gt;
                        &lt;th&gt;System&lt;/th&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
  
                   &lt;tbody&gt;
                      &lt;tr th:each="ary4 : ${ary4}"&gt;
                          &lt;td th:text="${ary4.dtoTiername}"&gt;&lt;/td&gt;
                          &lt;td th:text="${ary4.dtoSystem}"&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/tbody&gt;
  
                 &lt;/table&gt;
  
  </code></pre>
  
  <p><strong>TestApp:</strong></p>
  
  <pre><code>package com.John.model;
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  public class TestApp implements java.io.Serializable  {
  
      private String dtoTiername;
      private String dtoSystem;
  
      private static final long serialVersionUID = 1L;
  
  
      //Constructor
      public TestApp(String dtoTiername, String dtoSystem) {
          super();
          this.dtoTiername = dtoTiername;
          this.dtoSystem = dtoSystem;
      }
  
      //Default Constructor
      public TestApp() {
  
      }
  
  
  
      //Getter
      public String getName() {
          return dtoTiername;
      }
  
      public String getSystem() {
          return dtoSystem;
      }
  
  
      //Setter
      public void setName(String dtoTiername) {
          this.dtoTiername = dtoTiername;
      }
  
  
      public void setSystem(String dtoSystem) {
          this.dtoSystem = dtoSystem;
      }
  
  }
  
  </code></pre>
  
  <p><strong>Entity:</strong></p>
  
  <pre><code>package com.John.model;
  
  import java.util.*;
  
  
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  @Table(name = "tier")
  public class AppSelectorTier implements java.io.Serializable {
  
      @Id
      @Column(name = "tiername")
      private String tiername;
  
      @Column(name = "system")
      private String system;
  
      private static final long serialVersionUID = 1L;
  
  
      //Constructor
      public AppSelectorTier(String tiername, String system) {
          super();
          this.tiername = tiername;
          this.system = system;
      }
  
      //Default Constructor
      public AppSelectorTier() {
  
      }
  
  
  
      //Getter
      public String getName() {
          return tiername;
      }
  
      public String getSystem() {
          return system;
      }
  
  
      //Setter
      public void setName(String tiername) {
          this.tiername = tiername;
      }
  
  
      public void setSystem(String system) {
          this.system = system;
      }
  
  }
  
  </code></pre>