Hi,
So I'm currently having an issue where createEntityManagerFactory returns null. When I run the application on the my local machine through Tomcat it works fine, the odb file is created.
public class TaskDaoODBImpl implements TaskDao { private EntityManagerFactory emf; private EntityManager em; public TaskDaoODBImpl(){ emf = Persistence.createEntityManagerFactory("C:/objectdb-2.5.5_12/db/tasks.odb"); em = emf.createEntityManager(); em.find(Task.class, Task.class); }
Here's my object (I removed the getters and setters):
@Entity public class Task implements Serializable { @Id @GeneratedValue int id; //int id = 0; private String ticketNumber; private String createdDate; private String updatedDate; private String dueDate; private String description; private String owner; private String status; private String approvalGroup; private String details; private String notes = ""; private String ppmc = ""; private String cmTicket = ""; private int leadTimeDays = 0; private String type = "System-Generated"; public Task(String ticketNumber, String owner, String approvalGroup, String description, String details){ this.ticketNumber = ticketNumber; this.approvalGroup = approvalGroup; this.description = description; this.status = "Not Started"; this.owner = owner; this.details = details; } public Task(String ticketNumber, String createdDate, String approvalGroup, String description, String owner, String dueDate, String status) { super(); this.ticketNumber = ticketNumber; this.createdDate = createdDate; this.dueDate = dueDate; this.description = description; this.owner = owner; this.status = status; this.approvalGroup = approvalGroup; } public int getId(){ return id; } }
The problem comes up when I attempt to run this on an IBM Websphere server. I modify the path on the createEntityManagerFactory call:
public class TaskDaoODBImpl implements TaskDao { private EntityManagerFactory emf; private EntityManager em; public TaskDaoODBImpl(){ emf = Persistence.createEntityManagerFactory("/lsppordev1/app/lsppo/db/tasks.odb"); em = emf.createEntityManager(); em.find(Task.class, Task.class); }
The application is deployed to Websphere as an EAR file. When I attempt to access the application I get an exception. The exception is ultimately caused by a null pointer on the line "em = emf.createEntityManager()" in TaskDaoOBDImpl. I've attached a copy of the exception below.
I'm not using a persistence.xml file in this case to define the location of the database since I have two different databases to connect to.
Any ideas what could be causing this?
Thanks,
elks