我在下面遇到PersistenceUnitLoadingException
了 Eclispelink 2.4.1,堆栈跟踪说明了什么?
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@45a877
Internal Exception: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@45a877
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:118)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at com.mypkg.Main.<clinit>(Main.java:12)
Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@45a877
Internal Exception: java.lang.NullPointerException
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:321)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:272)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchives(JPAInitializer.java:150)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfo(JPAInitializer.java:135)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:76)
... 3 more
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.init(DirectoryArchive.java:79)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.init(DirectoryArchive.java:96)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.<init>(DirectoryArchive.java:74)
at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.<init>(DirectoryArchive.java:54)
at org.eclipse.persistence.internal.jpa.deployment.ArchiveFactoryImpl.createArchive(ArchiveFactoryImpl.java:89)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:297)
... 7 more
Could not find the main class: com.mypkg.Main. Program will exit.
@编辑
我在下面的 Eclipse 下有项目结构,它与 Hibernate 作为持久性提供者配合得很好。
bin
|_META-INF
| |_persistence.xml
|_com
|_mypkg
|_Main.class
|_MyEntity.class