将项目 jar 文件导出到文件服务器后,jpa 的实体管理器的创建不再起作用。
有以下细节:
- 我使用 Glassfishv3 项目中的 EclipseLink
- 我从网站下载了 EclipseLink 2.4...。
- org.eclipse.persistence.core.jar、org.eclipse.persistence.jpa.jar、javax.persistence.jar 和 eclipselink.jar 在 lib 文件夹中。
- persistence.xml 位于 src 内的 META-INF 文件夹中。(我使用日食 helios)
这是 persistence.xml 的内容
<?xml version="1.0" encoding="UTF-8"?> <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"> <persistence-unit name="QIS" transaction-type="RESOURCE_LOCAL" > <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <class>com.quoka.qis.lib.persistence.Type</class> </persistence-unit> </persistence>
整个事情在 eclipse 中工作,但不是来自文件服务器。:-)
错误信息是:
org.eclipse.persistence.internal.jpa.deployment.xml.parser.XMLException
URI was not reported to parser for entity [document])
Caused By:
Log Exception of type org.eclipse.persistence.internal.jpa.deployment.xml.parser.XMLException :
(1. URI was not reported to parser for entity [document])
(0) org.eclipse.persistence.internal.jpa.deployment.xml.parser.XMLExceptionHandler.error(XMLExceptionHandler.java:28)
(1) org.eclipse.persistence.internal.jpa.deployment.xml.parser.XMLExceptionHandler.warning(XMLExceptionHandler.java:23)
(2) gnu.xml.aelfred2.SAXDriver.warn(SAXDriver.java:935)
(3) gnu.xml.aelfred2.SAXDriver.startExternalEntity(SAXDriver.java:631)
(4) gnu.xml.aelfred2.XmlParser.pushURL(XmlParser.java:3358)
(5) gnu.xml.aelfred2.XmlParser.doParse(XmlParser.java:159)
(6) gnu.xml.aelfred2.SAXDriver.parse(SAXDriver.java:320)
(7) gnu.xml.aelfred2.XmlReader.parse(XmlReader.java:294)
(8) org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceXML(PersistenceUnitProcessor.java:442)
(9) org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceArchive(PersistenceUnitProcessor.java:401)
(10) org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.getPersistenceUnits(PersistenceUnitProcessor.java:310)
(11) org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchive(JPAInitializer.java:149)
(12) org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchives(JPAInitializer.java:136)
(13) org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfo(JPAInitializer.java:125)
(14) org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:98)
(15) org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:65)
(16) javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:78)
(17) com.quoka.qis.admin.QisAdminEntityManager.getInstance(QisAdminEntityManager.java:33)
(18) com.quoka.qis.admin.QisAdminFrame.login(QisAdminFrame.java:574)
(19) com.quoka.qis.admin.QisAdminFrame.testLogin(QisAdminFrame.java:513)
(20) com.quoka.qis.admin.QisAdminFrame.showFrame(QisAdminFrame.java:441)
(21) com.quoka.qis.admin.QisAdminFrame.showFrame(QisAdminFrame.java:417)
(22) com.quoka.qis.admin.QisAdminFrame.access$3(QisAdminFrame.java:416)
(23) com.quoka.qis.admin.QisAdminFrame$DebugPanel.run(QisAdminFrame.java:777)
(24) java.lang.Thread.run(Thread.java:662)
DBConnection 是:
Map<String, String> properties = new HashMap<String, String>();
properties.put("javax.persistence.jdbc.driver", "com.sybase.jdbc3.jdbc.SybDriver");
properties.put("eclipselink.target-database", "Sybase");
properties.put("javax.persistence.jdbc.url", "jdbc:sybase:Tds:"+meta.getServerName()+":"+meta.getPort());
properties.put("javax.persistence.jdbc.user", meta.getUserName());
properties.put("javax.persistence.jdbc.password", meta.getPassword());
properties.put("eclipselink.logging.level", "INFO");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("QIS", properties);
em = emf.createEntityManager();