我刚刚下载了 http://www.apache.org/dyn/closer.cgi/openejb/4.0.0-beta-1/apache-tomee-1.0.0-beta-1-webprofile.zip以使用OpenJJB和OpenJPA2.1.1. 我无法使我的persistence.xml工作. 堆栈顶部的跟踪: org.xml.sax.SAXException
我无法使我的persistence.xml工作.
堆栈顶部的跟踪:
org.xml.sax.SAXException:
file:/D:/Workspaces/sandbox/tomcat_ejb_jpa2_tomEE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/testEE/WEB-INF/classes/META-INF/persistence.xml
[Location: Line: 2, C: 248]: org.xml.sax.SAXParseException: cvc-elt.1:
Cannot find the declaration of element ‘persistence’.
我的persistence.xml:
<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/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"> <persistence-unit name="testEE"> </persistence-unit> </persistence>
我已经读过,问题应该通过命名空间声明来解决(xmlns =“http://java.sun.com/xml/ns/persistence”),但它仍然不起作用.
<?xml version="1.0"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"> <persistence-unit name="jpa-lib"> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl </provider> <class>com.dav.jpa.entity.Employee</class> <class>com.dav.jpa.entity.Department</class> <properties> <property name="openjpa.ConnectionURL" value="jdbc:oracle:thin:@localhost:1521:DVD" /> <property name="openjpa.ConnectionDriverName" value="oracle.jdbc.OracleDriver" /> <property name="openjpa.ConnectionUserName" value="scott" /> <property name="openjpa.ConnectionPassword" value="tiger" /> <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" /> </properties> </persistence-unit> </persistence>
这对我有用..