Modify

Opened 7 years ago

Last modified 7 years ago

#15520 new defect

NPE at DxfImportTask.realRun

Reported by: jjaf.de Owned by: team
Priority: normal Milestone:
Component: Plugin DxfImport Version: tested
Keywords: kabeja Cc:

Description

Trying to load a .DXF via DxfImport from Open GeoData of Hanover, e.g. SKH 1000 Teil Nord 4597D.DXF. After conforming the scale 1 unit(s) = 1 m:

An unexpected exception occured that may have come from the 'DxfImport' plugin.
URL:http://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2017-10-29 19:52:48 +0100 (Sun, 29 Oct 2017)
Build-Date:2017-10-29 19:11:19
Revision:13053
Relative:URL: ^/trunk

Identification: JOSM/1.5 (13053 en) Linux Debian GNU/Linux 9.1 (stretch)
Memory Usage: 610 MB / 1820 MB (381 MB allocated, but free)
Java version: 1.8.0_151-8u151-b12-1~deb9u1-b12, Oracle Corporation, OpenJDK 64-Bit Server VM
Screen: :0.0 1680x1050, :0.1 904x1440
Maximum Screen Size: 1680x1440
Java package: openjdk-8-jre:amd64-8u151-b12-1~deb9u1
Java ATK Wrapper package: libatk-wrapper-java:all-0.33.3-13
Dataset consistency test: No problems found

Plugins:
+ DxfImport (1010)
+ ImportImagePlugin (33563)
+ PicLayer (33385)
+ ejml (32680)
+ geotools (33380)
+ jts (32699)
+ log4j (32699)
+ measurement (33088)

Last errors/warnings:
- W: No configuration settings found.  Using hardcoded default values for all pools.
- E: java.io.IOException: java.lang.NullPointerException. Cause: java.lang.NullPointerException
- E: Handled by bug report queue: java.io.IOException: java.lang.NullPointerException. Cause: java.lang.NullPointerException


=== REPORTED CRASH DATA ===
BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: AWT-EventQueue-1 (17) of main
java.io.IOException: java.lang.NullPointerException
	at org.openstreetmap.josm.plugins.dxfimport.DxfImportTask.realRun(DxfImportTask.java:193)
	at org.openstreetmap.josm.gui.PleaseWaitRunnable.doRealRun(PleaseWaitRunnable.java:95)
	at org.openstreetmap.josm.gui.PleaseWaitRunnable.run(PleaseWaitRunnable.java:143)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
	at org.openstreetmap.josm.plugins.dxfimport.DxfImportTask.realRun(DxfImportTask.java:182)
	... 7 more

Attachments (0)

Change History (11)

comment:1 by Don-vip, 7 years ago

Summary: "An unexpected exception occured" while trying to load a .DXF with DxfImportNPE at DxfImportTask.realRun

comment:2 by Don-vip, 7 years ago

The zip archive does not contain any .DXF file?

in reply to:  2 comment:3 by jjaf.de, 7 years ago

Replying to Don-vip:

The zip archive does not contain any .DXF file?

Sorry, wrong URL. The Correct one is SKH 1000 DXF.

comment:4 by Don-vip, 7 years ago

In console we can see this error:

[Fatal Error] :284:174: Attribute "stroke-width" was already specified for element "use".

comment:5 by Don-vip, 7 years ago

Indeed the parser chokes on:

   <g id="Gelände-_#32_u._#32_Gewässertopographie" color="rgb(0,0,0)" stroke="currentColor" fill="none" stroke-width="0.10202025000004505">
    <line x1="546000" y1="5797400.499" x2="545977.414" y2="5797500" id="ID_126" stroke-width="0.18mm" stroke-dasharray="10, 0.05% "/>
    <line x1="545978.835" y1="5797500" x2="546000" y2="5797407.376" id="ID_127" stroke-width="0.18mm" stroke-dasharray="10, 0.05% "/>
    <use transform="translate(0 0)" id="ID_95" stroke-width="0.18mm" stroke-width="0.10202025000004505" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#ID__#42_X0"/>
    <use transform="translate(0 0)" id="ID_124" stroke-width="0.18mm" stroke-width="0.10202025000004505" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#ID__#42_X1"/>
   </g>

comment:6 by jjaf.de, 7 years ago

