flow
flow copied to clipboard
TaskUpdateImports throws exception with unclear message
Description of the bug
TaskUpdateImports (from build-frontend) can fail with the following message:
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:14.8.6:build-frontend (default) on project webclient: Execution default of goal com.vaadin:vaadin-maven-plugin:14.8.6:build-frontend failed: java.io.IOException: Ist ein Verzeichnis -> [Help 1]
("Ist ein Verzeichnis" means "is a directory")
The exception is thrown here.
Expected behavior
The exception message should contain information about the offending filePath
.
Minimal reproducible example
The example is a customer application. The actual cause had not been isolated yet, because the exception message doesn't suggest an exact cause. Static code analysis can demonstrate that such exception may be thrown at that location, given that something is a directory.
...
Caused by: java.io.IOException: Ist ein Verzeichnis
at sun.nio.ch.FileDispatcherImpl.pread0 (Native Method)
at sun.nio.ch.FileDispatcherImpl.pread (FileDispatcherImpl.java:54)
at sun.nio.ch.IOUtil.readIntoNativeBuffer (IOUtil.java:274)
at sun.nio.ch.IOUtil.read (IOUtil.java:245)
at sun.nio.ch.FileChannelImpl.readInternal (FileChannelImpl.java:811)
at sun.nio.ch.FileChannelImpl.read (FileChannelImpl.java:796)
at java.nio.file.FileChannelLinesSpliterator$1.read (FileChannelLinesSpliterator.java:140)
at sun.nio.cs.StreamDecoder.readBytes (StreamDecoder.java:274)
at sun.nio.cs.StreamDecoder.implRead (StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read (StreamDecoder.java:178)
at java.io.BufferedReader.fill (BufferedReader.java:161)
at java.io.BufferedReader.readLine (BufferedReader.java:326)
at java.io.BufferedReader.readLine (BufferedReader.java:392)
at java.nio.file.FileChannelLinesSpliterator.readLine (FileChannelLinesSpliterator.java:174)
at java.nio.file.FileChannelLinesSpliterator.forEachRemaining (FileChannelLinesSpliterator.java:116)
at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:484)
at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:474)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:913)
at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:578)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.visitImportsRecursively (AbstractUpdateImports.java:526)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.handleImports (AbstractUpdateImports.java:583)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.visitImportsRecursively (AbstractUpdateImports.java:567)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.handleImports (AbstractUpdateImports.java:583)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.getUniqueEs6ImportPaths (AbstractUpdateImports.java:359)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.getModuleLines (AbstractUpdateImports.java:399)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.collectModules (AbstractUpdateImports.java:308)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.run (AbstractUpdateImports.java:113)
at com.vaadin.flow.server.frontend.TaskUpdateImports.execute (TaskUpdateImports.java:413)
at com.vaadin.flow.server.frontend.NodeTasks.execute (NodeTasks.java:529)
at com.vaadin.flow.plugin.maven.BuildFrontendMojo.runNodeUpdater (BuildFrontendMojo.java:200)
...
Versions
- Vaadin: 14.8.6
- OS version: Linux (doesn't happen under Windows or MacOS)
- Using Adoptium Java 11
It should be trying to read @JsModule
and @JavaScript
annotations and imports in generated-flow-imports.js
and generated-flow-imports-fallback.js
(these 2 should match @NpmPackage
found in the code).
Then it checks for these files the import statements for other import statements to handle.
Only imports pointing to files inside frontend
folder or node_modules/@vaadin/flow-frontend/
folder should be considered.
I would guess that somewhere in a frontend template file there is an import pointing to a folder instead of a file. This should be probably ignored as we do not need to do anything with it and perhaps logged to inform that there was this kind of issue somewhere.
If you find the cause could you add a small sample so that we could replicate and generate a good error message?
This happens when you import a directory. All tools seem to interpret a directory import like you want to import index.js
inside that directory but the theme import parser fails on this
I have the same issue. As already reported here, it fails the build on Linux but not on Windows.
However, taking a closer look on the build output, I noticed that there is also a warning about a similar problem:
[WARNING] Could not read file C:\MyProject\appmodule\frontend. Skipping applying theme for its imports
java.nio.file.AccessDeniedException: C:\MyProject\appmodule\frontend
at sun.nio.fs.WindowsException.translateToIOException (WindowsException.java:89)
at sun.nio.fs.WindowsException.rethrowAsIOException (WindowsException.java:103)
at sun.nio.fs.WindowsException.rethrowAsIOException (WindowsException.java:108)
at sun.nio.fs.WindowsFileSystemProvider.newFileChannel (WindowsFileSystemProvider.java:121)
at java.nio.channels.FileChannel.open (FileChannel.java:298)
at java.nio.channels.FileChannel.open (FileChannel.java:357)
at java.nio.file.Files.lines (Files.java:4132)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.visitImportsRecursively (AbstractUpdateImports.java:571)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.handleImports (AbstractUpdateImports.java:630)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.visitImportsRecursively (AbstractUpdateImports.java:614)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.handleImports (AbstractUpdateImports.java:630)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.getUniqueEs6ImportPaths (AbstractUpdateImports.java:377)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.getModuleLines (AbstractUpdateImports.java:415)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.collectModules (AbstractUpdateImports.java:326)
at com.vaadin.flow.server.frontend.AbstractUpdateImports.run (AbstractUpdateImports.java:130)
at com.vaadin.flow.server.frontend.TaskUpdateImports.execute (TaskUpdateImports.java:396)
at com.vaadin.flow.server.frontend.NodeTasks.execute (NodeTasks.java:977)
at com.vaadin.flow.plugin.base.BuildFrontendUtil.runNodeUpdater (BuildFrontendUtil.java:340)
at com.vaadin.flow.plugin.maven.BuildFrontendMojo.execute (BuildFrontendMojo.java:100)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:210)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:195)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:833)
This ticket/PR has been released with Vaadin 23.3.0.
This ticket/PR has been released with Vaadin 23.2.15.
This ticket/PR has been released with Vaadin 22.0.28.
This ticket/PR has been released with Vaadin 14.9.5.
This ticket/PR has been released with Vaadin 14.10.0.alpha1 and is also targeting the upcoming stable 14.10.0 version.