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

Generating site on windows, exception - file referencing incorrect? #463

Closed
chipbite opened this issue Mar 20, 2024 · 12 comments · Fixed by #483 or #517
Closed

Generating site on windows, exception - file referencing incorrect? #463

chipbite opened this issue Mar 20, 2024 · 12 comments · Fixed by #483 or #517
Labels
help wanted Extra attention is needed

Comments

@chipbite
Copy link
Contributor

chipbite commented Mar 20, 2024

Hi! Very interesting tool.
I downloaded and ran this on windows.

It started building the site tree and files, and got pretty far but after a while it throws the exception found here:

java.nio.file.InvalidPathException: UNC path is missing sharename: /\index.html

C:\code\c4-demo-stuff\>"%JAVA_HOME%\bin\java.exe" -cp C:\temp\structurizr-site-generatr-1.1.7\lib\* nl.avisi.structurizr.site.generatr.AppKt generate-site -w space-c4.dsl
space_componentview...
corelib_componentview...
space_containerview...
space_Context...
Exception in thread "main" java.nio.file.InvalidPathException: UNC path is missing sharename: /\index.html
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:118)
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
        at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
        at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
        at java.base/java.nio.file.Path.of(Path.java:148)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.writeHtmlFile(SiteGenerator.kt:206)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.access$writeHtmlFile(SiteGenerator.kt:1)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt$generateHtmlFiles$1$1.invoke(SiteGenerator.kt:119)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt$generateHtmlFiles$1$1.invoke(SiteGenerator.kt:119)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt$generateHtmlFiles$2.invoke(SiteGenerator.kt:173)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt$generateHtmlFiles$2.invoke(SiteGenerator.kt:173)
        at nl.avisi.structurizr.site.generatr.site.SiteGeneratorKt.generateHtmlFiles$lambda$20(SiteGenerator.kt:173)
        at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
        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:290)
        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)

C:\code\c4-demo-stuff\>

I looked briefly into it, but it was a while I coded java and have never coded kotlin, so I figured I'd let someone else with better familiarity look into it. Some file reference error it seems.

ℹ️ Note: The thing is, it has at this point succeeded in generating alot. (But links between the pages are not working at this point, at all.) So, it seems likely that there is a specific problem that is causing the file to not be referenced correctly. It is not failing in general, much has been completed at this point.

BR! /marcus


PS

Executing on windows, and in general

  1. The .bat script does not work (for me and I guess for anyone). The reason is that the classpath statement is too long and it yields and "Input too long" error, immediately.
    So I ran it with a wildcard to lib folder instead, which works fine. The rest of the .bat file is just boilerplate/red tape and does not do anything. So this works, for example (I extracted to a folder in temp):
java.exe" -cp C:\temp\structurizr-site-generatr-1.1.7\lib\* nl.avisi.structurizr.site.generatr.AppKt --help

Maybe the .bat script can be simplified. I could help and propose, if I get past the errors and get it to work... :-)

  1. I have several java versions, and I had to use version 20 for this too work. Version 17 did not work. So, therefore, I had to use %JAVA_HOME% to specify the version and I then actually ran:
"%JAVA_HOME%\bin\java.exe" -cp C:\temp\structurizr-site-generatr-1.1.7\lib\* nl.avisi.structurizr.site.generatr.AppKt generate-site space-c4.dsl

Which was successful in starting execution and started to generate the site.

@chipbite chipbite changed the title Generating site on windows, exception Generating site on windows, exception - file referencing incorrect? Mar 20, 2024
@jp7677 jp7677 added the help wanted Extra attention is needed label Mar 22, 2024
dirkgroot added a commit that referenced this issue Apr 9, 2024
@dirkgroot
Copy link
Collaborator

dirkgroot commented Apr 9, 2024

Hi @chipbite,

Unfortunately I don't have easy access to a Windows machine. I have made a little change that might fix your issue. You can download the binaries containing this change using the following link: potential fix.

Could you try if this fixes your issue? Thanks in advance!

dirkgroot added a commit that referenced this issue Apr 9, 2024
This is a workaround for an issue with the generated .bat file, reported
in #463.

Instead of listing each and every .jar file in the lib directory, we
just use a wildcard to include everything in the lib directory in the
classpath.
dirkgroot added a commit that referenced this issue Apr 9, 2024
@dirkgroot
Copy link
Collaborator

@chipbite I've updated the link in my previous comment to a build that includes the fix from #484.

@chipbite
Copy link
Contributor Author

chipbite commented Apr 9, 2024

Hi @dirkgroot, that is great news! - I have now tried this.

Sadly, I get an error directly when attempting to execute - an error that I did not get before, it seems there is some java version issue...

First I try with java version 20, and then with 17, just to try.
But if I venture and try to interpret the error message, it seems I need to update my java version, since this latest version was compiled with a newer java than I have and will not run with my older versions... maybe? I am again not a java guy during office hours... or other hours for that matter...

BR! /marcus

C:\code\c4-demo-stuff\ipex-architecture\c4-dsl\docs>"%JAVA_HOME%\bin\java.exe" --version
openjdk 20.0.2 2023-07-18
OpenJDK Runtime Environment Temurin-20.0.2+9 (build 20.0.2+9)
OpenJDK 64-Bit Server VM Temurin-20.0.2+9 (build 20.0.2+9, mixed mode, sharing)

