1

I am getting an error when I create a j2ee application in rad with IBM's Websphere server

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:

<?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. 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

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

DataNucleus
  • 15,497
  • 3
  • 32
  • 37
nkvp
  • 342
  • 1
  • 8
  • 15
  • 2
    You need to post the file in question. Your `persistence.xml` maybe? The `SAXParseException` stacktrace is useless; the message is the only part helping us. – beerbajay Feb 25 '12 at 21:03
  • Does Websphere have a local XML catalog that provides the resolution for the `xsi:schemalocation`? If so it may be overriding the external link to the XSD and providing the wrong one (v 1.0) which would result in the error you're seeing. – Jim Garrison Feb 26 '12 at 08:01
  • So you use what JPA implementation and what version ? OpenJPA ? and a version that only supports JPA1? – DataNucleus Feb 26 '12 at 08:32
  • @DataNucleus well, i could not find a way out... so i'm currently using 1.0... planning to upgrade later to was8.0 – nkvp Mar 17 '12 at 21:32

2 Answers2

2

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

By default Websphere 7.0 uses a wrapped version of 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.

Community
  • 1
  • 1
Terrell Plotzki
  • 2,014
  • 17
  • 17
2

Does WebSphere 7.0 support 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.

You should also look at this post

websphere 7 and (application based) open-jpa 2

I would also suggest you look at wsjpaversion to see the support for JPA in your set up.

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.

Community
  • 1
  • 1
Manglu
  • 10,744
  • 12
  • 44
  • 57