Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve watch throws java.io.FileNotFoundException on update (windows) #549

Closed
chipbite opened this issue Jun 26, 2024 · 4 comments · Fixed by #632
Closed

Serve watch throws java.io.FileNotFoundException on update (windows) #549

chipbite opened this issue Jun 26, 2024 · 4 comments · Fixed by #632
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@chipbite
Copy link
Contributor

Hi!

Serve watch throws java.io.FileNotFoundException when file change is detected

I start generatr to run locally and it watches for any changes.

It is triggered correctly when a files is updated. But it almost (like 95% of the time) always consistently throws a filenotfoundexception when it tries to act on the change and reload the site.

See output below.

It seems to be a similar file handling issue, to the issue that we saw during startup (now fixed).

Hoping it is an easy fix!

Workaround: Kill and restart generatr server.

Let me know if there is anything other output that I can supply.

Output:

Detected a change in C:\code\c4-demo-stuff\ipex-architecture\c4-dsl\dexf, updating site...
juni 26, 2024 12:14:46 EM com.structurizr.dsl.StructurizrDslParser parse
WARNING: !constant has been deprecated and will be removed in a future release - please use !const or !var instead
Generating index page...
Copying assets...
Writing workspace.json...
Generating diagrams...
Kompis-Account UP-TO-DATE
space_containerview UP-TO-DATE
ipex-landscape1 UP-TO-DATE
space_Context UP-TO-DATE
space_componentview UP-TO-DATE
Kompis-Save UP-TO-DATE
kvadrat_componentview UP-TO-DATE
corelib_componentview UP-TO-DATE
kvadrat_containerview UP-TO-DATE
Context-DEXF-Account UP-TO-DATE
flow-kompis-auth UP-TO-DATE
kvadrat_Context UP-TO-DATE
Kompis-Context UP-TO-DATE
Generating site...
java.io.FileNotFoundException
        at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
        at java.base/java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:542)
        at java.base/java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:567)
        at java.base/java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:670)
        at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:160)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:174)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
        at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
        at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:765)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateHtmlFiles(SiteGenerator.kt:202)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateSite(SiteGenerator.kt:87)
        at nl.avisi.structurizr.site.generatr.ServeCommand.updateSite(ServeCommand.kt:83)
        at nl.avisi.structurizr.site.generatr.ServeCommand.monitorFileChanges(ServeCommand.kt:175)
        at nl.avisi.structurizr.site.generatr.ServeCommand.startWatchService$lambda$12(ServeCommand.kt:147)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.io.FileNotFoundException: build\serve\master\index.html (The requested operation cannot be performed on a file with a user-mapped section open)
        at java.base/java.io.FileOutputStream.open0(Native Method)
        at java.base/java.io.FileOutputStream.open(FileOutputStream.java:289)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:230)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:179)
        at kotlin.io.FilesKt__FileReadWriteKt.writeText(FileReadWrite.kt:141)
        at kotlin.io.FilesKt__FileReadWriteKt.writeText$default(FileReadWrite.kt:140)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.writeHtmlFile(SiteGenerator.kt:239)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateHtmlFiles$lambda$52$lambda$11(SiteGenerator.kt:130)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateHtmlFiles$lambda$53(SiteGenerator.kt:202)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateHtmlFiles$lambda$54(SiteGenerator.kt:202)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
        at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:722)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291)
        at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:754)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
@jp7677
Copy link
Contributor

jp7677 commented Jul 2, 2024

Looks like something (the embedded web server?) is keeping files open and that blocks the generator to overwrite the html file(s). Unfortunately I don't have a windows box close to me for further investigation, so any help is appreciated.

@jp7677 jp7677 added help wanted Extra attention is needed bug Something isn't working labels Jul 2, 2024
@galuszkak
Copy link
Contributor

@jp7677 not sure if this helps at all but Microsoft is providing for development purposes Windows VMs:
https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/

@lhauspie-adeo
Copy link

Is there anything to do to activate the watch mode ?
I'm running the site generator with docker but any change doesn't trigger a new site generation 🤔

@chipbite
Copy link
Contributor Author

Is there anything to do to activate the watch mode ?

No, just the normal serve to start the server. (as per the help section in the readme).

I'm running the site generator with docker but any change doesn't trigger a new site generation 🤔

Not running docker, so not sure how this affects things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
4 participants