1

使用 IBM 的 Websphere 服务器在 rad 中创建 j2ee 应用程序时出现错误

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.1: Value '2.0' of attribute 'version' of element 'persistence' is not valid with respect to the corresponding attribute use. Attribute 'version' has a fixed value of '1.0'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.processOneAttribute(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.processAttributes(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
at org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:85)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:113)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:202)

编辑:自动生成的 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="PLHService">
        <class>plh.jpa.entity.User</class>
    </persistence-unit>
</persistence>

我尝试将连接参数添加到 persistence.xml。这没有什么区别 我在http://forum.springsource.org/showthread.php?89055-jpa-2-0-persistence-xml-does-not-validate
上查看了一篇文章,但我没有使用休眠

构建路径是 rad 和 websphere 7.0 中的默认设置。

4

2 回答 2

2

WebSphere 7.0 是否支持 JPA 2.0。

答案是否定的!!. 正如 Terrell 所建议的,您应该探索使用 JPA 2.0 功能包,在这种情况下,您应该能够使用 JPA 2.0。

你也应该看看这篇文章

websphere 7 和(基于应用程序的)open-jpa 2

我还建议您查看 wsjpaversion 以了解您的设置中对 JPA 的支持。

http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.jpafep.multiplatform.doc%2Finfo%2Fae%2Fae%2Frejb_wsjpaversion.html&resultof=%22newfeat% 22%20

希望这些能给你提供好的指点。

于 2012-02-27T01:18:28.907 回答
2

构建路径是 rad 和 websphere 7.0 中的默认设置。

默认情况下,Websphere 7.0 使用 OpenJPA 1.0 的打包版本。如果您想解决此问题,请在您的 persistence.xml 文件中使用 1.0,或者在 RAD 和 WAS 中切换持久性提供程序,或者您也可以应用 JPA2.0 功能包

于 2012-02-26T18:25:13.780 回答