本文介绍了带有EclipseLink和Java SE的JPA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将项目jar文件导出到文件服务器后,jpa的Entitymanager的创建将不再起作用.

After exporting the project jar file to the fileserver the creation of the entitymanager of jpa does not work anymore.

有以下详细信息:

  1. 我使用Glassfishv3项目中的EclipseLink
  2. 我从网站上下载了EclipseLink 2.4....
  3. org.eclipse.persistence.core.jar,org.eclipse.persistence.jpa.jar,javax.persistence.jar和eclipselink.jar位于lib文件夹中.
  4. persistence.xml位于src内的META-INF文件夹中. (我使用日食日光灯)
  5. 这是persistence.xml的内容

  1. I use EclipseLink from Glassfishv3 Project
  2. I downloaded EclipseLink 2.4... from the website.
  3. org.eclipse.persistence.core.jar, org.eclipse.persistence.jpa.jar, javax.persistence.jar and eclipselink.jar are in the lib folder.
  4. persistence.xml is in META-INF folder inside src. (I use eclipse helios)
  5. this is the content of the 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中起作用,但不能在文件服务器中起作用. :-)

The whole thing works inside eclipse but not from the fileserver. :-)

错误消息是:

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是:

DBConnection is:

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();

推荐答案

persistence.xml文件格式正确,因此该错误可能与类路径混乱导致调用错误的SAX解析器有关.我的建议是仔细检查您的应用程序类路径,尤其是检查所包含的jar是否包含重复且不兼容的SAX解析器.

The persistence.xml file is well-formed so the error could be related to a wrong SAX parser being called as a result of a messed classpath. My advise is to carefully review your application classpath, especially checking if included jars contain duplicate and incompatible SAX parsers.

这篇关于带有EclipseLink和Java SE的JPA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 09:08