Run jar file with node js on Microsoft Azure - javascript

I make a node js web app for generating report. My idea is to use .jasper file (jasper report) to generate these reports. I've tried a bunch of node js library to do this, but nothing seems to work. And finally I proceed to make a .jar file (java) to solve this. The process is as follows:
Node js get request from user
Node js run .jar file by using child_process. It run something like "java -jar MyApp.jar arg1 arg2 arg3"
.jar file generate a pdf and save it to a folder
.jar file return the path of newly generated pdf file
Node js get the path and return pdf file to user
It run perfectly in my computer. Then I upload it to Microsoft Azure. It seems like the run .jar file step is failed, because no pdf file is created. Can anyone help me or suggest a better way to do this?

If you deployed the NodeJS webapp into MS Azure WebApps, the step 2 of the process could not spawn a child process for running a jar runnable file because the Java runtime environment not included your current Azure WebApp with NodeJS.
There are three suggested way to do this:
Using Azure VM to install NodeJS and Java, and deploy your app on the VM as the same as on the local computer. It's the simple way.
I searched an open source report software called jsreport. It can be install on MS Azure VM or Cloud Service. You can refer to the download page Run jar file with node js on Microsoft Azure to install it. And there is the jsreport sdk for NodeJS http://jsreport.net/learn/nodejs. If you want to use jsreport on Azure Cloud Service, you need to know how to build NodeJS App on Azure Cloud Service https://azure.microsoft.com/en-us/documentation/articles/cloud-services-nodejs-develop-deploy-express-app/.
Changing your process. NodeJS get request from user and send it with the specified file name and path to the ServiceBus; The jar runnable file modified as a Azure WebJob read the request from the ServiceBus and generate a pdf with the given file name and save it to the given file path on the Azure Blob Storage; NodeJS directly return pdf file to user from Blob Storage.
For Azure WebJob & Service Bus, you can refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/ and https://azure.microsoft.com/en-us/documentation/articles/service-bus-nodejs-how-to-use-queues/.

I suspect that your Java PDF generation calls into APIs restricted by the App Service sandbox. Most PDF rendering engines use GDI+, which has most functionality restricted by the Azure App Service sandbox. However, this policy is relaxed on dedicated servers. Scaling up to a dedicated server should resolve this problem (i.e. not the Shared or Free SKU).

Related

AWS API Gateway Generated SDK does not contain client js file

I have created an API using the AWS Api Gateway Service, and am ready to use the javascript sdk in a simple webpage.
However, the instructions for using the javascript SDK here show an import for a js file called apigClient. I can only assume this is where the client class is stored for the api. However, when I generate the SDK for MY API, there is no such file (as in, the older file in the unzipped folder is lib. There is no js file in the root directory.)
Am I expected to create this file on my own? If so, I did not see any instructions to do so. Are there? What am I missing here?
I had the same problem, and I fixed it by deploying API.
See step4 "Deploy Your API" in this link.
https://aws.amazon.com/getting-started/projects/build-serverless-web-app-lambda-apigateway-s3-dynamodb-cognito/module-4/

node.js command line file excel on web server

My script in node.js generate a excel file, I need to put this file available on web server like web url and people can download it directly. Right now, script generate a excel file and it is available in windows folder. Thanks
If you really want to use nodejs for this you can use something like "static-server" and create a server that will export everything from you'r folder to the "web"..
But much better approach is to do it throught nginx or apache.
You can google with keywords "static [file] server (nginx|apache|nodejs)".

How to make an executable(.exe) that packages a nodejs server? (not UI-centric)

I have implemented a nodejs server that serves incoming requests to use the bluetooth services of the local computer. I want the nodejs server to be packed as an windows executable file so that I can distribute it. People should be able to just install/run that .exe which will install any packages required (if any) and run the server. How to do this?. I saw and tried node-webkit etc., but they are UI-centric, that is it can pack a nodejs application that opens a html page. But I want my server javascript file to be executed, like the way it is done in command prompt : node file-name.js. How to do this?
I've a server running with nodejs and for execute this I use a .bat file.
Create a .bat file
Inside of the file put:
cd path/to/server/
node índex.js
I used JXCore for this task in the past. It basically creates one executable that includes everything.
Unfortunately active development of is halted.
Solution:
You can use nexe for that.
Create a single executable out of your node.js app
Motivation
Ability to run multiple applications with different node.js runtimes.
Distributable binaries without needing node / npm.
Starts faster.
Lockdown specific application versions, and easily rollback.
Faster deployments.

Problems with public directory when deploying Node.js app with Heroku

I've been working on an app which will feature a Timelinejs (open source js library) element on the client side. I copied the Timelinejs library into my public/javascripts/ directory of my app. Then I linked it in my html header. When I serve my app up locally everything works fine with the timeline. However, I noticed that when I deployed my app to Heroku it wasn't loading my timeline. Using chrome js console I discovered that it didn't find my files in the public/Javascripts/Timelinejs folder. Using the Heroku run bash command I discovered that none of my Timelinejs files were present in the file structure, although an empty Timelinejs directory was present. Is there any command or configuration I need to specify to get these files to my Heroku deployment?
Heroku has a readonly file system. The directory where you can write are ./tmp or ./log. You can't write inside the public folder.
That's because of how they manage their dynos and the way to scale them. If you want to store something, use the ./tmp or, recommended, a s3 bucket. (as I presume 'tmp' stands for 'temporary' :D)
More info here: https://devcenter.heroku.com/articles/read-only-filesystem

Running a local server with javascript

I want to create a simple Javascript program with a HTML interface. The program will run in Chrome. I will also use node-serialport and Node.js to comunicate with an Arduino. I have a HTML and JavaScript file done, but I have no clue how to run it, or how to implement Node.js or node-serialport, nor how to "start" the sever. Initially it will only be running locally, but eventually it may become a real sever. For now, how do I run all that locally?
EDIT: I'm using the sample code from http://brandontilley.com/2012/03/02/controlling-an-arduino-from-nodejs.html, with the CoffeeScript converted into JavaScript.
Lucas, glad you found the blog post useful; perhaps I should add this information to it.
Getting the sketch into your Arduino
Just fire up the Arduino application, paste in the sketch code, and hit "Upload." Should be all you need to do here.
Starting the Node.js Server
What operating system are you using this on? Finding out how to access your Arduino microcontroller via node-serialport will differ based on your OS.
In the source code, change the string value of port to be your Arduino's device (once you know it). Also, the script depends on Express and (of course) node-serialport from NPM, so run npm install express serialport in the directory where your JavaScript file is saved. Finally, run the file with node server.js (assuming server.js is the name of your file). Then you can access the server at http://localhost:8080.
You can use node.js to serve up HTML with Express. If your main Javascript file is called server.js, then run it by typing:
node server.js
at the command line.

Categories

Resources