Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hazelcat 3.5 - InvalidConfigurationException: cvc-complex-type.2.4.a #6523

Closed
alexey-su opened this issue Oct 21, 2015 · 9 comments

Comments

Projects
None yet
4 participants
@alexey-su
Copy link

commented Oct 21, 2015

closes the issue: #5551
closes the issue: #5659

Code without xml validation error

HazelcastClient.newHazelcastClient();

Code with xml validation error

Hazelcast.newHazelcastInstance();

If use com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorImpl from runtime no validate error.
If use org.apache.xerces.jaxp.validation.ValidatorImpl from xerces 2.11.0, return validate error

org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'group'. 
One of '{"http://www.hazelcast.com/schema/config":import, 
"http://www.hazelcast.com/schema/config":group, 
"http://www.hazelcast.com/schema/config":license-key, 
"http://www.hazelcast.com/schema/config":management-center, 
"http://www.hazelcast.com/schema/config":properties, 
"http://www.hazelcast.com/schema/config":wan-replication, "http://www.hazelcast.com/schema/config":network,
"http://www.hazelcast.com/schema/config":partition-group,
"http://www.hazelcast.com/schema/config":executor-service,
"http://www.hazelcast.com/schema/config":queue,
"http://www.hazelcast.com/schema/config":map,
"http://www.hazelcast.com/schema/config":multimap,
"http://www.hazelcast.com/schema/config":replicatedmap,
"http://www.hazelcast.com/schema/config":cache, 
"http://www.hazelcast.com/schema/config":list, 
"http://www.hazelcast.com/schema/config":set, 
"http://www.hazelcast.com/schema/config":topic, 
"http://www.hazelcast.com/schema/config":reliable-topic, 
"http://www.hazelcast.com/schema/config":jobtracker, 
"http://www.hazelcast.com/schema/config":semaphore, 
"http://www.hazelcast.com/schema/config":ringbuffer, 
"http://www.hazelcast.com/schema/config":listeners, 
"http://www.hazelcast.com/schema/config":serialization, 
"http://www.hazelcast.com/schema/config":native-memory, 
"http://www.hazelcast.com/schema/config":services, 
"http://www.hazelcast.com/schema/config":security, 
"http://www.hazelcast.com/schema/config":member-attributes, 
"http://www.hazelcast.com/schema/config":quorum}' is expected.

I propose to transfer the description of the item "import"
from file
hazelcast/hazelcast-client/src/main/resources/hazelcast-client-config-3.5.xsd
to
hazelcast/hazelcast/src/main/resources/hazelcast-config-3.5.xsd

<xs:element name="hazelcast">
  <xs:complexType>
    <xs:choice minOccurs="1" maxOccurs="unbounded">
      <xs:element ref="import"/>

change element "import" to

<xs:element ref="import" minOccurs="0" maxOccurs="unbounded"/>

We have to change 3 files:
hazelcast-config-3.4.xsd
hazelcast-config-3.5.xsd
hazelcast-config-3.6.xsd

@bilalyasar bilalyasar added the PENDING label Oct 21, 2015

@bilalyasar

This comment has been minimized.

Copy link
Collaborator

commented Oct 21, 2015

Hi @alexey-su ,
thanks for your concern and suggestion.
Actually we have solved this issue with this PR. #5659

Does issue still exist? or am i missing some points?

@alexey-su

This comment has been minimized.

Copy link
Author

commented Oct 22, 2015

The file hazelcast-client-config-3.5.xsd have element "import" is optional and can be several times.

27: <xs: element ref = "import" minOccurs = "0" maxOccurs = "unbounded" />

The file hazelcast-config-3.5.xsd have element "import" a required and can be only once.

27: <xs: element ref = "import" />

class AbstractConfigBuilder in hazelcast-3.5.3.jar