So the Plugin converts the DXF to an interim SVG representation and this one includes superfluous stroke-width attributes in use elements?

It seems like the "0.18mm" may be derived from DXF values "18", but the "0.10202025000004505" seems to be a Plugin calculated value.

comment:7 by Don-vip, 7 years ago

Keywords: kabeja added

Yes, but not directly. The plugin uses the Kabeja library to transform to SVG, then the SVG is converted thanks to our embedded SVG engine: svgSalamander.

Problem is: Kabeja is dead (last update in 2010), and several people tried to improve it differently, on their own (myself included):

I have not enough time right now to dig into Kabeja code. If you find what's wrong, I could release a forked version which fixes this problem. Not sure however where things are going between Antea's line of development and fuziness' one...

in reply to:  7 ; comment:8 by jjaf.de, 7 years ago

Replying to Don-vip:

Yes, but not directly. The plugin uses the Kabeja library to transform to SVG, then the SVG is converted thanks to our embedded SVG engine: svgSalamander.

So i believe one can improve robustness by following Postel's law by making kabeja output unambiguous and make svgSalamanders Fatal Error a Warning only.

Problem is: Kabeja is dead (last update in 2010), and several people tried to improve it differently, on their own (myself included):

I have not enough time right now to dig into Kabeja code. If you find what's wrong, I could release a forked version which fixes this problem. Not sure however where things are going between Antea's line of development and fuziness' one...

From Dxf-Import source i believe kabeja-0.4 is the used source.

By reading the context of grep --recursive --ignore-case 'stroke-width ./kabeja-0.4/ i believe kabeja-0.4/blocks/svg/src/org/kabeja/svg/generators/SVGViewportGenerator.java (svgContext.put) could be the problem:

public void toSAX(ContentHandler handler, Map svgContext, DXFEntity entity,
        TransformContext transformContext) throws SAXException {
[...]
                SVGUtils.addAttribute(attr,
                    SVGConstants.SVG_ATTRIBUTE_STROKE_WITDH,
                    SVGUtils.formatNumberAttribute(width));
                svgContext.put(SVGContext.STROKE_WIDTH, new Double(width));

I would delete the line 175 with svgContext.put as it seems the value width is pushed in two different ways to probably the same context. This may be a remnant of an API change since it is the only occurrence in the whole project here and the code around it uses SVGUtils.addAttribute only.

I did not execute any code to verify!

But would't that unconditional double stroke-width mean that DxfImport could not import anything!? Am i experiencing a bug in a rarely used Plugin again - like the last one we had contact ;-) ?

BTW: ATTRIBUTE_STROKE_WITDH is a typo with 22 occurrences, but maybe this is fixed in the forks already.

in reply to:  8 comment:9 by Don-vip, 7 years ago

Replying to jjaf.de:

By reading the context of grep --recursive --ignore-case 'stroke-width ./kabeja-0.4/ i believe kabeja-0.4/blocks/svg/src/org/kabeja/svg/generators/SVGViewportGenerator.java (svgContext.put) could be the problem:

public void toSAX(ContentHandler handler, Map svgContext, DXFEntity entity,
        TransformContext transformContext) throws SAXException {
[...]
                SVGUtils.addAttribute(attr,
                    SVGConstants.SVG_ATTRIBUTE_STROKE_WITDH,
                    SVGUtils.formatNumberAttribute(width));
                svgContext.put(SVGContext.STROKE_WIDTH, new Double(width));

I would delete the line 175 with svgContext.put as it seems the value width is pushed in two different ways to probably the same context. This may be a remnant of an API change since it is the only occurrence in the whole project here and the code around it uses SVGUtils.addAttribute only.

I did not execute any code to verify!

But would't that unconditional double stroke-width mean that DxfImport could not import anything!? Am i experiencing a bug in a rarely used Plugin again - like the last one we had contact ;-) ?

BTW: ATTRIBUTE_STROKE_WITDH is a typo with 22 occurrences, but maybe this is fixed in the forks already.

Thanks for searching, I'm giving it a try :)

comment:10 by Don-vip, 7 years ago

It was painful, but I have an improvement with https://github.com/JOSM/Dxf-Import/releases/tag/v1012. Can you please test?

comment:11 by Don-vip, 7 years ago

Ticket #14988 has been marked as a duplicate of this ticket.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to jjaf.de.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.