Anybody using Ringojs with Spring Boot?

78 views
Skip to first unread message

Darren Cruse

unread,
Jan 8, 2016, 5:08:12 PM1/8/16
to RingoJS
I have prior (good!) experience with ringojs where we included it in a WAR along with Spring MVC...

And I just started looking at possibly including ringojs into a new project - one that's already started using Spring Boot with embedded Tomcat.

I don't see any reason it shouldn't work right?  As long as I can setup the ringojs servlet in Spring Boot it should work right...

Anybody see any problems with the idea?  (I know ringojs was developed under jetty but it should work with tomcat too right?  or is that a risk would I be better with jetty?)

And anybody out there actually tried it?  (I googled "ringojs spring boot" btw but came up empty)

Thanks,

Darren

  

Philipp Naderer

unread,
Jan 10, 2016, 4:40:54 PM1/10/16
to rin...@googlegroups.com
Hi Darren!

I looked for my master’s thesis at Spring Boot for a very short time. Since it was not possible to use it inside the sandboxed App Engine runtime, I dropped the approach early. If a framework supports the Servlet API, the Ringo JSGI servlet can always be the target for a request. Therefore, it should be easy to route traffic to a Ringo application in the context of Spring Boot.


Distinti saluti,

Philipp


--
You received this message because you are subscribed to the Google Groups "RingoJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ringojs+u...@googlegroups.com.
To post to this group, send email to rin...@googlegroups.com.
Visit this group at https://groups.google.com/group/ringojs.
For more options, visit https://groups.google.com/d/optout.

Darren Cruse

unread,
Jan 10, 2016, 5:46:08 PM1/10/16
to RingoJS
Thanks Philipp,

Yeah I worked on this yesterday and this morning - using the Ringo JsgiServlet from within this Spring Boot app - and it's gone pretty well I do have it working.

The biggest problem I've run into is the project is configured to create an executable jar using embedded Tomcat, and it seems no matter what I do the ringojs "WebappRepository" cannot see the server side javascript files bundled inside the jar file.

I'm suspecting it's for the same reason there's apparently issues using JSPs inside these executable jar files see e.g. this

I figured out though if I configure the servlet's ringo home and module path with full paths to my files on the file system it automatically fails over when it can't find them in the jar to instead find them on the file system (using the "FileRepository").  

So this is working for me now and has been enough for me to move forward.

Another thing kind of interesting is before I understood what was happening, I also noticed that when it couldn't find the .js files via either the "WebappRepository" or the "FileRepository" it was also trying a "ZipRepository". 

But strangely, even though jar files are really zip files, and even though the path it showed to and within the zip (jar) looked correct, even that wasn't working.  

So right now having the ringo server side .js files externalized outside the jar on my file system is literally the only thing I've been able to get to work.

Unless I figure that out I guess I won't be using the executable jar I'll have to switch things over to using a regular WAR.  That's a little disappointing I think part of the appeal of spring boot is going back to the simple deployment of just a single file with no container...

But otherwise it's working fine I even got the debugger to come up this morning - there's a slight trick there in addition to the servlet "debug" setting you have to disable headless mode via like:

      java -Djava.awt.headless=false -jar myproject-0.1.0.jar 

Posting some of the above in case it's of interest to others.  If anybody's super interested and wanted to do this too, if people post here I'll consider doing a pull request (e.g. there's some docs on the ringo site about spring with ringo, I was thinking I could offer to contribute a section on spring boot if people were interested - but I'll wait to hear there's interest before going to the trouble :).

Darren

Darren Cruse

unread,
Jan 16, 2016, 12:09:57 PM1/16/16
to RingoJS
If anybody has ideas about this problem it's my biggest problem going forward I'd love some thoughts or suggestions:

The biggest problem I've run into is the project is configured to create an executable jar using embedded Tomcat, and it seems no matter what I do the ringojs "WebappRepository" cannot see the server side javascript files bundled inside the jar file.
 
Maybe it is an actual shortcoming of these executable jars (i.e. I was surprised when I learned even JSPs can be a problem in executable jars), but I'm not sure that's really the case (JSPs are so popular it's a little hard for me to believe that's the case).

I'm hopeful there's a way for this to deploy as an executable jar containing the ringo server-side js files bundled inside it, and not be forced to change to it to being a war, or at the very least to only have to change it be an "executable war" as opposed to a war deployed in a standalone tomcat.

Yet even how to set up an "executable war" doesn't seem super well documented from what I can find from googling on spring boot.  There is some stuff that I tried but it didn't work (I *think* maybe you do have to switch back to some older school stuff e.g. adding a web.xml file - yet any docs I've found did not actually say that, but otoh it didn't work for me without one).

Happy for any thoughts,

Darren

  

Darren Cruse

unread,
Jan 16, 2016, 10:32:35 PM1/16/16
to RingoJS
If anybody's following along...  fyi I did get past my problem I'm now able to read the ringo .js files out of the bundled spring boot executable jar.

It appears the ZipRepository (which is automatically tried by ringo after the WebappRepository and FileRepository's fail) is the answer.

I only realized this after wasting time trying to get the WebappRepository to work but failing (it confused me when I tried to test using an expanded jar and thought I had it working only to realize the exact same configuration that worked with the expanded jar would fail under the jar'ed up version of the same setup).

It turns out the ZipRepository does work fine though - in retrospect it was close to working from the beginning but I'd neglected to include ${ringo.home}/modules and ${ringo.home}/packages (I have stick under packages) in my module path.

So in my final working setup I've moved my "ringo" root directory under src/main/resources/static and with the following in my spring boot application.properties file the ZipRepository picks everything up fine:  

ringo.home=static/ringo

ringo.modulePath=.,${ringo.home},${ringo.home}/modules,${ringo.home}/packages,${ringo.home}/app,${ringo.home}/common/middleware,${ringo.home}/common/modules,${ringo.home}/common/thirdparty


(I should clarify I've made a little "RingoServletRegistrar" class that registers an instance of the JsgiServlet as a bean with the init params drawn from application.properties such as the above).


Again, if anybody's interested in using ringo with spring boot like this let me know and I'll consider doing a pull request with what I've done.  You can post here or if it's been a while you might have better luck emailing me at darren...@gmail.com.


Fwiw in my case it's an angular front end talking to a spring boot/ringo backend, exchanging json messages via ajax.  


Darren


Reply all
Reply to author
Forward
0 new messages