persistence@glassfish.java.net

Problem with Entity Manager

From: Skanda skanda <k.skanda_at_gmail.com>
Date: Thu, 7 May 2009 10:25:47 +0530

I'm using netbeans 6.5, glassfish,persistence and mySQL. I'm not able to
check whether EntityManager is open or not. Here is the code:
{code}
private String getData1() {
try {
em=javax.persistence.persistence.createEntityManagerFactory("x").createEntityManager;

if (em.isOpen())
{
return("open");
}
else
{
return("close");

}

} catch (Exception nre) {
System.out.println(nre);
return null;
}

}
{code}

but it returns with the error unable to instantiate Entity Manager class.
I've @PersistentContext included in the java file. What else to be added
here? Or how do I open EntityManager