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.*;
      public class StudentDAO implements StudentDAOInterface
       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)
       <type-mapping>MS SQLSERVER2000</type-mapping>

      and the persistence.xml file is:

       <persistence-unit name="wsmp">

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