[jdom-interest] jdom2 migration issue

Rolf Lear jdom at tuis.net
Mon Aug 20 10:34:58 PDT 2012


Hi Craig.

There must be some other imports from the org.jdom package (as well as
org.jdom2....).

The error message you are getting would be impossible unless you have
those imports.

Something is wrong in your imports.... and your build path must have some
old JDOM classes from places other than just the old JDOM jar.

Finally, it is normal in GUI-type development tools, (eclipse, IntelliJ,
etc) to exclude the package on field names.... i.e. the line:

    protected org.jdom2.Document document;

would not normally be created by Eclipse/IntelliJ unless your class was
already using the org.jdom.Document version somewhere. You should probably
replace the line with:

    protected Document document;

and ensure that you can import Document from org.jdom2 with

    import org.jdom2.Document;

Bottom line is that you still have old JDOM classes in your build path,
and the copde you have shown us us using *both* Document versions
(org.jdom, as well as org.jdom2).

Rolf





On Mon, 20 Aug 2012 09:58:15 -0600, "Craig Christophersen"
<craigch at synesis7.com> wrote:
> Hello;
> 
> I have been trying to migrate to Jdom2 in an application.  I have
followed
> the migration guide but get a type mismatch error.
> 
> Snippit below:
> 
>    protected org.jdom2.Document document; 
> 
>  
> 
>     private String str = null;
> 
>     private String dmString = "";
> 
>     String f = "f";
> 
>     String t = "t";
> 
>     protected DocType dt;
> 
>     /**
> 
>      * Read the specified File and parse it to create a JDOM tree
> 
>      **/
> 
>     public ReadDmFile(File dmFile)// throws IOException, JDOMException {
> 
>     { 
> 
>         System.out.println("File in ReadDm X: " + dmFile);
> 
>        
> 
>         try {
> 
>         SAXBuilder builder =
> 
>             new SAXBuilder(); //"org.apache.xerces.parsers.SAXParser"
> 
>       
> 
>         // Parse the specified file and convert it to a JDOM document
> 
>         builder.setIgnoringElementContentWhitespace(true);
> 
>         document = builder.build(dmFile);
> 
>  
> 
>  
> 
>  
> 
> On last line I get "Type mismatch: cannot convert from
org.jdom2.Document
> to
> org.jdom.Document"
> 
> The old jdom jar is removed from this project.
> 
> Any help would be appreciated.
> 
>  
> 
> Thanks,
> 
>  
> 
>  
> 
> Craig Christophersen
> 
> Software Developer
> 
> Synesis7
> 
> craigch at synesis7.com


More information about the jdom-interest mailing list