Hi,

I'm new to dom4j.  I use Eclipse 3.2 and dom4j-1.5.2. The program compiles
fine, but when i run it I get an error message that says "Fatal Exception
Occured. Program will Exit".
Any help on resolving this issue would be great.

Regards
Karthic

The program is as follows.
*package* mypackage;

*import* java.io.FileWriter;

*import* org.dom4j.Document;

*import* org.dom4j.DocumentHelper;

*import* org.dom4j.Element;

*import* org.dom4j.io.OutputFormat;

*import* org.dom4j.io.XMLWriter;

*public* *class* XMLCreator {

     Document document ;



     *public* *void* createDocument() {

       document = DocumentHelper.*createDocument*();

       Element root = document .addElement( "root" );



       Element author1 = root.addElement( "author" )

           .addAttribute( "name" , "James" )

           .addAttribute( "location" , "UK" )

           .addText( "James Strachan" );



       Element author2 = root.addElement( "author" )

           .addAttribute( "name" , "Bob" )

           .addAttribute( "location" , "US" )

           .addText( "Bob McWhirter" );

   }

    *public* *void* write()     {

     *try* {

           //lets write to a file

           XMLWriter writer = *new* XMLWriter(*new* FileWriter( "output.xml
" ));

           writer.write( document );

           writer.close();



           // Pretty print the document to System.out

           OutputFormat format = OutputFormat.* createPrettyPrint*();

           writer = *new* XMLWriter( System.*out* , format );

           writer.write( document );



           // Compact format to System.out

           format = OutputFormat.*createCompactFormat *();

           writer = *new* XMLWriter( System.*out* , format );

           writer.write( document );

     }

     *catch* (Exception e) {

           e.printStackTrace();

     } }

     *public* *static* *void* main(String args[]) {

           XMLCreator xc = *new* XMLCreator();

           xc.createDocument();

           xc.write();

     } }

The error is as follows.

java.lang.NoSuchMethodError:
com.trend.iwss.jscan.appscan.runtime.PolicyProps: method <init>()V not found

     at com.trend.iwss.jscan.appscan.runtime.Session.<init>( *Session.java
:58* )

     at com.trend.iwss.jscan.appscan.runtime.Session.<clinit>( *
Session.java:33* )

     at org.dom4j.DocumentFactory.<clinit>(DocumentFactory.java)

     at org.dom4j.DocumentHelper.createDocument(* DocumentHelper.java:34* )

     at mypackage.XMLCreator.createDocument(* XMLCreator.java:17* )

     at mypackage.XMLCreator.main(* XMLCreator.java:60* )

Exception in thread "main"
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to