0 Replies Latest reply on Mar 30, 2006 3:09 PM by Ray Slee

    Exception when accessing EntityManager

    Ray Slee Newbie

      I have a simple app that is connecting to a mssql db (not my choice), when I try and access the entity manager from within the bean I get a null pointer exception. There are no errors when I deploy the ear to the server (hot or cold deploy - no errors)

      the class code is:

      package com.wsmp.dao;
      
      import java.util.*;
      import javax.persistence.*;
      import javax.annotation.Resource;
      import javax.ejb.*;
      
      import com.wsmp.dto.*;
      
      @Stateless
      public class StudentDAO implements StudentDAOInterface
      {
       @PersistenceContext(unitName="wsmp")
       protected EntityManager em;
      
       public StudentDAO(){}
      
       public Collection<Student> getStudentList()
       {
       Query query = em.createQuery("from STUDENT s"); //Null pointer exception here!
       return query.getResultList();
       }
      .
      .
      .
      


      mssql-ds.xml file is (running though jTDS)
      <datasources>
       <local-tx-datasource>
       <jndi-name>MSSQLDS</jndi-name>
       <connection-url>jdbc:jtds:sqlserver://150.104.62.27:1433/wsmp_t</connection-url>
       <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
       <user-name>x</user-name>
       <password>y</password>
       <min-pool-size>5</min-pool-size>
       <max-pool-size>20</max-pool-size>
       <idle-timeout-minutes>0</idle-timeout-minutes>
       <track-statements/>
       <metadata>
       <type-mapping>MS SQLSERVER2000</type-mapping>
       </metadata>
       </local-tx-datasource>
      
      </datasources>
      


      and the persistence.xml file is:

      <persistence>
       <persistence-unit name="wsmp">
       <jta-data-source>java:/MSSQLDS</jta-data-source>
       </persistence-unit>
      </persistence>
      


      any help would be appreciated, I've tried a bunch of things and nothing works - probably have done something simple wrong...

      cheers
      Ray