After adding log4j property in ignite default config file, service not able to start

家住魔仙堡 提交于 2021-02-10 20:33:54

问题


I'm trying to enable Log4j logger by using the gridLogger property in the config file like below:

<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"/>
<property name="gridLogger">
<bean class="org.apache.ignite.logger.log4j.Log4JLogger">
<constructor-arg type="java.lang.String" value="config/ignite-log4j.xml"/>
</bean>
</property>

But when starting the ignite.sh it is giving below error as it is not able to read the property parameter.

[root@ignite1 ~]# /usr/apache-ignite-2.7.6-bin/bin/ignite.sh
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.ignite.internal.util.GridUnsafe$2 (file:/usr/apache-ignite-2.7.6-bin/libs/ignite-core-2.7.6.jar) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of org.apache.ignite.internal.util.GridUnsafe$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
class org.apache.ignite.IgniteException: Failed to instantiate Spring XML application context [springUrl=file:/usr/apache-ignite-2.7.6-bin/config/default-config.xml, err=Line 29 in XML document from URL [file:/usr/apache-ignite-2.7.6-bin/config/default-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 29; columnNumber: 33; cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://www.springframework.org/schema/beans":property}'. One of '{"http://www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/schema/beans"], "http://www.springframework.org/schema/beans":beans}' is expected.]
        at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:1029)
        at org.apache.ignite.Ignition.start(Ignition.java:351)
        at org.apache.ignite.startup.cmdline.CommandLineStartup.main(CommandLineStartup.java:301)
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to instantiate Spring XML application context [springUrl=file:/usr/apache-ignite-2.7.6-bin/config/default-config.xml, err=Line 29 in XML document from URL [file:/usr/apache-ignite-2.7.6-bin/config/default-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 29; columnNumber: 33; cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://www.springframework.org/schema/beans":property}'. One of '{"http://www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/schema/beans"], "http://www.springframework.org/schema/beans":beans}' is expected.]
        at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:392)
        at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:104)
        at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:98)
        at org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:751)
        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:952)
        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:861)
        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:731)
        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:700)
        at org.apache.ignite.Ignition.start(Ignition.java:348)
        ... 1 more
Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 29 in XML document from URL [file:/usr/apache-ignite-2.7.6-bin/config/default-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 29; columnNumber: 33; cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://www.springframework.org/schema/beans":property}'. One of '{"http://www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/schema/beans"], "http://www.springframework.org/schema/beans":beans}' is expected.
        at 

回答1:


The error states that you have an invalid element property:

Invalid content was found starting with element '{"http://www.springframework.org/schema/beans":property}'

At the very first line, you occasionally have a closed bean id="grid.cfg" tag without a value.

Should be:

<beans ...
...
<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
  <property name="gridLogger">
    <bean class="org.apache.ignite.logger.log4j.Log4JLogger">
      <constructor-arg type="java.lang.String" value="config/ignite-log4j.xml"/>
    </bean>
  </property>
</bean>
</beans>

Also, do not forget to include the ignite-log4j.jar as a project dependency. For maven:

<dependency>
    <groupId>org.apache.ignite</groupId>
    <artifactId>ignite-log4j</artifactId>
    <version>${ignite.version}</version>
</dependency>


来源:https://stackoverflow.com/questions/58942014/after-adding-log4j-property-in-ignite-default-config-file-service-not-able-to-s

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!