Article

Error "org.xml.sax.SAXParseException: Content is not allowed in prolog" in the ESB container when configured with log4j

« Go Back

Information

 
Article Number000026950
EnvironmentProduct: Sonic ESB CA Suite 7.6
OS: All supported platforms
Question/Problem Description
ESB container configured with log4j fails to load  the log4j.xml file.
Loading the log4j.xml file, fails throwing exception: 
"org.xml.sax.SAXParseException: Content is not allowed in prolog" in the container logs.
Steps to Reproduce
Clarifying Information
The log4j.xml file used has below content
 
<?xml version="1.0" encoding="UTF-8" ?>
<appender name="xqLog" class="com.sonicsw.xqimpl.util.log.XQLogAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p [%c{1}] %m"/>
</layout>
</appender>

<logger name="com.pantero">
<level value="debug"/>
</logger>
<logger name="com.pantero.runtime.debug.TestCaseRunner">
<level value="debug"/>
</logger>
<logger name="com.pantero.runtime.RuntimeEnvironment">
<level value="debug"/>
</logger>

<root>
<priority value="info"/>
<appender-ref ref="xqLog"/>
</root>

 
Error Messagelog4j:ERROR Could not parse url [sonicfs:/Resources/log4j.xml].
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at org.apache.log4j.xml.DOMConfigurator$2.parse(DOMConfigurator.java:690)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:789)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:696)
at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:821)
at com.sonicsw.xqimpl.util.log.XQLog4jConfigurator.setConfiguration(XQLog4jConfigurator.java:93)
at com.sonicsw.xqimpl.service.XQContainer.initLog4j(XQContainer.java:468)
at com.sonicsw.xqimpl.service.XQContainer.init(XQContainer.java:397)
at com.sonicsw.mf.framework.agent.AbstractMBean.<init>(AbstractMBean.java:293)
at com.sonicsw.mf.framework.agent.ComponentMBean.<init>(ComponentMBean.java:170)
at com.sonicsw.mf.framework.agent.ContainerImpl.internalLoadComponent(ContainerImpl.java:3368)
at com.sonicsw.mf.framework.agent.ContainerImpl.loadComponent(ContainerImpl.java:1297)
at com.sonicsw.mf.framework.agent.ContainerImpl.loadConfiguredComponent(ContainerImpl.java:473)
at com.sonicsw.mf.framework.agent.ContainerImpl.loadConfiguredComponents(ContainerImpl.java:4101)
at com.sonicsw.mf.framework.agent.ContainerImpl.loadAllConfiguredComponents(ContainerImpl.java:3937)
at com.sonicsw.mf.framework.agent.ContainerImpl.bootFramework(ContainerImpl.java:2225)
at com.sonicsw.mf.framework.agent.ContainerImpl.<init>(ContainerImpl.java:313)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
at com.sonicsw.mf.framework.agent.ci.Agent.<init>(Agent.java:212)
at com.sonicsw.mf.framework.agent.ci.Agent$1.run(Agent.java:93)
at java.lang.Thread.run(Thread.java:595)
Defect/Enhancement Number
Cause
This exception is being thrown by the XML parser, due to the XML being used not being correctly formed.
Resolution
Modify the log4j.xml to include log4j:configuration tag.

For example, modify the xml example in this Article as follows:
 
<?xml version="1.0" encoding="UTF-8" ?>                                  
                                                                         
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">                        
                                                                         
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">     
                                                                         
<appender name="xqLog" class="com.sonicsw.xqimpl.util.log.XQLogAppender">
<layout class="org.apache.log4j.PatternLayout">                          
<param name="ConversionPattern" value="%-5p [%c{1}] %m"/>                
</layout>                                                                
</appender>                                                              
                                                                         
<logger name="com.pantero">                                              
<level value="debug"/>                                                   
</logger>                                                                
<logger name="com.pantero.runtime.debug.TestCaseRunner">                 
<level value="debug"/>                                                   
</logger>                                                                
<logger name="com.pantero.runtime.RuntimeEnvironment">                   
<level value="debug"/>                                                   
</logger>                                                                
                                                                         
<root>                                                                   
<priority value="info"/>                                                 
<appender-ref ref="xqLog"/>                                              
</root>                                                                  
                                                                         
</log4j:configuration>

 
Workaround
Notes
Attachment 
Last Modified Date12/12/2018 11:58 AM


Feedback
 
Did this article resolve your question/issue?

   

Your feedback is appreciated.

Please tell us how we can make this article more useful. Please provide us a way to contact you, should we need clarification on the feedback provided or if you need further assistance.

Characters Remaining: 1025