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(); } . . .
<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>
<persistence> <persistence-unit name="wsmp"> <jta-data-source>java:/MSSQLDS</jta-data-source> </persistence-unit> </persistence>