Vertispan / j2clmavenplugin

Maven plugin to launch new J2CL compilation
https://vertispan.github.io/j2clmavenplugin/
Apache License 2.0
53 stars 26 forks source link

j2cl:watch crashes when doing hot changes on windows 11 #163

Closed starklord closed 2 years ago

starklord commented 2 years ago

Hi, when i run j2cl:watch , then jetty:run, the program runs nicely but when i make changes in src packages, the j2cl:watch crashes, curiously when i make changes in the css folder, my IDE (VS Code) tells me i can't make any changes(maybe privilleges?) i will put all the stacktrace PS C:\workspaces\j2cl\piru> mvn j2cl:watch [INFO] Scanning for projects... [INFO] [INFO] -----------------------------< piru:piru >------------------------------ [INFO] Building piru 1.0-SNAPSHOT [INFO] --------------------------------[ war ]--------------------------------- [INFO] [INFO] --- j2cl-maven-plugin:0.19:watch (default-cli) @ piru --- [INFO] Using C:\workspaces\j2cl\piru\target/piru-1.0-SNAPSHOT as webappDirectory since goal is running in a non-reactor build and none was set [INFO] Removing dependency com.google.jsinterop:base:jar:1.0.0:compile, replacing with com.vertispan.jsinterop:base:jar:1.0.0-1 [INFO] Removing dependency com.google.jsinterop:base:jar:1.0.0:compile, replacing with com.vertispan.jsinterop:base:jar:1.0.0-1 [INFO] Removing dependency com.google.jsinterop:base:jar:1.0.0:compile, replacing with com.vertispan.jsinterop:base:jar:1.0.0-1 [INFO] Removing dependency com.google.jsinterop:base:jar:1.0.0:compile, replacing with com.vertispan.jsinterop:base:jar:1.0.0-1 [INFO] Starting com.google.elemental2:elemental2-dom:1.1.0/unpack [INFO] Finished com.google.elemental2:elemental2-dom:1.1.0/unpack in 328ms [INFO] Starting com.google.jsinterop:jsinterop-annotations:2.0.0/unpack [INFO] Starting com.google.elemental2:elemental2-core:1.1.0/unpack [INFO] Finished com.google.elemental2:elemental2-core:1.1.0/unpack in 61ms [INFO] Starting com.google.elemental2:elemental2-promise:1.1.0/unpack [INFO] Starting com.vertispan.jsinterop:base:1.0.0-1/unpack [INFO] Finished com.vertispan.jsinterop:base:1.0.0-1/unpack in 8ms [WARNING] Test watch temporarily disabled [INFO] Start watching {piru:piru:1.0-SNAPSHOT=[C:\workspaces\j2cl\piru\src\main\java]} [INFO] Watching for changes [INFO] Starting piru:piru:1.0-SNAPSHOT/jszipbundle [INFO] Starting com.google.elemental2:elemental2-dom:1.1.0/bytecode [INFO] Starting com.vertispan.jsinterop:base:1.0.0-1/bytecode [INFO] Finished com.vertispan.jsinterop:base:1.0.0-1/bytecode in 11ms [INFO] Starting com.google.jsinterop:jsinterop-annotations:2.0.0/bytecode [INFO] Finished com.google.jsinterop:jsinterop-annotations:2.0.0/bytecode in 6ms [INFO] Starting com.google.elemental2:elemental2-core:1.1.0/bytecode [INFO] Finished com.google.elemental2:elemental2-core:1.1.0/bytecode in 90ms [INFO] Starting com.google.elemental2:elemental2-promise:1.1.0/bytecode [INFO] Finished com.google.elemental2:elemental2-promise:1.1.0/bytecode in 9ms [INFO] Starting com.vertispan.jsinterop:base:1.0.0-1/stripped_sources [INFO] Finished com.google.elemental2:elemental2-dom:1.1.0/bytecode in 659ms [INFO] Finished com.vertispan.jsinterop:base:1.0.0-1/stripped_sources in 95ms [INFO] Starting com.google.jsinterop:jsinterop-annotations:2.0.0/stripped_sources [INFO] Starting com.google.elemental2:elemental2-core:1.1.0/stripped_sources [INFO] Finished com.google.elemental2:elemental2-core:1.1.0/stripped_sources in 37ms [INFO] Starting com.google.elemental2:elemental2-promise:1.1.0/stripped_sources [INFO] Starting com.vertispan.jsinterop:base:1.0.0-1/transpiled_js [INFO] Finished piru:piru:1.0-SNAPSHOT/jszipbundle in 2018ms [INFO] Finished com.vertispan.jsinterop:base:1.0.0-1/transpiled_js in 1191ms [INFO] Starting com.vertispan.jsinterop:base:1.0.0-1/stripped_bytecode [INFO] Starting com.google.jsinterop:jsinterop-annotations:2.0.0/stripped_bytecode [INFO] Starting com.google.jsinterop:jsinterop-annotations:2.0.0/transpiled_js [INFO] Starting com.vertispan.jsinterop:base:1.0.0-1/bundled_js [INFO] Finished com.vertispan.jsinterop:base:1.0.0-1/bundled_js in 131ms [INFO] Starting com.google.jsinterop:jsinterop-annotations:2.0.0/stripped_bytecode_headers [INFO] Starting com.google.jsinterop:jsinterop-annotations:2.0.0/bundled_js [INFO] Finished com.vertispan.jsinterop:base:1.0.0-1/stripped_bytecode in 471ms [INFO] Starting com.vertispan.jsinterop:base:1.0.0-1/stripped_bytecode_headers [INFO] Starting com.google.elemental2:elemental2-promise:1.1.0/transpiled_js [INFO] Starting com.google.elemental2:elemental2-promise:1.1.0/stripped_bytecode [INFO] com.google.elemental2:elemental2-promise:1.1.0/stripped_bytecode: /C:/workspaces/j2cl/piru/target/gwt3BuildCache/0.19/com.google.elemental2-elemental2-promise-1.1.0/b9a9c421dcc5a5ad53af6450b3f7ae6a-stripped_sources/results/elemental2/promise/Promise.java C:\workspaces\j2cl\piru\target\gwt3BuildCache\0.19\com.google.elemental2-elemental2-promise-1.1.0\b9a9c421dcc5a5ad53af6450b3f7ae6a-stripped_sources\results\elemental2\promise\Promise.java uses unchecked or unsafe operations. [INFO] com.google.elemental2:elemental2-promise:1.1.0/stripped_bytecode: /C:/workspaces/j2cl/piru/target/gwt3BuildCache/0.19/com.google.elemental2-elemental2-promise-1.1.0/b9a9c421dcc5a5ad53af6450b3f7ae6a-stripped_sources/results/elemental2/promise/Promise.java Recompile with -Xlint:unchecked for details. [INFO] Finished com.google.elemental2:elemental2-promise:1.1.0/stripped_bytecode in 131ms [INFO] Finished com.google.elemental2:elemental2-promise:1.1.0/transpiled_js in 136ms [INFO] Starting com.google.elemental2:elemental2-promise:1.1.0/stripped_bytecode_headers [INFO] Starting com.google.elemental2:elemental2-core:1.1.0/transpiled_js [INFO] Starting com.google.elemental2:elemental2-core:1.1.0/stripped_bytecode [INFO] com.google.elemental2:elemental2-core:1.1.0/stripped_bytecode: /C:/workspaces/j2cl/piru/target/gwt3BuildCache/0.19/com.google.elemental2-elemental2-core-1.1.0/4ee56d58cd973f29c315b0e308cfff8c-stripped_sources/results/elemental2/core/JsArray.java C:\workspaces\j2cl\piru\target\gwt3BuildCache\0.19\com.google.elemental2-elemental2-core-1.1.0\4ee56d58cd973f29c315b0e308cfff8c-stripped_sources\results\elemental2\core\JsArray.java uses unchecked or unsafe operations. [INFO] com.google.elemental2:elemental2-core:1.1.0/stripped_bytecode: /C:/workspaces/j2cl/piru/target/gwt3BuildCache/0.19/com.google.elemental2-elemental2-core-1.1.0/4ee56d58cd973f29c315b0e308cfff8c-stripped_sources/results/elemental2/core/JsArray.java Recompile with -Xlint:unchecked for details. [INFO] Finished com.google.elemental2:elemental2-core:1.1.0/stripped_bytecode in 656ms [INFO] Finished com.google.elemental2:elemental2-core:1.1.0/transpiled_js in 1016ms [INFO] Starting com.google.elemental2:elemental2-promise:1.1.0/bundled_js [INFO] Finished com.google.elemental2:elemental2-promise:1.1.0/bundled_js in 53ms [INFO] Starting com.google.elemental2:elemental2-core:1.1.0/stripped_bytecode_headers [INFO] Finished com.google.elemental2:elemental2-core:1.1.0/stripped_bytecode_headers in 61ms [INFO] Starting com.google.elemental2:elemental2-core:1.1.0/bundled_js [INFO] Starting com.google.elemental2:elemental2-dom:1.1.0/stripped_sources [INFO] Starting piru:piru:1.0-SNAPSHOT/bytecode [INFO] Finished com.google.elemental2:elemental2-dom:1.1.0/stripped_sources in 194ms [INFO] Finished piru:piru:1.0-SNAPSHOT/bytecode in 261ms [INFO] Starting piru:piru:1.0-SNAPSHOT/stripped_sources [INFO] Finished com.google.elemental2:elemental2-core:1.1.0/bundled_js in 1174ms [INFO] Starting com.google.elemental2:elemental2-dom:1.1.0/stripped_bytecode [INFO] Starting com.google.elemental2:elemental2-dom:1.1.0/transpiled_js [INFO] com.google.elemental2:elemental2-dom:1.1.0/stripped_bytecode: /C:/workspaces/j2cl/piru/target/gwt3BuildCache/0.19/com.google.elemental2-elemental2-dom-1.1.0/667d0d24e90bada4d4a6a06318e31144-stripped_sources/results/elemental2/dom/DOMRectReadOnly.java Some input files use or override a deprecated API. [INFO] com.google.elemental2:elemental2-dom:1.1.0/stripped_bytecode: /C:/workspaces/j2cl/piru/target/gwt3BuildCache/0.19/com.google.elemental2-elemental2-dom-1.1.0/667d0d24e90bada4d4a6a06318e31144-stripped_sources/results/elemental2/dom/DOMRectReadOnly.java Recompile with -Xlint:deprecation for details.
[INFO] Finished com.google.elemental2:elemental2-dom:1.1.0/stripped_bytecode in 1670ms [INFO] Finished com.google.elemental2:elemental2-dom:1.1.0/transpiled_js in 2373ms [INFO] Starting com.google.elemental2:elemental2-dom:1.1.0/stripped_bytecode_headers [INFO] Finished com.google.elemental2:elemental2-dom:1.1.0/stripped_bytecode_headers in 290ms [INFO] Starting piru:piru:1.0-SNAPSHOT/transpiled_js [INFO] Finished piru:piru:1.0-SNAPSHOT/transpiled_js in 51ms [INFO] Starting piru:piru:1.0-SNAPSHOT/bundled_js [INFO] Finished piru:piru:1.0-SNAPSHOT/bundled_js in 34ms [INFO] Starting com.google.elemental2:elemental2-dom:1.1.0/bundled_js [INFO] Finished com.google.elemental2:elemental2-dom:1.1.0/bundled_js in 6077ms [INFO] Starting piru:piru:1.0-SNAPSHOT/bundled_js_app [INFO] Starting final task piru:piru:1.0-SNAPSHOT/bundled_js_app [INFO] Finished final task piru:piru:1.0-SNAPSHOT/bundled_js_app in 1233ms [INFO] ----- Build Complete: ready for browser refresh ----- [INFO] Starting piru:piru:1.0-SNAPSHOT/bytecode [INFO] Finished piru:piru:1.0-SNAPSHOT/bytecode in 162ms at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: java.nio.file.FileSystemException: C:\workspaces\j2cl\piru\target\piru-1.0-SNAPSHOT\piru\piru.js: The requested operation cannot be performed on a file with a user-mapped section open at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92) at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103) at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108) at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:236) at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:484) at java.base/java.nio.file.Files.newOutputStream(Files.java:228) at java.base/java.nio.file.Files.write(Files.java:3581) at java.base/java.nio.file.Files.write(Files.java:3633) at com.vertispan.j2cl.build.provided.BundleJarTask$1.finish(BundleJarTask.java:131)

