简体   繁体   中英

Hazelcast Spring integration issue

I am integrating Hazelcast and Spring. Its giving me error regarding the Schema. Checked the spring and hazelcast version, still not sure why.

Spring Version : 3.2.8 HazelCast Version : 3.5

My applicationContext:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:hz="http://www.hazelcast.com/schema/spring"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
                        http://www.hazelcast.com/schema/spring http://hazelcast.com/schema/spring/hazelcast-spring-3.5.xsd">

    <context:component-scan base-package="com.hazel.hazelcastSpringBasic" />

    <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:/hazelcast-config.properties</value>
            </list>
        </property>
    </bean>

    <bean class="hazelcastSrpingBasic.TestBean" name="springTestBean">
        <property name="result" value="${value}" />
    </bean>

    <hz:hazelcast id="instance">
        <hz:config>
            <hz:group name="${name}" password="${password}" />
            <hz:properties>
                <hz:property name="hazelcast.merge.first.run.delay.seconds">5</hz:property>
                <hz:property name="hazelcast.merge.next.run.delay.seconds">5</hz:property>
            </hz:properties>
            <hz:network port="${defaultPort}" port-auto-increment="true">
                <hz:join>
                    <hz:multicast enabled="true" />
                </hz:join>
            </hz:network>
        </hz:config>
    </hz:hazelcast>

    <hz:client id="client">
        <hz:group name="${name}" password="${password}" />
        <hz:network>
            <hz:member>127.0.0.1:5705</hz:member>
        </hz:network>
    </hz:client>

    <hz:map id="map" instance-ref="instance" name="Map" lazy-init="false" />
    <hz:multiMap id="multiMap" instance-ref="instance" name="Multimap" />
    <hz:replicatedMap id="replicatedMap" instance-ref="instance"
        name="ReplicatedMap" />
    <hz:queue id="queue" instance-ref="instance" name="Queue" />
    <hz:topic id="topic" instance-ref="instance" name="Topic"
        depends-on="instance, client" />
    <hz:set id="set" instance-ref="instance" name="Set" />
    <hz:list id="list" instance-ref="instance" name="List" />
    <hz:executorService id="executorService"
        instance-ref="instance" name="ExecutorService" />
    <hz:idGenerator id="idGenerator" instance-ref="instance"
        name="IdGenerator" />
    <hz:atomicLong id="atomicLong" instance-ref="instance"
        name="atomicLong" />
    <hz:atomicReference id="atomicReference"
        instance-ref="instance" name="atomicReference" />
    <hz:countDownLatch id="countDownLatch" instance-ref="instance"
        name="countDownLatch" />
    <hz:semaphore id="semaphore" instance-ref="instance" name="semaphore" />
    <hz:lock id="lock" instance-ref="instance" name="lock" />
</beans>

Error I am getting while compilation :

Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 2 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; systemId: http://hazelcast.com/schema/spring/hazelcast-spring-3.5.xsd; lineNumber: 2; columnNumber: 35; s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw '301 Moved Permanently'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
    at org.springframework.context.support.GenericXmlApplicationContext.load(GenericXmlApplicationContext.java:115)
    at org.springframework.context.support.GenericXmlApplicationContext.<init>(GenericXmlApplicationContext.java:69)
    at hazelcastSpringBasic.SpringClient.main(SpringClient.java:26)
Caused by: org.xml.sax.SAXParseException; systemId: http://hazelcast.com/schema/spring/hazelcast-spring-3.5.xsd; lineNumber: 2; columnNumber: 35; s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw '301 Moved Permanently'.
    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.opti.SchemaDOMParser.characters(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanContent(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.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
    at org.apache.xerces.impl.xs.opti.SchemaParsingConfig.parse(Unknown Source)
    at org.apache.xerces.impl.xs.opti.SchemaDOMParser.parse(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.getSchemaDocument(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(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.impl.XMLNSDocumentScannerImpl.scanStartElement(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.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
    ... 9 more

Thanks in advance.

Does it work for you if you change the last line of the schema instance from http://www.hazelcast.com/schema/spring http://hazelcast.com/schema/spring/hazelcast-spring-3.5.xsd"> to http://www.hazelcast.com/schema/spring https://hazelcast.com/schema/spring/hazelcast-spring-3.5.xsd"> ?

The xsi:schemaLocation section is problematic. The line referenced above is missing www for the second URL.

The second URL in the XML file is http://hazelcast.com/schema/spring/hazelcast-spring-3.5.xsd and should be http://www.hazelcast.com/schema/spring/hazelcast-spring-3.5.xsd

You need to add hazelcast-spring project to your classpath.

<dependency>
   <groupId>com.hazelcast</groupId>
   <artifactId>hazelcast-spring</artifactId>
   <version>3.5</version>
</dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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