title: Overridden toString method in EJB not invoked
body: <p>I am studying/experimenting with EJBs. I have an EJB with an overridden toString method:</p>
  
  <pre><code>@Stateless
  @LocalBean
  public class FlightService {
  ... 
  @Override
  public String toString() {
      return "FlightService [id=" + id + ", from=" + from + ", to=" + to + ", price=" + price + ", airplaneModel="
              + airplaneModel + "]";
  }
  </code></pre>
  
  <p>}</p>
  
  <p>In my servlet, I inject this EJB into a variable, like this:</p>
  
  <pre><code>@EJB
  private FlightService fs;
  </code></pre>
  
  <p>However, when I would like to print it out..</p>
  
  <pre><code>if (fs != null){
      out.println("Flight details: " + fs.toString());
  }
  </code></pre>
  
  <p>.. I get the following output, which is what I would get with the defaul toString method, I think.</p>
  
  <pre><code>Flight details: com.airline.service.__EJB31_Generated__FlightService__Intf___754270295
  </code></pre>
  
  <p>Instead of</p>
  
  <pre><code>Flight details: FlightService [id=123, ...]
  </code></pre>
  
  <p>as I would expect. All other functionalities of the EJB are working as expected, as far as I can tell. Can someone please explain to me what happens with the toString method? Thank you!</p>
  
  <p>EDIT: It works with explicitly created objects (new FlightService()), as suggested by Soumitri Pattnaik.</p>
  
  <p>EDIT2: Full source available on pastebin. <a href="http://pastebin.com/WHc9a7g3" rel="nofollow">FlightService.java</a>, <a href="http://pastebin.com/pSB6Q1pK" rel="nofollow">FlightDetails.java</a>
  The project was created in Eclipse, running on Glassfish 4.</p>