Comments (13)
According to me, this would be an important feature to add to Javalin for it to be a nice backend for SPA development
from javalin.
@PascalLeMerrer For static files you don't need to restart the server, you can either just build (will copy files to jar), or use enableStaticFiles("/path", Location.EXTERNAL)
. If you use an external location, all you have to do is save and refresh.
from javalin.
No, I don't use IntelliJ or Eclipse. I should probably just give in and use an IDE the next time I work on a JVM project.
from javalin.
Hi @geekytime. Unfortunately I don't have any experience with this myself, neither with maven nor with gradle, but I would love to get it working. I was under the impression that you would need something like JRebel or DCEVM though, but maybe this isn't the case? It would be great if you could look into it.
from javalin.
https://github.com/HotswapProjects/HotswapAgent <- might be worth looking into.
from javalin.
@geekytime did you have any success with this?
from javalin.
No. I tried for a few days and then gave up.
Kotlin and Javalin make it pleasant to code a web server on the JVM. Unfortunately, between slow compile/startup times, lack of hot-reloading, and having to deal with maven or gradle; running a web server on the JVM will likely always be an exercise in frustration. đ
from javalin.
@geekytime are you using IntelliJ or eclipse? Rebuild+restart should take less than a second. There is also debug-mode in IntelliJ which should give some (limited) hotswapping.
from javalin.
@ShikaSD @iProdigy do either of you have any experience with this? Or any interest in finding out how we can achieve automatic class reloading?
from javalin.
I notice in this thread you already found HotswapAgent
- but I still thought I'd mention this project I came across which seems to use HotswapAgent to do hot page reloading. Perhaps it can give you a clue ...
https://github.com/kwebio/core/blob/master/src/main/kotlin/io/kweb/dev/hotswap/KwebHotswapPlugin.kt
from javalin.
I found these instructions for "Kweb":
Step 1 : Install Dynamic Code Evolution VM (DCEVM) Java patch
Go to https://github.com/dcevm/dcevm/releases and download the latest DCEVM light installer (DCEVM-light-8u112-installer.jar at the time of writing).
Run the installer by double-clicking on it.
Note for Mac users: You may get an error like âDCEVM-light-8u112-installer.jarâ canât be opened because it is to an unidentified developer, if so you should control-click the file and select âOpenâ to the drop-down menu, then click âOpenâ.
You must now select your Java Development Kit directory. If it isnât already listed click Add installation directory, for example on a Mac it may be /Library/Java/JavaVirtualMachines/jdk1.7.0_121.jdk/Contents/Home.
Click Install DCEVM as altjvm.
When the installation is complete you can quit the DCEVM installer.
Step 2 : Download HotSwapAgent
Go here and download the latest hotswap-agent .jar, (hotswap-agent-1.1.0-SNAPSHOT.jar at the time of writing).
Save it somewhere appropriate, perhaps in a directory called javalibs in your home directory (it doesnât really matter where you put it but youâll need the full path and filename later).
Step 3 : Modify your projectâs run configuration
In intelliJ select Edit Configurations... under the Run menu, and paste the following into the VM Options field:
-XXaltjvm="dcevm" -javaagent:PATH_TO/hotswap-agent.jar=disablePlugin=AnonymousClassPatch
Be sure to edit PATH_TO/hotswap-agent.jar to be the full path and name of the hotswap-agent .jar file you downloaded in Step 2.
Note that =disablePlugin=AnonymousClassPatch was necessary at the time of writing to prevent a non-fatal error, but this bug in HotSwapAgent has been reported and may be fixed by now.
Step 4 : Configure Kweb to refresh webpages automatically
Set the refreshPageOnHotswap Kweb constructor parameter to true:
Kweb(port = 1234, refreshPageOnHotswap = true) {
Most of it looks pretty general. Might have to look at what Kweb does for refreshPageOnHotswap = true
.
Edit: @gkopff hah, thanks!
from javalin.
The Kweb author posted on reddit: https://www.reddit.com/r/Kotlin/comments/8d6afi/kweb_rapidly_build_rich_web_apps_in_pure/ and I PM'd them a link to this issue to see if they were interested in helping out.
from javalin.
Kweb author here, it's been a while since I did the hotswap stuff, it was a bit fiddly but I managed to get it working eventually. @gkopff has already provided the relevant pointers, happy to answer any questions.
from javalin.
Related Issues (20)
- Support for Jetty 12 HOT 7
- Tus server implementation for reliable chunked upload. HOT 1
- Skip static files in DevLogginPlugin doesn`t skip .map files HOT 1
- javalinVue: not able to get LoadableData to work HOT 2
- OpenAPI schema-first generator: issues with order of routes HOT 6
- Register multiple paths for single handler HOT 3
- Is there a way to read the current rate limit. HOT 3
- SpaRoot sending wrong Mime Type HOT 2
- Static files with SSL plugin HOT 1
- Path Parameters Unavailable in beforeMatched HOT 1
- Move javalin-rendering back into main repo HOT 8
- Javalin 7 API redesign HOT 8
- Log or throw exception if user tries to consume uncached request body twice HOT 1
- Provide a way to define custom metadata for each endpoint HOT 2
- Is there a substitute for 5.x Javalin.createStandalone() in version 6.x? HOT 3
- [Question] How to check the size of a file that's uploading and reject it if it exceeds a specifc size on a per URL basis? HOT 4
- Nicer way to optionally get a ContextPlugin extension HOT 6
- WebSocket DeadLock HOT 1
- CORS `IndexOutOfBoundsException` when you pass an `Origin` without a `.` HOT 4
- CORS have option to not do a Http status 400 override if a client `Origin` isn't valid HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â¤ď¸ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javalin.