NoSuchFileException
See original GitHub issueHi,
I’m trying to run your sample in IntelliJIdea, but get this error when I run it: Caused by: java.nio.file.NoSuchFileException: jte/hello.jte
I have this in my pom.xml:
<dependency>
<groupId>gg.jte</groupId>
<artifactId>jte</artifactId>
<version>1.0.0</version>
</dependency>
...
<plugin>
<groupId>gg.jte</groupId>
<artifactId>jte-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<sourceDirectory>${basedir}/src/main/jte</sourceDirectory>
<targetDirectory>${basedir}/jte-classes</targetDirectory>
<contentType>Html</contentType>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>precompile</goal>
</goals>
</execution>
</executions>
</plugin>
And in the main function:
CodeResolver codeResolver = new DirectoryCodeResolver(Path.of("jte")); // This is the directory where your .jte files are located.
TemplateEngine templateEngine = TemplateEngine.create(codeResolver, ContentType.Html); // Two choices: Plain or Html
TemplateOutput output = new StringOutput();
templateEngine.render("hello.jte", 1, output);
System.out.println(output);
How does compiler find template files? What is the path Path.of("jte")
relative to?
Are the .jte
files source or resources?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
NoSuchFileException (Java Platform SE 8 ) - Oracle Help Center
Checked exception thrown when an attempt is made to access a file that does not exist. Since: 1.7; See Also: Serialized Form ...
Read more >How to solve the java.nio.file.NoSuchFileException?
The problem is that your default directory at application startup is not what you think it is. Try adding the following line to...
Read more >How to resolve error java.nio.file.NoSuchFileException
This error occurs most commonly when a file name, directory name or file path has been incorrectly specified when using the file handling ......
Read more >NoSuchFileException - Android Developers
public NoSuchFileException (String file, String other, String reason). Constructs an instance of this class. Parameters. file, String : a string identifying ...
Read more >NoSuchFileException - Kotlin Programming Language
An exception class which is used when file to copy does not exist. NoSuchFileException( file: File, other: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @mahdix, the
TemplateEngine
can now be created so that the application class loader is used. This way it should be possible to bundle templates into the application JAR!At least it worked in my test setup 😃 Here’s a working example: https://github.com/casid/jte/tree/master/jte-runtime-cp-test
TemplateEngine creation is even easier that way!
TemplateEngine.createPrecompiled(ContentType.Html);
And in pom.xml, you’d need to change the target directory to:
<targetDirectory>${basedir}/target/classes</targetDirectory>
Would you mind to check it out and see if this works for you? I’d then release
1.1.0
shortly after.If you want to try it you’d need to change
${jte.version}
in your pom.xml to 1.1.0-SNAPSHOT and build jte locally.To build the jte:
Hope it works! Also, thanks for your suggestion, I really like this new way of running in production 😃
@mahdix I’ve just released
1.2.0
. With this version it is even easier to achieve precompiled templates with application class loader:https://github.com/casid/jte/issues/7
Just in case you’re interested 😃