WorldWind AbstractMethodError sample application application at startup

I was instructed to create an application using the WorldWind API and get familiar with the API, I tried to run the HelloWorldWind sample application. When I do this, I get the following error stack:

Exception in thread "main" java.lang.AbstractMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V at gov.nasa.worldwind.util.WWXML.createDocumentBuilder(WWXML.java:61) at gov.nasa.worldwind.util.WWXML.openDocumentStream(WWXML.java:236) at gov.nasa.worldwind.util.WWXML.openDocumentStream(WWXML.java:223) at gov.nasa.worldwind.util.WWXML.openDocumentFile(WWXML.java:175) at gov.nasa.worldwind.util.WWXML.openDocument(WWXML.java:148) at gov.nasa.worldwind.Configuration.loadConfigDoc(Configuration.java:131) at gov.nasa.worldwind.Configuration.<init>(Configuration.java:108) at gov.nasa.worldwind.Configuration.<clinit>(Configuration.java:76) at gov.nasa.worldwindx.examples.HelloWorldWind.main(HelloWorldWind.java: 

WWXML.createDocumentBuilder as follows:

 public static DocumentBuilder createDocumentBuilder(boolean isNamespaceAware) { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setNamespaceAware(isNamespaceAware); if (Configuration.getJavaVersion() >= 1.6) { try { docBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); // Not getting past here } catch (ParserConfigurationException e) { // Note it and continue on. Some Java5 parsers don't support the feature. String message = Logging.getMessage("XML.NonvalidatingNotSupported"); Logging.logger().finest(message); } } ... 

Reading some things on the Internet , people blame jogl , since I work on a 64-bit system, however, I already have the necessary banks in my build path. Also, trying the URL shown above in the browser returns a 404 page, which makes me think that this could be the reason the URL is just a way to format some settings . Since I do not have a source for DocumentBuilderFactory.setFeature , I do not see what is happening there.

Am I really a jogl or something else?

+6
source share
2 answers

This is some class problem. AbstractMethodError occurs when the JVM tries to call an abstract method (which is not valid). DocumentBuilderFactory.setFeature(String, boolean) is an abstract method that was added to DocumentBuilderFactory in JavaSE 5, so implementations compiled against J2SE 1.4.2 would not have this method, and this error would setFeature(String, boolean) when setFeature(String, boolean) .

Perhaps you have an old XML library in your class path that returned an instance for DocumetnBuilderFactory.newInstance() . The problem may not be JOGL itself, maybe JOGL brought the old XML library into the library as a dependency.

+10
source

You need to go to the WWXML class and replace:

 docBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); 

with:

 docBuilderFactory.setNamespaceAware(true); 

full java method:

  public static DocumentBuilder createDocumentBuilder(boolean isNamespaceAware) { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilderFactory.setNamespaceAware(isNamespaceAware); if (Configuration.getJavaVersion() >= 1.6) { docBuilderFactory.setNamespaceAware(true); } try { return docBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { String message = Logging.getMessage("XML.ParserConfigurationException"); Logging.logger().finest(message); throw new WWRuntimeException(e); } } 
+1
source

Source: https://habr.com/ru/post/953161/


All Articles