C:\code\c4-demo-stuff\ipex-architecture\c4-dsl\docs>"%JAVA_HOME%\bin\java.exe" -cp C:\temp\structurizr-site-generatr-1.1.7\lib\* nl.avisi.structurizr.site.generatr.AppKt generate-site c4-bank-demo-simplified.dsl
Error: LinkageError occurred while loading main class nl.avisi.structurizr.site.generatr.AppKt
        java.lang.UnsupportedClassVersionError: nl/avisi/structurizr/site/generatr/AppKt has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 64.0

C:\code\c4-demo-stuff\ipex-architecture\c4-dsl\docs>java --version
openjdk 17.0.9 2023-10-17 LTS
OpenJDK Runtime Environment Microsoft-8552009 (build 17.0.9+8-LTS)
OpenJDK 64-Bit Server VM Microsoft-8552009 (build 17.0.9+8-LTS, mixed mode, sharing)

C:\code\c4-demo-stuff\ipex-architecture\c4-dsl\docs>java.exe -cp C:\temp\structurizr-site-generatr-1.1.7\lib\* nl.avisi.structurizr.site.generatr.AppKt generate-site c4-bank-demo-simplified.dsl
Error: LinkageError occurred while loading main class nl.avisi.structurizr.site.generatr.AppKt
        java.lang.UnsupportedClassVersionError: nl/avisi/structurizr/site/generatr/AppKt has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0

C:\code\c4-demo-stuff\ipex-architecture\c4-dsl\docs>

@dirkgroot
Copy link
Collaborator

@chipbite This tool needs Java 21 to function. So yes, you need to upgrade 😄.

@jp7677
Copy link
Contributor

jp7677 commented Apr 10, 2024

We don't use Java 21 specific features (yet), just changing https://github.com/avisi-cloud/structurizr-site-generatr/blob/main/build.gradle.kts#L54 to e g. 17 locally should also work if installing JDK21 isn't that feasible.

@chipbite
Copy link
Contributor Author

I have not built the source myself, but looking at the file you reference, @jp7677, it seems there are references to both v 21 and v 17:
https://github.com/avisi-cloud/structurizr-site-generatr/blob/main/build.gradle.kts#L55-L64

kotlin {
jvmToolchain(21)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
java {
targetCompatibility = JavaVersion.VERSION_17
}

Theoretically, would it suffice to edit the jvmtoolchain value to 17 and run gradle?

(I will try adding java 21 to my system as well, I already have a few versions installed... )

@jp7677
Copy link
Contributor

jp7677 commented Apr 10, 2024

@chipbite You need to switch to the fix-exception-on-windows branch if you want to follow the work around I mentioned, main already contains #486

dirkgroot added a commit that referenced this issue Apr 10, 2024
@dirkgroot
Copy link
Collaborator

dirkgroot commented Apr 10, 2024

I've rebased the fix-exception-on-windows branch. Here's a link to the binaries that contain the potential fix and that are compabitle with Java 17.

@chipbite
Copy link
Contributor Author

Tested. I installed java 21 and then it built the site without error ✔️ - with both the binaries you sent April 9th and now April 10th.

So, the error is gone, I run and it builds:

C:\code\c4-demo-stuff\ipex-architecture\c4-dsl\docs>"%JAVA_HOME%\bin\java.exe" -cp C:\temp\structurizr-site-generatr-1.1.7\lib\* nl.avisi.structurizr.site.generatr.AppKt generate-site -w c4-bank-demo-simplified.dsl
Components...

C:\code\c4-demo-stuff\ipex-architecture\c4-dsl\docs>"%JAVA_HOME%\bin\java.exe" --version
openjdk 21.0.2 2024-01-16 LTS
OpenJDK Runtime Environment Microsoft-8905927 (build 21.0.2+13-LTS)
OpenJDK 64-Bit Server VM Microsoft-8905927 (build 21.0.2+13-LTS, mixed mode, sharing)

I also tried one of our own workspaces and the build process completes without error.

Fix works.

The potential fix you have implemented solves this issue, and build runs without error on windows ([Version 10.0.19045.4170]).

Java 17 using binaries from april 10th

I also tried running using java 17 on windows using the rebased binaries and it also completes build without errors.


So, thanks for this, now I got a locally built site... but I found a small link problem when browsing off of disk, #487.

dirkgroot added a commit that referenced this issue Apr 11, 2024
`Path.of` uses OS-specific directory separators to generate a complete
path. This causes the problem reported in #463. This commit changes this
to use the `File` constructor instead of `Path.of`.
@mawid6
Copy link
Contributor

mawid6 commented Apr 25, 2024

@dirkgroot : This issue is still there in the latest release I discovered (a colleague instaled and tested and got the same error).

Should I reopen this issue until it is fixed or open a new issue as a regression?

( Also, thinking about if there could be a github runner to test on win32/64
https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories )

@jp7677
Copy link
Contributor

jp7677 commented Apr 25, 2024

Could you please open a new issue, refer to this issue and also include details about what exactly goes wrong?

@chipbite
Copy link
Contributor Author

Sure, will do. Its the same issue - same exception, like in the OP above.

Exception in thread "main" java.nio.file.InvalidPathException: UNC path is missing sharename: /\index.html

Created a new issue #499 for it.

dirkgroot added a commit that referenced this issue May 21, 2024
Using the same API's that were used in #483 to fix #463.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
4 participants