有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java组织。xml。萨克斯。SAXParseException

在使用IBM的Websphere server在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)

编辑: 自动生成的持久性。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>

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

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


共 (2) 个答案

  1. # 1 楼答案

    The build path is the default set in rad and websphere 7.0.

    默认情况下,WebSphere7.0使用OpenJPA1.0的包装版本。如果你想解决这个问题,可以在持久化中使用1.0。xml文件,或者RAD和WAS中的switch the persistence provider,或者您也可以选择apply the JPA2.0 feature pack

  2. # 2 楼答案

    WebSphere7.0是否支持JPA2.0

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

    你也应该看看这个帖子

    websphere 7 and (application based) 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

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