title: EJB threw an unexpected (non-declared) exception during invocation of method
body: <p>I have this application running in Websphere 8.5. But, when I try to login to this application. I get this </p>
  
  <pre><code>Error 500: javax.ejb.EJBException: Injection failure; nested exception is: java.lang.NullPointerException 
  </code></pre>
  
  <p>This is the method thats being invoked</p>
  
  <pre><code> /**
   * Retrieves the user with the given user name.
   *
   * @param username the username to search for
   * @return the matching user, null if not found
   * @throws PortalServiceException for any errors encountered
    */
  @SuppressWarnings("rawtypes")
  @TransactionAttribute(TransactionAttributeType.SUPPORTS)
  public CMSUser findByUsername(String username) throws PortalServiceException {
  Query q = getEm().createQuery("FROM CMSUser u WHERE u.username = :username");
  q.setParameter("username", username);
  List rs = q.getResultList();
  if (rs.isEmpty()) {
  
      return null;
  }
  return (CMSUser) rs.get(0);
  </code></pre>
  
  <p>}</p>
  
  <p><img src="https://i.stack.imgur.com/uh8Il.png" alt="enter image description here"></p>
  
  <pre><code>**Websphere JVM Logs**
  
  [6/15/13 9:29:56:259 CDT] 00000084 BusinessExcep E   CNTR0019E: EJB threw an unexpected (non-declared) exception during invocation of method "findByUsername". Exception data: javax.ejb.EJBException: Injection failure; nested exception is: java.lang.NullPointerException
      at com.ibm.ejs.container.util.ExceptionUtil.EJBException(ExceptionUtil.java:475)
      at com.ibm.ejs.container.StatelessBeanO.initialize(StatelessBeanO.java:299)
      at com.ibm.ejs.container.BeanOFactory.create(BeanOFactory.java:130)
      at com.ibm.ejs.container.EJSHome.createNewBeanO(EJSHome.java:869)
      at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1242)
      at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1360)
      at com.ibm.ejs.container.activator.UncachedActivationStrategy.atActivate(UncachedActivationStrategy.java:89)
      at com.ibm.ejs.container.activator.Activator.preInvokeActivateBean(Activator.java:324)
      at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:3728)
      at com.ibm.ejs.container.EJSContainer.EjbPreInvoke(EJSContainer.java:3042)
      at gov.medicaid.services.EJSLocal0SLRegistrationServiceBean_95c2d7eb.findByUsername(EJSLocal0SLRegistrationServiceBean_95c2d7eb.java)
      at gov.medicaid.security.CMSLDAPUserDetailsMapper.mapUserFromContext(CMSLDAPUserDetailsMapper.java:78)
      at org.springframework.security.ldap.authentication.LdapAuthenticationProvider.authenticate(LdapAuthenticationProvider.java:256)
      at gov.medicaid.security.DomainLdapAuthenticationProvider.authenticate(DomainLdapAuthenticationProvider.java:50)
      at org.springframework.security.authentication.ProviderManager.doAuthentication(ProviderManager.java:130)
      at org.springframework.security.authentication.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:48)
      at gov.medicaid.security.CustomAuthenticationProcessingFilter.attemptAuthentication(CustomAuthenticationProcessingFilter.java:84)
      at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
      at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
      at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
      at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:928)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1025)
      at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3761)
      at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:976)
      at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:459)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:526)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:312)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:283)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
      at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
      at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
      at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
      at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
      at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
      at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
      at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)
  Caused by: java.lang.NullPointerException
      at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:188)
      at org.hibernate.service.internal.BasicServiceRegistryImpl.configureService(BasicServiceRegistryImpl.java:80)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:145)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:118)
      at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:70)
      at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2253)
      at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2249)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1720)
      at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:76)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:884)
      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
      at com.ibm.ws.jpa.management.JPAPUnitInfo.createEMFactory(JPAPUnitInfo.java:1584)
      at com.ibm.ws.jpa.management.JPAPUnitInfo.createEntityManagerFactory(JPAPUnitInfo.java:1406)
      at com.ibm.ws.jpa.management.JPAPxmlInfo.extractPersistenceUnits(JPAPxmlInfo.java:246)
      at com.ibm.ws.jpa.management.JPAScopeInfo.processPersistenceUnit(JPAScopeInfo.java:119)
      at com.ibm.ws.jpa.management.JPAApplInfo.processModulePUs(JPAApplInfo.java:167)
      at com.ibm.ws.jpa.management.AbstractJPAComponent.startingModule(AbstractJPAComponent.java:451)
      at
  </code></pre>
  
  <p>Any suggestions?</p>