title: List size is 0 on Glassfish whereas on tomcat , it works
body: <p>I have a a method which return the last index in a list. When I run the application on tomcat, it works fine. But when I run it on glassfish,I got the following error:  </p>
  
  <pre><code>    java.lang.IndexOutOfBoundsException
  </code></pre>
  
  <p>This is the method which is returning the last value in a list:</p>
  
  <pre><code>    public String getLastValue(String code){
  
      List&lt;Cars&gt; car=new ArrayList&lt;Cars&gt;();
      try{
          car = new ArrayList&lt;Cars&gt;(carsDAO.findCarById(code));
      }
      catch(Exception e){
          System.out.println("Error: "+ e);
      }
  
      List&lt;String&gt; temp= new ArrayList&lt;String&gt;();
  
      for (Cars cars : car){
              temp.add(cars.getValue());
          }
      system.out.print("Size of car":+ temp.size());
  
      Collections.sort(temp);
      return temp.get(temp.size()-1);
  
  }
  </code></pre>
  
  <p>STACKTRACE:</p>
  
  <pre><code>       type Exception report
  
         message
  
         descriptionThe server encountered an internal error () that prevented    it from fulfilling this request.
  
         exception
  
        javax.servlet.ServletException: java.lang.IndexOutOfBoundsException:  Index: 5, Size: 0
        root cause
  
        javax.faces.el.EvaluationException:    java.lang.IndexOutOfBoundsException: Index: 5, Size: 0
        root cause
  
        java.lang.IndexOutOfBoundsException: Index: 5, Size: 0
  </code></pre>
  
  <p>As you can see, I print the size of the list. On glassfish the size is 0 but on tomcat it returns me the correct number of data. How come it does not work on glassfish?</p>