77: NodeList importTags = (NodeList) xpath.evaluate("/" + this.getXmlType().name + "/" + IMPORT.name, document,
78:     XPathConstants.NODESET);
79: for (Node node: new AbstractXmlConfigHelper.IterableNodeList (importTags)) {

It is understood that the elements can not be (minOccurs = "0") or many (maxOccurs = "unbounded")

My project use Apache Xerces 2.11.0. The system falls out of error. We have to adjust the configuration code.
Like that:

Config cfg = new Config();
Hazelcast.newHazelcastInstance(cfg);

JUnit tests use Xerces from JVM runime. The error is not repeated.

@mesutcelik mesutcelik modified the milestone: 3.6 Oct 27, 2015

@mdogan mdogan removed the PENDING label Nov 2, 2015

@bilalyasar

This comment has been minimized.

Copy link
Collaborator

commented Nov 2, 2015

@alexey-su , i tried your case in my local.
For your validator, it works. But if you use another validator this fix doesn't work. I also tried with saxon.. -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl .. and it failed...

@alexey-su

This comment has been minimized.

Copy link
Author

commented Nov 2, 2015

You say that the test falls.
This means that the code should fall

HazelcastClient.newHazelcastClient();

Let's say, the implementation of which version we tested. So be honest.

@bilalyasar

This comment has been minimized.

Copy link
Collaborator

commented Nov 2, 2015

yes, my version is 3.5.3

my output is when i try HazelcastClient.newHazelcastClient();

JAXP: using thread context class loader (sun.misc.Launcher$AppClassLoader@3b76d662) for search
JAXP: Looking up system property 'javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom'
JAXP: The property is undefined.
JAXP: found null in $java.home/jaxp.properties
JAXP: no META-INF/services/javax.xml.xpath.XPathFactory file was found
JAXP: attempting to use the platform default W3C DOM XPath lib
JAXP: createInstance(com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl)
JAXP: loaded com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl from jar:file:/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib/rt.jar!/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.class
JAXP: factory 'com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl' was found for http://java.sun.com/jaxp/xpath/dom
Nov 02, 2015 2:01:10 PM com.hazelcast.client.config.XmlClientConfigLocator
INFO: Loading 'hazelcast-client-default.xml' from classpath.
JAXP: find factoryId =javax.xml.parsers.DocumentBuilderFactory
JAXP: loaded from fallback value: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
JAXP: created new instance of class com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl using ClassLoader: null
JAXP: find factoryId =javax.xml.transform.TransformerFactory
JAXP: found jar resource=META-INF/services/javax.xml.transform.TransformerFactory using ClassLoader: sun.misc.Launcher$AppClassLoader@3b76d662
JAXP: found in resource, value=net.sf.saxon.TransformerFactoryImpl
JAXP: created new instance of class net.sf.saxon.TransformerFactoryImpl using ClassLoader: sun.misc.Launcher$AppClassLoader@3b76d662
JAXP: using thread context class loader (sun.misc.Launcher$AppClassLoader@3b76d662) for search
JAXP: Looking up system property 'javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema'
JAXP: The property is undefined.
JAXP: found null in $java.home/jaxp.properties
JAXP: no META-INF/services/javax.xml.validation.SchemaFactory file was found
JAXP: attempting to use the platform default XML Schema validator
JAXP: createInstance(com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory)
JAXP: loaded com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory from jar:file:/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib/rt.jar!/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.class
JAXP: factory 'com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory' was found for http://www.w3.org/2001/XMLSchema
Exception in thread "main" com.hazelcast.config.InvalidConfigurationException: cvc-elt.1: Cannot find the declaration of element 'hazelcast-client'.
    at com.hazelcast.config.AbstractXmlConfigHelper.schemaValidation(AbstractXmlConfigHelper.java:193)
    at com.hazelcast.client.config.XmlClientConfigBuilder.parseAndBuildConfig(XmlClientConfigBuilder.java:183)
    at com.hazelcast.client.config.XmlClientConfigBuilder.build(XmlClientConfigBuilder.java:164)
    at com.hazelcast.client.config.XmlClientConfigBuilder.build(XmlClientConfigBuilder.java:157)
    at com.hazelcast.client.HazelcastClient.newHazelcastClient(HazelcastClient.java:71)
    at com.hazelcast.client.Main.main(Main.java:8)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

My validator is saxon.

Can you also post your logs when you start your jvm via -Djaxp.debug=1?

@mesutcelik mesutcelik modified the milestones: 3.6, 3.7 Nov 2, 2015

@alexey-su

This comment has been minimized.

Copy link
Author

commented Nov 3, 2015

I'm in one of the projects was a problem with saxon.
Someone decided to repeat the code in AbstractXmlConfig.

Validator validator = schema.newValidator();
SAXSource source = new SAXSource(new InputSource(is));
validator.validate(source);

Other code written earlier, there are no errors.

SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(true);
factory.setNamespaceAware(true);
factory.setSchema(schema);
SAXParser parser = factory.newSAXParser();
XMLReader reader = parser.getXMLReader();
reader.setErrorHandler(new DefaultErrorHandler());
reader.parse(is);

Last code does not use the Transformer.

@bilalyasar

This comment has been minimized.

Copy link
Collaborator

commented Nov 4, 2015

factory.setNamespaceAware(true); is also our fix code which is available in 3.6...
For earlier versions we recommend workarounds..

So your workaround, i think will solve problems in some validators-transformers. ( for example it doesn't solve saxon problem)
What is your opinion in this respect?

@alexey-su

This comment has been minimized.

Copy link
Author

commented Nov 5, 2015

Less dependency on other solutions, the system is easier.
Do not make hard dependencies on the implementation of XSLT Transformer.

I think that should be selected for the Saxon setting SCHEMA_URI_RESOLVER or SCHEMA_URI_RESOLVER_CLASS. http://www.saxonica.com/documentation/index.html#!configuration/config-features

@mesutcelik mesutcelik modified the milestones: 3.8, 3.7 Jun 29, 2016

@bilalyasar

This comment has been minimized.

Copy link
Collaborator

commented Dec 19, 2016

this is fixed by 3.6. (#5659)
if you use older version, please look workarounds. (#5551)

@bilalyasar bilalyasar closed this Dec 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.