0 Replies Latest reply on Dec 27, 2005 7:49 AM by Vijaypal Singh

    Entity Manager is  null

    Vijaypal Singh Newbie

      Hello everybody,

      I'am using ejb 3 with jboss AS 4.0.2 .I have created an entity bean

      import java.io.Serializable;
      import java.sql.Date;

      import javax.persistence.Column;
      import javax.persistence.Entity;
      import javax.persistence.FetchType;
      import javax.persistence.Id;
      import javax.persistence.JoinColumn;
      import javax.persistence.ManyToOne;
      import javax.persistence.Table;

      import com.dte.incentiveGroup.ejb.IncentiveGroupPO;
      import com.dte.incentivePlan.ejb.IncentivePlanPO;
      import com.dte.user.ejb.EmployeePO;

      @Table(name = "Employee_Grant")
      public class EmployeeGrantPO implements Serializable{
      Integer employeeGrantID;
      private IncentiveGroupPO incentiveGroupID;
      private EmployeePO employeeID;
      private IncentivePlanPO incentivePlanID;
      private GrantPO grantPO;
      Integer companyID;
      Float AIPPer;
      Integer sharesOriginal;
      String activeYN;
      String createdBY;
      Date createdDT;
      String modifiedBY;
      Date modifiedDT;

      public String getActiveYN() {
      return activeYN;

      public void setActiveYN(String activeYN) {
      this.activeYN = activeYN;

      public Float getAIPPer() {
      return AIPPer;

      public void setAIPPer(Float per) {
      AIPPer = per;

      public Integer getCompanyID() {
      return companyID;

      public void setCompanyID(Integer companyID) {
      this.companyID = companyID;

      public String getCreatedBY() {
      return createdBY;

      public void setCreatedBY(String createdBY) {
      this.createdBY = createdBY;

      public Date getCreatedDT() {
      return createdDT;

      public void setCreatedDT(Date createdDT) {
      this.createdDT = createdDT;
      public Integer getEmployeeGrantID() {
      return employeeGrantID;

      public void setEmployeeGrantID(Integer employeeGrantID) {
      this.employeeGrantID = employeeGrantID;
      @JoinColumn(name = "Employee_ID")
      public EmployeePO getEmployeeID() {
      return employeeID;

      public void setEmployeeID(EmployeePO employeeID) {
      this.employeeID = employeeID;

      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "Grant_ID")

      public GrantPO getGrantPO() {
      return grantPO;

      public void setGrantPO(GrantPO grantID) {
      this.grantPO = grantID;

      public IncentiveGroupPO getIncentiveGroupID() {
      return incentiveGroupID;

      public void setIncentiveGroupID(IncentiveGroupPO incentiveGroupID) {
      this.incentiveGroupID = incentiveGroupID;

      @JoinColumn(name = "Incentive_Plan_ID")
      public IncentivePlanPO getIncentivePlanID() {
      return incentivePlanID;

      public void setIncentivePlanID(IncentivePlanPO incentivePlanID) {
      this.incentivePlanID = incentivePlanID;

      public String getModifiedBY() {
      return modifiedBY;

      public void setModifiedBY(String modifiedBY) {
      this.modifiedBY = modifiedBY;

      public Date getModifiedDT() {
      return modifiedDT;

      public void setModifiedDT(Date modifiedDT) {
      this.modifiedDT = modifiedDT;

      public Integer getSharesOriginal() {
      return sharesOriginal;

      public void setSharesOriginal(Integer sharesOriginal) {
      this.sharesOriginal = sharesOriginal;


      and a session bean

      import java.io.Serializable;
      import javax.ejb.Remote;
      import javax.ejb.Stateful;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;

      public class EmployeeGrantBean implements EmployeeGrant,Serializable{
      private EntityManager manager;
      RestrictedGrantInfo restrictedGrantInfo = null;
      EmployeeGrantPO employeeGrantPO = null;
      public EmployeeGrantPO getEmployeeGrant(String employeeSSN){

      System.out.println("Inside EmployeeGrantPO getEmployeeGrant for employeeSSN = "+employeeSSN);
      System.out.println("manager = "+manager);
      employeeGrantPO = (EmployeeGrantPO)manager.createQuery("select employeeGrantPO from EmployeeGrantPO employeeGrantPO where employeeGrantPO.employeeID =:value").setParameter("value",employeeSSN).getSingleResult();
      System.out.println("Returning from EmployeeGrantPO getEmployeeGrant employeeGrantPO = "+employeeGrantPO);
      return employeeGrantPO;

      the problem is that when try to fire the method on EntityManager manager
      the manager is null.

      My question is what wrong an i doing that the value of EntityManager manager is null??

      I humbly look forward to your guidence.