views:

276

answers:

1

I am able to create a simple JPA Java application from NetBeans using Apache Derby database. But when I try to do the same with SQL Server 2008, I keep getting the following error:

SEVERE: Application class sample.DBTestApp failed to launch javax.persistence.PersistenceException: No Persistence provider for EntityManager named RS6910SQLEXPRESS:3027;databaseName=TestPU: The following providers: oracle.toplink.essentials.PersistenceProvider oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider Returned null to createEntityManagerFactory.

    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
    at sample.DBTestAppView.initComponents(DBTestAppView.java:285)
    at sample.DBTestAppiew.<init>(DBTestAppiew.java:36)
    at sample.DBTestApp.startup(DBTestApp.java:19)

Appreciate your help looking into this.

A: 

The problem seems to be with the generated PersistenceUnit name for SQL Server database with an instance name. The generated name was wrong as it was having backslashes and after modifying this to one simple word like "TestPU" instead of the generated "RS6910\SQLEXPRESS:3027;databaseName=TestPU" one, then everything started working.

I think this might be a bug with the NetBeans code generation for SQL Server databases with an instance name.

But as we now know a workaround, we can try to follow this. Just rename the generated persistence unit name in all of your files and things should start working.

related questions