Fork me on GitHub
#luminus
<
2021-05-28
>
bastilla12:05:53

Random sad note into community space without any intention: I wish I could use Luminus. Alas, so far I didn't figure out how to produce an uberwar. (Supplying a WAR is required by the prod environment. And no, that uberwar plug-in doesn't fly with Luminus.) Well, it is what it is. Time to move on.

tobias00:05:22

Sounds like you've already given up, but if you want to still give it a try then tell me the specific error your encountering and maybe I can help. I've deployed Luminus apps to WAR on Tomcat and Wildfly in the past and it worked OK.

bastilla11:05:54

Hey @UA9399DFZ Many thanks for chiming in and offering a hand here. Actually very much appreciated since I have not totally given up, (still postponed porting all code to Fulcron). I'll pack a sample (Luminus) project - the most basic one possible - and put it on githup. This should minimize your time investment - so you could check the issue within like 2 minutes. Alas today (saturday) my government girlfriend commands me to repair her bicyle first. But I'll get to that asap. I already thank you for posting. It helped lifting my spirit! CU soon...

bastilla10:05:10

Oops..., I wasn't even capable of creating a new luminus project. (Luminus is in full strike mode on my PC, it seems. See paragraph A for details. My actual issue is paragraph B.) A) Even project creation fails now with Luminus templates. I tried all of these:

> lein new luminus luminuswar +re-frame +shadow-cljs +war
> lein new luminus luminuswar +re-frame +war
> lein new luminus luminuswar +war
In case of adding +shadow-cljs I also did:
> lein shadow compile app
All of them resulted in successfull project creation, means I could start the server:
> lein run
...
2021-05-30 11:11:47,796 [main] INFO  luminus.http-server - server started on port 3000
...
BUT here is the issue now. ALL these created projects are mis-configured, it seems:
> wget 
--2021-05-30 11:01:41--  
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:3000... connected.
HTTP request sent, awaiting response... 404 Not Found
2021-05-30 11:01:41 ERROR 404: Not Found.
Same result with Firefox, too, of course. Here comes the funny part. This WORKS and gets me a running web site:
> lein new luminus veryplainluminus
So I suspect the culprit is +war Some version numbers:
> lein -version
Leiningen 2.9.4 on Java 11.0.11 OpenJDK 64-Bit Server VM
> uname -a
Linux 4.4.0-197-generic #229+8.0trisquel3 SMP Tue Dec 1 13:00:01 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
B) My main issue: Luminus WAR files neither run under Tomcat nor Jetty: Luckily I created my server stuff months ago with +war, and it ran successfully in dev mode. I actually really didn't need it since I only deliver Clojurescript code to my customers. But now they urge me to also develop some Java stuff for their servers and Luminus just denies me building applicable WAR files. Some conf details: project.clj
:plugins [[lein-shadow "0.2.0"]
		  [lein-sassc "0.10.4"]
		  [lein-auto "0.1.2"]
		  [lein-uberwar "0.2.1"]]
:uberwar
  {:handler sfprj.handler/app
   :init sfprj.handler/init
   :destroy sfprj.handler/destroy
   :name "sfprj.war"}
