Let's imagine that your company asked to develop a real-time chat application and wanted it to be finished in hours. Since you already know that it's super duper easy with Node.js, you developed it in Node.js but the company uses Java Application Servers(like WebSphere, JBoss or WebLogic).
So the server administrator expects .EAR files to deploy.
Is there any way to provide an .EAR file that runs your Node.js app behind?
this is so frigging dirty that any sane checks on the released EAR should kill you on place. that being said, yes, it's possible. you have to know a bit of things first.
is the target JVM is enough priviliged to run processes or security on the execute right sufficently lax to enable the JVM to execute shell process by using it's API methods. (i'm talking about Java security, not OS security)
you must know first hand exactly which type of OS the ear container is running on.
the EAR/WAR must be "expanded" to a real filesystem known by the OS.
you must know if the credential under which the ear container have enough privilege to execute a OS command.
once you know exactly those four points, this is no biggie to use the Process java API to execute a Node.js process that the executable (statically linked and OS compatible) is conveniently to a known position...
even as Bruno Grieder said, sharing port is not possible, so you'll just have the web application acting as a front proxy for the "real" application running on Node.js, HTTP or HTTPS being not relevant at all as the final communication between the web application container and the web application itself is no longer encrypted.
awwww... so cute ... :) but, you have to know that using a sneaky method like this in company environment, is not a good thing.
No.
You cannot properly package a "pre-installed" nodeJS inside an ear.
NodeJS installation differs between Windows and Linux; the EAR would not be portable.
On a side note, I would not like to be in your shoes, should the server administrators learn that you are packaging executables not meant to be run on the JVM, inside the EAR.
(note1: as noted in the comments above by #mlan, it would be impossible to share ports between the JVM and nodejs process - faking it would require a fronting reverse proxy dispatching HTTP requests, assuming all traffic is HTTP)
(note2: don't put me wrong, you can put anything in a EAR, including executables that you trigger from Java using ProcessBuilder for instance, but that a last resort workaround)
Related
I have created a java application in intellij ide. The application is working well. Now that my application is ready I want to transfer my java application from my machine to server and make it live. I have one server, domain and all the basic rights in the server. Can any one help me figuring out?
I am very new in this part. I dont know anything about hosting my own website and application.
The answer depends on what technology you use. If you use application that needs to be deploy into servlet container you can deploy it onto e.g. Tomcat.
Whatever technology you use you definiately should build your application - it also depends on what building system you use.
E.g.fFor gradle, you can use gradlew build.
For maven: mvn compile.
Tell us more details about technology you use to allow us to help you.
You have a java application (Dropwizard) and first need a server to run it on, which means that it must be a server with java installed or where you can install it yourself.
Then you need to transfer the application "fat" jar (typically you find this in the target directory, depending on how you built it) to this server and start it with java -jar my-application.jar.
Then you need to make sure that the port that the application runs on is available externally. This usually means that you need to have a web server installed (commonly nginx or httpd) which redirects from port 80 or 443 to the port of your application.
Only then is you app "live".
I am about to start working on a JSF application and I am trying to decide on how to set up my production environment.
I enjoy working off my VPS for production instead of my local host. Is there a way to launch a JSF app to my server and then build on it from there? Or is that not going to work because I have to have a compiler to compile the java each time I update?
If that is the case would it make sense to just install a compiler to the server?
This is my first JSF and real java application so if there is some good info on this please lead me there.
I have someone working with me and I was assuming if we both work of the server it would be easiest.
How would this work in a professional environment, or in other words how would a team working for a company set their environment up?
How it generally works is that each team member has a local installation, and deployments up the chain to servers are handled by the systems admin guys on requests, them being provided with an installation package containing the compiled application (a WAR or EAR file), any other files needed, and quite likely a script with database changes, an installation manual, and things like that.
You should never develop directly on a production server. Only deploy stuff there once it's complete, tested, and verified to be in working order, and secured against attacks.
I have coded a Jersey based java server which is all wrapped in one excecutable jar.
I am looking for a web host service in which i can deploy the jar and run it.
I saw some dedicated servers which can do this but this is overshooting the need, any suggestions?
As per your comment I understand that you created a web application with a Jetty embedded server.
I think the best solution for you in this case is to get a virtual machine host, install JRE, upload your *.jar and run it from there. Given firewall permissions and correct configuration you should be able to receive requests on the 80 port. Cons? It costs. A lot.
Most of the Java hosts have already a servlet container running (almost always Tomcat) and you can only deploy your web application in it. Having an embedded Jetty server messes up everything for you.
I strongly suggest you to detach your web application (or as you called it REST server) from Jetty and deploy the *.war in any of the multiple free Java hosts to test it online.
EDIT
Thanks to you I made a deeper research on the topic and found an interesting guide to deploy a web application with embedded Jetty server in Heroku. I've never tried it nor I know if its free, but maybe you can give a try.
Digital Ocean work pretty well for me. Their basic packages are really cheap and you get root control over your own machine, meaning you can host whatever you want without restrictions. The only downside is that they are pretty old school - you have to set up EVERYTHING yourself, including firewalls etc. There are a lot of guides available on their website though, which makes life a lot easier!
http://www.digitalocean.com
I know this is a touch redundant but I don't have voting or comment rights yet so this is the only method for me to communicate.
Digital Ocean is a solid choice. I am paying 5$ a month for a VM with 512 Mb Ram and 20 gigs of storage (which for my use is just fine.) I am still working on my first proper deploy but as stated above there are tons of tutorials to guide you through it. I have no prior command line experience but I've managed to get the server running, Created an SSH key, uploaded my landing page and have gotten a test project using Spark as the embedded server up and functional in a matter of a few hours. The Droplets are easily scalable from what I've seen. I'm still having trouble deploying an Rest based app with Postgres as the DB but it seems more to do with the ports in play than anything else. Keep getting 404s.
I need to call a jar which is kept on a shared windows machine.
The JVM also needs to be placed on this shared machine so that anyone with access to the remote location should be able to call this jar.
I need to write a windows script which shall be run using a service user.
Is this possible? If yes, request you to please provide pointers.
Java Management Extensions provides the tools for building Web-based, distributed, dynamic and modular solutions for managing and monitoring devices, applications, and service-driven networks.
see JMX Tutorial
see example with Linux script
see Windows cmd script
You might have some luck using the Tanuki Software Java Service Wrapper. Jetty uses this for their Windows Service Wrapper.
Another option is Apache Commons Procrun, which is what Apache Tomcat uses.
Both work well to set up a Java application as a Windows service. You will need to ensure your application is designed to run well as a service; you should be able to "trigger" events (start, stop, restart, etc.). You might need a lightweight adapter around the application to get it to work right as a service; but that should be a trivial exercise.
Once you have a service set up, make sure appropriate user(s) have rights to start/stop the service [1] [2]. You could even set the service up to run using a specific account. Then you can use the net start, net stop, etc. commands in a batch file.
I am currently developing an application for some researchers in my university.It's a small java program that you can use by command line. The next step is to package that program and deploy it to an application server. Some clients program will submit requests to the server who will call the tool that I wrote. Lately, we will add more tools to the server and he has to dispatch the requests to the right tool.
Which application server fits my needs ? I have looked for Tomcat, Jetty and Glassfish but it seems that they are only used for web application.
Is it possible to use those servers in some context different from web context? Which package archive should i use (jar, war) ?
Any advice?
Some clients program will submit requests to the server who will call the tool that I wrote.
The big question is what server-side technology and what communication protocol can you use between the clients and the server. You basically have two major options: HTTP and web services (in that case, consider using either JAX-WS or JAX-RS) or RMI-IIOP and EJBs (in that case, you'll have to use a Java EE compliant server like GlassFish).
I have looked for Tomcat, Jetty and Glassfish but it seems that they are only used for web application.
Not really. As I said, they can also be used for web services oriented applications. And GlassFish can be used for EJBs applications.
Which package archive should i use (jar, war)
The packaging will depend on the type of application you'll write, it's not something that you choose upfront, it's just a consequence. EJBs are packaged in an EJB JAR and typically deployed inside an EAR; Servlet based web services are deployed inside a WAR.
You really need to think about what technology to use first (with the current level of detail, I can't provide more guidance).
Do you even need an application server? There's nothing stopping you from adding the necessary network bindings and deploying it on its own.
Of the servers you mention, you've got 2 different categories: servlet containers and full-stack Java EE servers
Tomcat and Jetty are servlet containers. That doesn't mean that you can only do web stuff with them and you could manually add the required libraries to get a full Java EE server.
Glassfish is a full-stack Java EE server and can be compared with JBoss (both are open source) or the commercial rivals Weblogic and Websphere.
Sometimes this question is simple as the environment you are working in mandates a particular flavour of app server. You should check this first.
If you're not forced to use an app server, I'd ask why you think you need to use an app server?
I don't see why you would want to use tomcat, glassfish or jetty for a command line program.
If it's command-line based, and you want it to run server-side, you could write a little program that allows users to, for instance, telnet to your server, which in turn starts the CLI-application in question, and relays input / output to the client.
You may also want to look into Java Webstart, which makes deployment of new versions a breeze.
Actually we can't answer with so few elements.
- What are you planning to do
- With what technologies
- Where are you planning to host your application (have you got budget?)
- In which language are written the clients (even the future ones)?
- Could clients be on mobile phones (add some technlogy constraints...)
....
It would also be great to know what kind of request the clients will do, and what kind of response the server will provide...
Actually with what you tell us, all those application servers can do what you want...
I have looked for Tomcat, Jetty and
Glassfish but it seems that they are
only used for web application
You could even make a webapplication (servlet) and on the clientside use a httpclient to call that servlet... there are so many options :)
vive Paris!