Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to open or read KML files #27

Open
GoogleCodeExporter opened this issue Jun 29, 2015 · 1 comment
Open

Unable to open or read KML files #27

GoogleCodeExporter opened this issue Jun 29, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

I just tried setting up a little Java application to read and write KML files 
with this library. I am using the latest Eclipse version on Win XP x32. I 
started with a very simple class looking like this:

import de.micromata.opengis.kml.v_2_2_0.*;

public class Main {
    public static void main(String[] args) {
        Kml kml = new Kml();
        kml = Kml.unmarshal(("borabora.kml"));
        Document document = (Document) kml.getFeature();
    }
}

In the proect properties, I added references to:
- jaxb-impl-2.1.9-sources.jar
- JavaAPIforKml-sources.jar

Eclipse does not show any errors or warnings before trying to compile, but when 
I try to compile I receive the following exceptions:

javax.xml.bind.JAXBException
 - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory]
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:187)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
    at de.micromata.opengis.kml.v_2_2_0.Kml.unmarshal(Kml.java:843)
    at Main.main(Main.java:34)
Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:481)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:185)
    ... 5 more

I have already opened jaxb-impl-2.1.9-sources.jar with WinRar and I found the 
class com.sun.xml.bind.v2.ContextFactory where it's supposed to be. (Actually 
no class seems to be missing.)
I did not try to read attributes from the file, because I was not yet able to 
open any file at all.

What am I doing wrong?

Original issue reported on code.google.com by skupsc...@googlemail.com on 7 Jan 2011 at 9:17

@GoogleCodeExporter
Copy link
Author

It seems to be working now. Trying to include the sources seemed to be the 
problem.
Added the compiled libraries to the project now (these containing the .class 
files) and can now read and write KML files.

Regards.

Original comment by skupsc...@googlemail.com on 7 Jan 2011 at 10:01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant