hz:map-store throws error

58 views
Skip to first unread message

Tara Czutno

unread,
May 24, 2017, 8:06:06 PM5/24/17
to Hazelcast
In Spring xml config, 'hz:map-store' throws an error saying:
17:49:40.519 ERROR [main] org.springframework.test.context.TestContextManager – Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@1868ed54] to prepare test instance [com.twc.ctg.ecp.service.dataaccess.maps.EntitlementMapTest@1b9ea3e3] org.xml.sax.SAXParseException: cvc-complex-type.2.1: Element 'hz:map' must have no character or element information item [children], because the type's content type is empty.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) ~[?:1.8.0_101]
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) ~[?:1.8.0_101]
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396) ~[?:1.8.0_101]
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) ~[?:1.8.0_101]
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284) ~[?:1.8.0_101]
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:452) ~[?:1.8.0_101]

What am I doing wrong?

Tara

<?xml version="1.0" encoding="UTF-8"?>
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.hazelcast.com/schema/spring
http://www.hazelcast.com/schema/spring/hazelcast-spring.xsd">



<hz:hazelcast id="hzInstance1">
<hz:config>
<hz:group name="${ecp.hz.group.name}" password="${ecp.hz.group.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="${ecp.hz.port}" port-auto-increment="true">
<hz:join>
<hz:multicast enabled="true"/>
</hz:join>
</hz:network>
</hz:config>
</hz:hazelcast>

<hz:client id="hzInstance1Client">
<hz:group name="${ecp.hz.group.name}" password="${ecp.hz.group.password}"/>
<hz:network>
<hz:member>${ecp.hz.host}:${ecp.hz.port}</hz:member>
</hz:network>
</hz:client>

<hz:map id="entitlementCache" instance-ref="hzInstance1" name="entitlement">
<hz:map-store enabled="true" implementation="linearEntitlementMapStore"
write-delay-seconds="30000"/>

</hz:map>


<bean id="linearEntitlementMapStore" class="com.twc.ctg.ecp.service.dataaccess.maps.LinearEntitlementMapStore" />


</beans>

Viktor Gamov

unread,
Jun 1, 2017, 6:01:29 PM6/1/17
to Hazelcast
Hi Tara

Correct config below.
Basically map-store config should be included inside config tag.
Thank you
<?xml version="1.0" encoding="UTF-8"?>
<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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.hazelcast.com/schema/spring
http://www.hazelcast.com/schema/spring/hazelcast-spring.xsd">


<hz:hazelcast id="hzInstance1">
<hz:config>
<hz:group name="${ecp.hz.group.name}" password="${ecp.hz.group.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="${ecp.hz.port}" port-auto-increment="true">
<hz:join>
<hz:multicast enabled="true"/>
</hz:join>
</hz:network>
            <hz:map name="entitlement">

<hz:map-store enabled="true" implementation="linearEntitlementMapStore"
write-delay-seconds="30000"/>
</hz:map>
        </hz:config>
</hz:hazelcast>

<hz:client id="hzInstance1Client">
<hz:group name="${ecp.hz.group.name}" password="${ecp.hz.group.password}"/>
<hz:network>
<hz:member>${ecp.hz.host}:${ecp.hz.port}</hz:member>
</hz:network>
</hz:client>


    <bean id="linearEntitlementMapStore" class="com.twc.ctg.ecp.service.dataaccess.maps.LinearEntitlementMapStore"/>


</beans>

Tara Czutno

unread,
Jun 1, 2017, 6:13:06 PM6/1/17
to Hazelcast
Thank you.  I will try that.

s...@etcc.com

unread,
Nov 16, 2017, 9:37:59 AM11/16/17
to Hazelcast
Hi, I have a similar question, following this https://github.com/hazelcast/hazelcast-code-samples/blob/master/hazelcast-integration/spring-configuration/src/main/resources/applicationContext.xml

If define outside of the ocnfig

<hz:map id="map" instance-ref="instance" name="Map" lazy-init="false"/>

you can get bean

IMap<Integer, Integer> map = (IMap<Integer, Integer>) context.getBean("map", IMap.class);

If we have to define inside, is there a way that we can still use getBean to get the map?

Thanks
Shannon
Reply all
Reply to author
Forward
Message has been deleted
0 new messages