niloc132 commented 2 years ago

Thanks for the ticket - did you manage to get VS code to be able to make changes again, and if so, did that also fix j2cl:watch?

I might also expect j2cl:build to fail in this case, it will write to the file in a similar way (though not identical, unless you specify optimizationLevel=BUNDLE_JAR).

starklord commented 2 years ago

I am only available to make changes if i stop jetty;run , but to watch the changes i have to run j2cl:watch again cause it stops and i have to kill the process. I tried running vs code and command prompts with Administrator role but the scenario keeps the same

niloc132 commented 2 years ago

I'm not quite sure I follow, but it sounds like jetty might be "locking" the files that j2cl:watch is creating. I'll see if we can change the jetty configuration, if I missed some other option that must be set in the archetype to get jetty to behave.

treblereel commented 2 years ago

@niloc132 i have never faced this issue, maybe because i use linux. But if it's a problem my suggestion to remove jetty and tomcat from archetype at all

niloc132 commented 2 years ago

@starklord can you confirm that this only happens with the "simple" archetype, and never with the "servlet" archetype? If so, we have a workaround already in place with the servlet archetype (the context.xml file and the reference to it from the pom) that I can copy into the simple archetype too.

starklord commented 2 years ago

@niloc132 this happens with the two archetypes(simple and servlet) they have the same problem.

