title: Only in jsp javax.el.ELException: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
body: <p>Hello i have a web app spring+hibernate</p>
  
  <p>I jsp i tried to read a state of a product</p>
  
  <pre><code>&lt;p&gt;${product.state }&lt;/p&gt;
  </code></pre>
  
  <p>In my POJO class</p>
  
  <pre><code>public class Product
  {
     ...
     public String getState(){
         if(this.type == 6)
           return "A";
         if(propertyB.getRole()== 15)
           return "B"
     }
  }
  </code></pre>
  
  <p>when a product looking to access a property that is another entity like <code>propertyB</code> Throws </p>
  
  <blockquote>
    <p>org.hibernate.LazyInitializationException: could not initialize proxy
    - no Session</p>
  </blockquote>
  
  <p>Because i change my query with <code>LEFT JOIN FETCH</code></p>
  
  <pre><code>FROM Product p LEFT JOIN FETCH p.propertyB b
  </code></pre>
  
  <p>When i get a list of my prodcuts in a Test of Junit <strong>works</strong></p>
  
  <p>When i get a list of my products in my jsp file Throws</p>
  
  <blockquote>
    <p>javax.el.ELException: org.hibernate.LazyInitializationException: could
    not initialize proxy - no Session</p>
  </blockquote>
  
  <p>When i get a list of my products in the Controller like</p>
  
  <pre><code>for(Product p: listOfProducts){
      log.put(p.getState());
  }
  </code></pre>
  
  <p><strong>Works fine!!</strong></p>
  
  <p><strong>But only in jsp not work</strong>  why?</p>