简体   繁体   English

org.xml.sax.SAXParseException

[英]org.xml.sax.SAXParseException

I am getting an error when I create a j2ee application in rad with IBM's Websphere server 当我使用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)

EDIT: The auto generated persistence.xml is shown below: 编辑:自动生成的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>

I tried adding the connection parameters to persistence.xml. 我尝试将连接参数添加到persistence.xml。 It does not make a difference 它没有任何区别
I checked out an article at http://forum.springsource.org/showthread.php?89055-jpa-2-0-persistence-xml-does-not-validate but i did not use hibernate 我在http://forum.springsource.org/showthread.php?89055-jpa-2-0-persistence-xml-does-not-validate查看了一篇文章,但我没有使用hibernate

The build path is the default set in rad and websphere 7.0. 构建路径是rad和websphere 7.0中的默认设置。

The build path is the default set in rad and websphere 7.0. 构建路径是rad和websphere 7.0中的默认设置。

By default Websphere 7.0 uses a wrapped version of OpenJPA 1.0. 默认情况下,Websphere 7.0使用OpenJPA 1.0的包装版本。 If you want to fix this either use 1.0 in your persistence.xml file, or switch the persistence provider in RAD and WAS, or you could alternatively apply the JPA2.0 feature pack . 如果要修复此问题,请在persistence.xml文件中使用1.0,或者在RAD和WAS中切换持久性提供程序 ,或者也可以应用JPA2.0功能包

Does WebSphere 7.0 support JPA 2.0. WebSphere 7.0是否支持JPA 2.0。

The answer is no!! 答案是否定的!! . As suggested by Terrell you should explore using the JPA 2.0 Feature pack in which case, you should be able to use JPA 2.0. 正如Terrell建议你应该探索使用JPA 2.0 Feature Pack,在这种情况下,你应该能够使用JPA 2.0。

You should also look at this post 你也应该看看这篇文章

websphere 7 and (application based) open-jpa 2 websphere 7和(基于应用程序)open-jpa 2

I would also suggest you look at wsjpaversion to see the support for JPA in your set up. 我还建议您查看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 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

Hope these provide you with good pointers. 希望这些能为您提供良好的指导。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM