title: Java-Spring, strange NullPointerException
body: <p>I'll explain the situation.
  I have an application web, java + spring + hibernate. Actually, i want to integrate DWR with Spring, so I did all the configuration and I think what I did works fine since I get this windows:  </p>
  
  <p><img src="https://i.stack.imgur.com/BA2fk.png" alt="enter image description here"></p>
  
  <p>Now, we can focus on the <code>findUsername(String username)</code> methodo inside the dwr code:</p>
  
  <pre><code>@Autowired 
  UserBo userBo;
  
  public boolean findUsername(String username) {
  
      System.out.println("I'm in the DWR");
  
      try {
  
          User user = userBo.findByUsername(username);
  
          if(user != null) {
              return true;
          }
          else {
              return false;
          }
      }
      catch (Exception e) {
          System.out.println(e.toString());
          return false;
      }
  }
  </code></pre>
  
  <p>And this is the code of <code>userBo.findByUsername(String username)</code> methodo:</p>
  
  <pre><code>public User findByUsername(String username) {
      System.out.println("I'm in the BO");
      return userDao.findByUsername(username);
  }
  </code></pre>
  
  <p>And the DAO Code:</p>
  
  <pre><code>@Transactional
  public User findByUsername(String username) {
      session = sessionFactory.openSession();
  
      System.out.println("I'm in the DAO");
  
      String hql = "FROM User Tab WHERE Tab.username= :username";
  
      Query query = session.createQuery(hql);
  
      query.setParameter("username", username);
  
      @SuppressWarnings("unchecked")
      List&lt;User&gt; userFound = (List&lt;User&gt;) query.list();
      if (userFound.size() &gt; 0) {
  
          session.close();
          return userFound.get(0);
      }
      return null;
  }
  </code></pre>
  
  <p>But when the code reach <code>userBo.findByUsername(username);</code> method call i get the NullPointerException.</p>
  
  <p>I'm pretty sure the bo + day working good because I've used it in some other part of the application.</p>
  
  <p>I don't understand the problem.
  Can someone help me?</p>
  
  <p>EDIT: The StackTrace</p>
  
  <pre><code>lcc.dwr.CCServiceDWR.findUsername(CCServiceDWR.java:26)
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  java.lang.reflect.Method.invoke(Unknown Source)
  org.directwebremoting.impl.CreatorModule$1.doFilter(CreatorModule.java:229)
  org.directwebremoting.impl.CreatorModule.executeMethod(CreatorModule.java:241)
  org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:379)
  org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:332)
  org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:104)
  org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:120)
  org.directwebremoting.spring.DwrController.handleRequestInternal(DwrController.java:234)
  org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
  org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)
  org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:822)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
  org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
  org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
  org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
  org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
  java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  java.lang.Thread.run(Unknown Source)
  </code></pre>