aspose file tools*
The moose likes XML and Related Technologies and the fly likes JAXB with log.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB with log.xml" Watch "JAXB with log.xml" New topic
Author

JAXB with log.xml

sameerkm jain
Greenhorn

Joined: May 18, 2011
Posts: 2
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/apache/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)




Thanks
Sameer
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 468
    
    2
The exception message shows the setup has hurdled already many points of difficulty. In order to debug at that stage, you have to show the line that uses the unmarshal () method. How does it look like?
Seg Violet
Greenhorn

Joined: May 20, 2011
Posts: 4
I got a similar error when I didn't have the same schema file referenced in the xml file as I had used in JAXB's binding compilation step (i.e. the xsd files used with xjc -- this includes the full path, not just the file contents). You might want to check line 5 of your xml file to see if you are having a similar problem.

I hope that this helps!
sameerkm jain
Greenhorn

Joined: May 18, 2011
Posts: 2
Thanks for looking into this

Here is my Client



and I also tried changing the log.xml by pointing it to the specific DTD in the filesystem, but without any luck.


g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 468
    
    2
I would suppose you've compiled the schema (dtd) with a proper local or remote copy of the document correctly, with some jaxb package path, say "log4j" so designated in your post. In that case you should take a look at within the package and you should at least see a class named Log4JConfiguration.class (just to confirm)...

In that case, you can replace the unmarshal() line:
>Object xmlConf = u.unmarshal(new File("log.xml"));
by this:

and continue to use the object you named xmlConf.
 
Don't get me started about those stupid light bulbs.
 
subject: JAXB with log.xml
 
Similar Threads
how to disable the log
Unable to get logging working in Tomcat application
log4j:WARN No appenders could be found for logger
log4j Asynchronous log message order
Avoid additional server.log debug lines