niloc132 commented 2 years ago

Thanks, so that suggests this isn't fixed by org.eclipse.jetty.servlet.Default.useFileMappedBuffer to false, or we're setting it wrong. Based on comments at https://github.com/eclipse/jetty.project/issues/2925, we're probably setting it wrong.

From that thread, https://github.com/eclipse/jetty.project/issues/2925#issuecomment-436215138 looks like another, possibly better way to set it. It looks like as a result of that issue, they made some doc changes around this https://github.com/eclipse/jetty.project/pull/3061/files.

Could you try these out to see if there is another jetty workaround that fixes it on windows for you? We can incorporate that into the archetypes to generally handle this.

ARMistice commented 2 years ago

I found a solution for Windows File Locking Problem.

Just add the lines:

<_initParams>false

in the tag:

     <webApp>
            <_initParams>
            <org.eclipse.jetty.servlet.Default.useFileMappedBuffer>false</org.eclipse.jetty.servlet.Default.useFileMappedBuffer>
        </_initParams>

        <resourceBases>
          <!-- Serve static content without copying from src/main/webapp -->
          <resourceBase>src/main/webapp</resourceBase>
          <!-- Serve compiled JS built by J2CL -->
          <resourceBase>${project.build.directory}/${project.build.finalName}</resourceBase>
        </resourceBases>
      </webApp>

and it works.

niloc132 commented 2 years ago

Thanks @ARMistice - can you (and/or @starklord) try out this PR to confirm it works? I just tested both archetypes on windows 10 and it seems to solve the bug.

https://github.com/Vertispan/j2clmavenplugin/pull/180

ARMistice commented 2 years ago

For me it works fine, but I am also on Win10. Thanks @niloc132