question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NPE in migration tool CopyResourcesStep

See original GitHub issue

Execution of the migration tool fails with the following exception at CopyResourcesStep:130

Caused by: java.lang.NullPointerException
at com.vaadin.flow.migration.CopyResourcesStep$HtmlImportRewriter.adjustContent (CopyResourcesStep.java:130)
at com.vaadin.flow.migration.CopyResourcesStep$HtmlImportRewriter.handle (CopyResourcesStep.java:84)
at com.vaadin.flow.migration.AbstractCopyResourcesStep$CopyFileVisitor.visitFile (AbstractCopyResourcesStep.java:88)
at com.vaadin.flow.migration.AbstractCopyResourcesStep$CopyFileVisitor.visitFile (AbstractCopyResourcesStep.java:68)
at java.nio.file.Files.walkFileTree (Files.java:2803)
at java.nio.file.Files.walkFileTree (Files.java:2875)
at com.vaadin.flow.migration.AbstractCopyResourcesStep.doCopyResources (AbstractCopyResourcesStep.java:186)
at com.vaadin.flow.migration.AbstractCopyResourcesStep.copyResources (AbstractCopyResourcesStep.java:178)
at com.vaadin.flow.migration.CopyResourcesStep.copyResources (CopyResourcesStep.java:191)
at com.vaadin.flow.migration.Migration.migrate (Migration.java:171)
at com.vaadin.flow.plugin.maven.MigrateMojo.execute (MigrateMojo.java:120)

No information is provided in the log about what file caused that.

Vaadin 14.1.17

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mvysnycommented, May 5, 2021

Instead of closing as WON’T FIX, how about we help the customer and harden the sources of the migration tool?

Looking at CopyResourcesStep:130, the body variable is clearly null, which means that there is a html file which clearly has no body. If this can happen, simply return from the function. If this should not happen, add a simple check which will fail with an informative error message!

            if (body == null) {
                throw new IllegalArgumentException("File " + file + " has no <body> element");
            }
0reactions
mvysnycommented, May 5, 2021

Indeed, when I added the lines above, recompiled the migration tool on the 2.6 branch and ran it, the exception is now much more informative:

Exception in thread "main" java.lang.IllegalArgumentException: File ./src/main/webapp/frontend/flowgraph/node_modules/paper/dist/docs/index.html has no <body> element
	at com.vaadin.flow.migration.CopyResourcesStep$HtmlImportRewriter.adjustContent(CopyResourcesStep.java:113)
	at com.vaadin.flow.migration.CopyResourcesStep$HtmlImportRewriter.handle(CopyResourcesStep.java:84)
	at com.vaadin.flow.migration.AbstractCopyResourcesStep$CopyFileVisitor.visitFile(AbstractCopyResourcesStep.java:88)

The HTML file in question is:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Paper.js v0.12.0</title>
</head>
<frameset cols="230,*">
<frame src="classes/index.html" name="packageListFrame" title="All Packages">
<frame src="about:blank" name="class-frame" title="Class and interface descriptions">
</frameset>
</html>

It can be safely skipped. Indeed, this code does the trick:

            if (body == null) {
                System.out.println("Skipping " + file + " since it has no <body> element");
                return doc.outerHtml();
            }
Read more comments on GitHub >

github_iconTop Results From Across the Web

An NPE Exception occur when using Connector Migration ...
When using Connector Migration Tool to migrate the job with any connector stages, it might report the following error, SEVERE Migration failed: jobxxx: ......
Read more >
Migrate dependancies NPE — OpenText - Forums
running the migrate dependencies (workarea) as root, no log generated, getting an NPE, not certain how to proceed. Starting migration tool .
Read more >
New Commerce Experience Batch Migration Tool (BAM)
Learn how to use the New Commerce Experience Batch Migration Tool to migrate your customer's subscription's to NCE.
Read more >
TTP - A365 Email Migration
The migration of your email data may appear intimidating, but the following processes ... an NPE have migrated the NPE should be migrated...
Read more >
Configure the Secure Firewall Migration Tool for ASA ... - Cisco
This document describes the procedure to migrate Cisco Adaptive Security Appliance (ASA) to Cisco Firepower.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found