Skip to Content
Author's profile photo Former Member

Server-side JavaScript on #sapnwcloud

Node.js is getting a lot of attention from web developers and has had an amazing adoption among startups and tech companies.In my company bouvet , we haven’t yet had much enquiries from customers on Node.js, but I am sure it is not far away.

“Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”

10 years ago Server-side and JavaScript was an oxymoron, but now it is all the rage.

I was therefore not surprised when fellow sapmentor Dick Hirsch asked the all important question:

tweet_rhirsch.PNG

Even though SAP NetWeaver Cloud is extremely flexible, it requires that you are able to run the components on top of a Java Virtual Machine(JVM). Node.js runs on the Chrome JavaScript runtime V8 which is implemented in C++ and therefore you’re unable to run it on top of the JVM

However, there exist other similar framework that run on other JavaScript runtimes which are implemented in Java. These are already running on the JVM, and can therefore easily be adapted to run on SAP NetWeaver Cloud.

Here are a few relevant frameworks:

  1. Ringojs
  2. Sprintstack
  3. Narwhal
  4. Helma

All of them use the Mozilla Rhino JavaScript engine, though some of them support other JavaScript engines as well.

The most active and mature of these, appear to be Ringojs (though I am no expert in this area at all).

Let’s have a look at how we can run a Ringojs app with ServerSide JavaScript on SAP NetWeaver Cloud!

Update 22.10: The project is now shared in Github https://github.com/elsewhat/nwcloud-ringojs


How to

Deploying a Ringojs app to SAP NetWeaver Cloud is very simple. This because it has a project template for Java Web applications (tailored for Google App Engine). If you want to learn more about how ringo.js is integrated with the web container, see the JsgiServlet class.

Step 1

Download the ringo.js 0.8 binaries from http://ringojs.org/download and unzip to a local folder

Step 2

Open a command prompt and go to the bin subfolder of ringojs.

Run the command

ringo-admin create --google-appengine /path/to/appdir

where /path/to/appdir can for example be C:\DEV\temp\RingoJSNeo

Step 3

Start eclipse (with SAP NetWeaver Cloud SDK installed)

Step 4

Create new dynamic web project with name RingoJSNeo and use default settings.

For me the path of the project on the files system is C:\DEV\workspace_neo\RingoJSNeo\WebContent\WEB-INF

Step 5

Copy files from the ringojs-created project, to the web project in eclipse.

All files from C:\DEV\temp\RingoJSNeo\WEB-INF should be copied to C:\DEV\workspace_neo\RingoJSNeo\WebContent\WEB-INF

You can overwrite the web.xml without problems (although normally you would merge the files).

Eclipse will indicate a lot of errors in .js files, but you can safely ignore them.

This is how your project will look now:

(on the right you see the main.js that will be executed when an end-user access the web solution)

eclipseringoproject.PNG

Step 7

Open http://localhost:8080/RingoJSNeo in your browser and you should see this screen

/wp-content/uploads/2012/06/browser_ringojsneo_107493.png

Summary

The Java Virtual Machine is a very flexible piece of software and with SAP NetWeaver Cloud you can fully utilize this.

So the next time @hipsterhacker disses enterprise software, tell him SAP runs server-side JavaScript.

tweet_hipsterhacker.PNG

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      RingoJS might provide an easy way to generate an application which can run on netweaver cloud, but when it comes to an alternative to node.js running on the JVM vert.x [1] seems to be more relevant. It is also more active developed [2] than RingoJS[3]. I admit I haven't tried it so maybe you have reasons why you haven't mentioned it in this context?

      [1] http://vertx.io/

      [2] https://github.com/vert-x/vert.x

      [3] https://github.com/ringo/ringojs

      Author's profile photo Dagfinn Parnas
      Dagfinn Parnas

      I haven't look really close into this area, but have only used a few hours to scout it out. You're probably right that vert.x is more actively developed. However, it seems like it doesn't run completely in the JVM, and therefore might not be suitable (needs to be checked more though).

      Dagfinn

      Author's profile photo Former Member
      Former Member

      According to the install documentation you only need additional software if you want to use all the languages [1]. For example if you want to use Ruby you need to install JRuby or Jython for Python. But even that still only uses jvm. I downloaded and checked the startup scripts. And as far as I understand it, they basically configure your Java environment, check your OS, configure your logging and set the optional JRuby/JPython libs. Finally they just startup the jvm with their starter class

           org.vertx.java.deploy.impl.cli.Starter

      and the user defined cmdline arguments, which also contain your vertx application path.

      [1] http://vertx.io/install.html