When creating the uberwar the build process is doing everything 3 times over. (This is new and wasn't the case when I first tried it months ago.) This is why it's quite a lengthy output. (Sorry to bother you with this log bloat, but this shows I'm not making it up.)
> lein uberwar
lein-shadow - running: npm --version
lein-shadow - NPM version 6.14.12
lein-shadow - running: npm install --save-dev --save-exact [email protected]
lein-shadow - NPM install successful + [email protected] 1 package and audited 9 packages in 1.901sfound 0 vulnerabilities
lein-shadow - running shadow-cljs...
[:app] Compiling ...
------ WARNING #1 -  -----------------------------------------------------------
 Resource: com/cognitect/transit.js:649:8
 variable module is undeclared
--------------------------------------------------------------------------------
nil
[:app] Build completed. (224 files, 0 compiled, 0 warnings, 52.06s)
Compiling sfprj.bundle.create
Compiling sfprj.bundle.csv-to-map
Compiling sfprj.bundle.folder-to-sql
Compiling sfprj.bundle.prep
Compiling sfprj.common-file-helper
Compiling sfprj.env
Compiling sfprj.handler
Compiling sfprj.layout
Compiling sfprj.middleware
Compiling sfprj.middleware.exception
Compiling sfprj.middleware.formats
Compiling sfprj.nrepl
Compiling sfprj.preview.preview-manager
Compiling sfprj.rootmanage.create
Compiling sfprj.rootmanage.writer
Compiling sfprj.routes.home
Compiling sfprj.routes.services
Compiling sfprj.routes.services.graphql
Compiling sfprj.validation
Compile SASS/SCSS files.
sassc -t nested -I resources/scss resources/scss/screen.scss resources/public/css/screen.css

Compiling sfprj.bundle.create
Compiling sfprj.bundle.csv-to-map
Compiling sfprj.bundle.folder-to-map.app-db
Compiling sfprj.bundle.folder-to-map.folder-structure
Compiling sfprj.bundle.folder-to-map.helper
Compiling sfprj.bundle.folder-to-map.id-storage
Compiling sfprj.bundle.folder-to-map.lists
Compiling sfprj.bundle.folder-to-map.objects
Compiling sfprj.bundle.folder-to-map.read
Compiling sfprj.bundle.folder-to-map.sitemap
Compiling sfprj.bundle.folder-to-map.transform
Compiling sfprj.bundle.folder-to-map.type-defs
Compiling sfprj.bundle.folder-to-sql
Compiling sfprj.bundle.helper
Compiling sfprj.bundle.prep
Compiling sfprj.bundle.tmp-style
Compiling sfprj.common-file-helper
Compiling sfprj.common-helper
Compiling sfprj.common-string-helper
Compiling sfprj.common-struct-helper
Compiling sfprj.config
Compiling sfprj.env
Compiling sfprj.handler
Compiling sfprj.helper
Compiling sfprj.layout
Compiling sfprj.middleware
Compiling sfprj.middleware.exception
Compiling sfprj.middleware.formats
Compiling sfprj.nrepl
Compiling sfprj.preview.preview-manager
Compiling sfprj.rootmanage.create
Compiling sfprj.rootmanage.path-manager
Compiling sfprj.rootmanage.reader
Compiling sfprj.rootmanage.writer
Compiling sfprj.routes.home
Compiling sfprj.routes.services
Compiling sfprj.routes.services.graphql
Compiling sfprj.validation
Compile SASS/SCSS files.
sassc -t nested -I resources/scss resources/scss/screen.scss resources/public/css/screen.css

lein-shadow - running: npm --version
lein-shadow - NPM version 6.14.12
lein-shadow - running: npm install --save-dev --save-exact [email protected]
lein-shadow - NPM install successful + [email protected] 1 package and audited 9 packages in 0.688sfound 0 vulnerabilities
lein-shadow - running shadow-cljs...
[:app] Compiling ...
------ WARNING #1 -  -----------------------------------------------------------
 Resource: com/cognitect/transit.js:649:8
 variable module is undeclared
--------------------------------------------------------------------------------
nil
[:app] Build completed. (224 files, 0 compiled, 0 warnings, 48.61s)
Compile SASS/SCSS files.
sassc -t nested -I resources/scss resources/scss/screen.scss resources/public/css/screen.css

lein-shadow - running: npm --version
lein-shadow - NPM version 6.14.12
lein-shadow - running: npm install --save-dev --save-exact [email protected]
lein-shadow - NPM install successful + [email protected] 1 package and audited 9 packages in 0.695sfound 0 vulnerabilities
lein-shadow - running shadow-cljs...
[:app] Compiling ...
------ WARNING #1 -  -----------------------------------------------------------
 Resource: com/cognitect/transit.js:649:8
 variable module is undeclared
--------------------------------------------------------------------------------
nil
[:app] Build completed. (224 files, 0 compiled, 0 warnings, 46.37s)
Compile SASS/SCSS files.
sassc -t nested -I resources/scss resources/scss/screen.scss resources/public/css/screen.css

lein-shadow - running: npm --version
lein-shadow - NPM version 6.14.12
lein-shadow - running: npm install --save-dev --save-exact [email protected]
lein-shadow - NPM install successful + [email protected] 1 package and audited 9 packages in 0.715sfound 0 vulnerabilities
lein-shadow - running shadow-cljs...
[:app] Compiling ...
------ WARNING #1 -  -----------------------------------------------------------
 Resource: com/cognitect/transit.js:649:8
 variable module is undeclared
--------------------------------------------------------------------------------
nil
[:app] Build completed. (224 files, 0 compiled, 0 warnings, 46.81s)
Created /.../sfprj/impl/server/sfprj/target/uberjar/sfprj.war
So, the process (`lein uberwar`) it doing stuff 3 x 47 seconds, where it should end after 1 x 47 seconds. But at least in the end I get a WAR file. Deploying it to tomcat ...
> cp target/uberjar/sjprj.war /home/.../bin/apache-tomcat-9.0.37/webapps
... and running it yields...
> cd /home/.../bin/apache-tomcat-9.0.37
> ./bin/startup.sh
...
Tomcat started.
> wget 
HTTP Status 500 – Internal Server Error

Type Exception Report

Message Wrong number of args (1) passed to: sfprj.handler/app

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

clojure.lang.ArityException: Wrong number of args (1) passed to: sfprj.handler/app
	clojure.lang.AFn.throwArity(AFn.java:429)
	clojure.lang.AFn.invoke(AFn.java:32)
	clojure.lang.Var.invoke(Var.java:384)
	sfprj.listener$_contextInitialized$fn__11.invoke(listener.clj:1)
	ring.util.servlet$make_blocking_service_method$fn__125.invoke(servlet.clj:113)
	sfprj.servlet$_service.invokeStatic(servlet.clj:1)
	sfprj.servlet$_service.invoke(servlet.clj:1)
	sfprj.servlet.service(Unknown Source)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

Note The full stack trace of the root cause is available in the server logs.
Apache Tomcat/9.0.37
Note, the log files don't give any more details. And this is the situation with Jetty.
> export JETTY_HOME=/home/.../bin/jetty-home-11.0.2
> cd /home/.../bin/jetty-base
> java -jar $JETTY_HOME/start.jar --add-module=server,http,deploy
> cp /.../sfprj.war webapps/
> java -jar $JETTY_HOME/start.jar
...
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
...
Caused by: 
java.lang.ClassNotFoundException: javax.servlet.ServletContextListener
Here I experimented with supplying servlet classes within the project (sfprj) but to no avail. I guess, the situation with Jetty is too much a mess. Tomcat at least is having no issues with missing servlet classes and delivers an error message regarding the project itself (wrong arity in a function call). Phew, quite a novel. Sorry! But these are the bloody details. I want to be as constructive and level headed and Commander Data-like as possible. But if I'd be the project lead of a company, Luminus would get a "strike and out!". Alas devs of that project didn't respond back then and will most likely not respond now. Bummer, because actually I really like Luminus approach of micro management. But sadly I have to regard it as "not production ready". I really hope I created that mess myself and someone points it out as being a mere PEBCAK. @UA9399DFZ if you see where I went wrong, I'd really appreciate that.

tobias11:05:54

OK I think I've solved part A. It's a problem with the routes. I'll put up a repo in a minute.

tobias12:05:09

Actually, not a bug. So, when you deploy to Tomcat, each app (i.e. each .war file in the /tomcat/webapps/ directory) us available at a URL with the same name as the app. So, if your app is called luminuswar, then in dev you need to go to localhost:3000/luminuswar/ (trailing slash is necessary). So, if you wget that address it should work. You can also see this if you look at the routes in luminuswar/routes/home.clj you'll see that the top-level route is "/luminuswar" to reflect this.

tobias12:05:02

Unfortunately it looks like this messes up the path of css during dev, so the home page isn't styled properly.

tobias12:05:03

OK, so now I tried building an uberjar and deploying to Tomcat. I get an error too 😞

tobias12:05:19

Might be worth raising an issue on the https://github.com/luminus-framework/luminus-template/. I rarely see Yogthos (the creator of Luminus) in this slack but in the past he's been pretty quick to respond to issues on github.

tobias12:05:22

In the meantime, you can use an old version of the template. When I last used Tomcat it was Luminus template version 3.25. You can create an app from that template with: lein new luminus luminuswar --template-version 3.25 -- +war

🙌 3
🙏 3
tobias12:05:47

I get the feeling that hosting in Tomcat / Jetty is less common these days than it used to be. I always just run a standalone jar. This has the benefit that you can REPL in to your production app, which I don't think you can do with Tomcat / Jetty. But if your client demands a war then I guess that's what you need to go with.

bastilla14:05:09

Hey @UA9399DFZ It's just awesome that you checked those issues so fast! Concerning dev mode and "feature not a bug" you are right, that this indeed works: http://localhost:3000/luminuswar/ ...but is documented differently: https://luminusweb.com/docs/guestbook.html#running_the_application and once I browse to 'home' via menu I get to http://localhost:3000 which is 404. So, food for Yogthos to correct. Concering WAR and tomcat, I really hope --template-version 3.25 -- will save the day. I'll post feedback on this next week since I have to set up / create the whole project again. But this is the most promising approach I had in like an eternity on this issue. Sooo many thanks @UA9399DFZ bows head in deep respect I'll finish this thread the upcoming days (hopefully!)... PS: And you are right, tomcat is outdated technology, but I don't have a choice.

tobias23:05:05

Good luck! In case you end up giving up on Luminus for WAR files and trying to build something from scratch, here's the most minimal example I've found: https://github.com/Igneous/hello-ring-war

tobias23:05:04

It's from this thread (where my username is notsohasty). Looking back I realise that even 9 months ago the +war profile in Luminus was not working. https://www.reddit.com/r/Clojure/comments/ieyc04/running_ten_of_simple_clojure_web_applications_on/

tobias23:05:02

OK, so another stumbling block to look out for: If you try to run lein uberwar on a project generated with Luminus template version 3.25 you might get an error compiling, depending on your version of Leiningen. I had to downgrade to an older version to get it to work. Version 8.25 worked fine. See attached for how to change the version of Leiningen (luckily it's pretty quick to do).

tobias23:05:48

Sorry, typo, I meant version 2.8.3 of Leiningen worked fine.

bastilla07:05:44

Our discussion held me from giving up on Luminus. And 10 minutes ago, I saw that devs discussed this exact issue on github: <https://github.com/luminus-framework/luminus/issues/280> With a final verdict on 16 April from <@U050CBXUZ> that, "_things are mostly working, ..._ [with one] _particular issue ... specific to ring-proxy_". In other words, the new template release should have resolved it BUT my experience this week showed a complete mess with `+war`. If the older template version works, fine by me! But an additional need to downgrade Leinigen as well shows me, this approach might open up a can of worms. I'll study this and the new input you've given me this week. * _Fingers crossed*_ EDIT: ~(Btw, are you sure you got the right link to reddit? It does not seem to be related to this issue at first sight.)~ *Got it now!* Ok, I'll give updates on my story. Thanks, man!!

tobias05:06:10

Well done spotting that issue. I'd searched for "WAR" on the luminus template repo but hadn't thought to search the documentation repo.

tobias05:06:32

Maybe try using version 399 of the template, the one Yogthos pushed out right after the discussion in that issue?