I am trying to generate artifacts for log4j
XML parsing using JAXB
. I am using the dtd
http://logging.apache.org/log4j/1.2/apidocs/org/ap.../log4j/xml/doc-files/log4j.dtd
and inlined log.xml. I am getting below exception. I am a newbie with all these tech. Please someone help with this issue.
Exception in thread "main" javax.xml.bind.UnmarshalException: unexpected element (uri:"http://jakarta.apache.org/log4j/", local:"configuration"). Expected elements are <{}appender>,<{}appender-ref>,<{}category>,<{}categoryFactory>,<{}connectionSource>,<{}dataSource>,<{}errorHandler>,<{}filter>,<{}layout>,<{}level>,<{}logger>,<{}logger-ref>,<{}loggerFactory>,<{}param>,<{}plugin>,<{}priority>,<{}renderer>,<{}rollingPolicy>,<{}root>,<{}root-ref>,<{}triggeringPolicy> at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:558) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:211) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:206) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:83) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext$DefaultRootLoader.childElement(UnmarshallingContext.java:965) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:401) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:382) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.startElement(SAXConnector.java:113) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(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.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:202) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:175) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:148) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:153) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:162) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:180)
log4jXML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false" xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
<appender-ref ref="DEFAULT"/>
</appender>
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c %x- %m%n"/>
</layout>
</appender>
<appender name="DEFAULT" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="/home/default.log" />
<param name="Append" value="true" />
<param name="maxFileSize" value="10MB" />
<param name="maxBackupIndex" value="2" />
<param name="encoding" value="UTF-8" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c %x- %m%n"/>
</layout>
</appender>
<appender name="DB_EXCEP" class="org.apache.log4j.FileAppender">
<param name="File" value="/home/db_exception.log" />
<param name="Append" value="true" />
<param name="encoding" value="UTF-8" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c %x- %m%n"/>
</layout>
</appender>
<category name="com.common.db.ScriptRunner" additivity="false">
<priority value="info" />
<appender-ref ref="DB_EXCEP" />
</category>
<category name="com.common.appsvr.current.admin" additivity="false">
<priority value="info"/>
<appender-ref ref="DEFAULT"/>
</category>
<!-- ROOT CATEGORY -->
<root>
<priority value="debug"/>
<appender-ref ref="DEFAULT"/>
<!-- <appender-ref ref="STDOUT"/> -->
</root>
</log4j:configuration>