"Could not resolve a persistence unit" error...

Hello,

I created a Netbeans Visual Web application. I added an Entity Class from a database table. A resource is added into Server Resources part. when I look at its properties, I see that it's JNDI name is set to "bitkiwiki" and I check the Sun Application Server's JDBC Resources and I see "bitkiwiki" in JDBC Resources.

My controller class has a EntityManagerFactory element:

@PersistenceUnit(unitName ="bitkiwiki")

private EntityManagerFactory emf;

When I compile the project it compiles successfully but when I deploy it, I get an error like this:

Deploying application in domain failed; Deployment Error -- Could not resolve a persistence unit corresponding to the persistence-unit-ref-name .......

The Persistance UnitName exists in the server resources but it still complains about it.

What's the problem you think?

Thanks.

[976 byte] By [xyzta] at [2007-11-27 10:40:38]
# 1

In the persistence.xml you have something like this:

<persistence-unit name="EJBCustomerPU" transaction-type="JTA">

<jta-data-source>cust</jta-data-source>

<properties>

</properties>

</persistence-unit>

The unitName in the annotation should equal "EJBCustomerPU". I think the "bitkiwiki" is wrong. The "cust" in the above persistence.xml should be the resource you mention in the jdbc section of the app server admin.

tobiassen666a at 2007-7-28 19:07:55 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

In Netbeans, Visual Web Application projects, persistance.xml file is not created. I don't know but altough I created an Entity Class, there's no persistance.xml in the project folders. In normal Web Application projects, it was created...I think Visual Web Pack is not well suited...

xyzta at 2007-7-28 19:07:55 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...