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

Jar artifact does not include compiled .class templates #1

Open
damir78 opened this issue Jul 27, 2019 · 3 comments
Open

Jar artifact does not include compiled .class templates #1

damir78 opened this issue Jul 27, 2019 · 3 comments

Comments

@damir78
Copy link

damir78 commented Jul 27, 2019

Hi @iceant

I did tested you nice rocket demo.
Currently if using mvn package - the jar does not include compiled generated tmplate classes (.class) into folder BOOT-INF/classes/templates/ . Ohnly .html files. If I try to start java- jar
` [Request processing failed; nested exception is com.fizzed.rocker.TemplateNotFoundException: Compiled template security/login not found] with root cause

java.lang.ClassNotFoundException: Class security.login not found
at com.pointcx.rocker.spring.boot.starter.reload.RockerClassLoader.loadClass(RockerClassLoader.java:44) ~[rocker-spring-boot-starter-1.2.1.jar!/:1.2.1]
`

It works fine if I start DemoRockerSpringBootStarterApplication directly from IDE (Intellij)

I think the problem is: rocker plugin uses login.rocker.html pattern for compiled files. Now it is just login.html

@damir78
Copy link
Author

damir78 commented Jul 27, 2019

image

@damir78
Copy link
Author

damir78 commented Jul 27, 2019

I've noticed if starting frrom IDE- your rocker-s-b-starter creates @runtime in target/classes the related class like target/security/login.class. But if strarts using java -jar blah.jar you can't create class inside jar file (classpath, etc). I think you should use the default maven plugin from rocker templates to create jar- artifacts

image

@iceant
Copy link
Owner

iceant commented Jul 30, 2019

Hi, @damir78
thanks for feedback.
Rocker had 2 seperated package, compiler and runtime package. compiler will generate source code from template, and runtime only use compiled class from classpath.
I don't like to do configuration in different place, so I moved the configuration from maven pom to application.properties for rocker-compiler.
I need to render .js, .css and other files with difference extension name, only support .rocker.html is not engough for me.
So far, the rocker-spring-boot-starter will check the compiled class first, if it can not find the compiled template class, it will try to compile the template to class. The default implementation in rocker is based on file system. We can not use classpath resource to load as string and compile it to class. It's not easy to do that at runtime. Maybe that's possilbe to modify rocker's compiler to make that happen. But, it will take too much time for me.
What make Rocker so fast? It's compiled template engine. So, at development phase, we can use file system based compiler. After the test, we can package to a jar file, and run it. At runtime, everything is just class.
I don't like the default maven based plugin, it's too complex for me. You need to do configuraiton in pom.xml, and run maven generate-sources everytime the template changed. I would like to change the temlate, then refresh the page, everything is reloaded. It works fine for me. Saved lots of time for me. This feature could have memory issue by using classloader to reload classes. But it's just happend at development phase, I can accept that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants