OpenShift upload jar and run it - java

Hi there I have a simple jar that works like a server, can I upload it to my OpenShift account and run it ? How by the way ? Thanks alot in advance.

You might need to provide a few more details. If you want to upload a .jar file and have it run, you will need to add it to your git repository and then create an action hook that runs the .jar file (java -jar /path/to/file.jar &) and then do a git push. if you want to include the jar file for your .war web application to use, you can check the KB articles section of the openshift website for examples of how to do that.

Only port 8080 on a specific IP is exposed to the outside world. Check the docs for the environment variables such as ${OPENSHIFT_DIY_IP} and ${OPENSHIFT_DIY_PORT}. (Note the public connect via port 80 but they are connecting to the openshift infrastructure which forwards to your app running on port 8080.)
An example of running a jetty server as a jar is given at https://stackoverflow.com/a/33114072/329496 which builds a WAR file then has a start script which runs jetty as a JAR assigning the host and port using those environment variables.
To be honest if you are building a JAR and pushing it to the server you could use just use Amazon Web Services to get a host without any added extras. OpenShift is PaaS (platform as a service) whereas Amazon Web Services is IaaS (infrastructure as service). If all you need is linux and java that is very well supported with any IaaS. They also have less restrictions on a raw linux virtual machine such as being able to run on port 80. As an example I used to build JARs to run on OpenShift but they don't have full support for websockets (you have to use a high port which is not acceptable to many corporate web proxies). So I moved over to AWS and it was very easy to get things running there.

Related

How to deploy java vertx server on linux?

i have made a java server that uses vertx, eventbus, and socket. The client connects to it using javascript. But all of this works locally, How can i deploy this software on a linux server so people online can use it?
you should build a jar file and deploy that on the server. Then start the file with
java -jar filename.jar
I don't know the context of your application, but it may be necessary to create a web server to let others connect to your application.

Disable or hide "ejb-timer-service-app" on Glassfish/Payara

Running a stock Glassfish or Payara Server there is a default application deployed called "ejb-timer-service-app" which includes a web frontend at http://localhost:8080/ejb-timer-service-app/timer
More information here: https://docs.oracle.com/cd/E18930_01/html/821-2418/beahw.html
Sadly the frontend is not reachable over the protected admin console (port 4848) but over the main host (port 8080 and 8181). So everyone knowing my server URL can access this page.
Is there a way to deactive the app (not the ejb-timer-service itself) or at least make the frontend-page no longer accessable (hide it) without some fancy firewall or loadbalancer configurations?
Apparently there is currently no way to disable the application out of the box. I requested a new features for payara over at github: https://github.com/payara/Payara/issues/1803
Because the ejb-timer-service-app.war is required for the application server in order to provide the EJB timerservice it can't be deleted.
However I've created a workaround to at least disable the frontend part:
I did some quick tests locally on how to remove the frontend without
damaging the EJB timer-service. Here is what I've changed inside the
${PAYARA_HOME}/glassfish/lib/install/applications/ejb-timer-service-app.war:
Delete file WEB-INF\sun-web.xml
Delete file WEB-INF\web.xml
Delete folder WEB-INF\classes\com
Shell commands:
zip -d ejb-timer-service-app.war "WEB-INF/sun-web.xml"
zip -d ejb-timer-service-app.war "WEB-INF/web.xml"
zip -d ejb-timer-service-app.war "WEB-INF/classes/com/*"
If the domain has been started before you also have to delete the folder
glassfish\domains\domain1\applications\ejb-timer-service-app to clean up the already deployed frontend.
After a domain restart the servlet at
http://localhost:8080/ejb-timer-service-app/timer is no longer
available (HTTP 404) nevertheless the EJB timers are working properly

Add Remote Glassfish server to Netbeans

I am a .NET Developer trying to learn Java. I have created a simple CRUD based EJB application and it works in Netbeans.
I am trying to add a remote Glassfish server (installed on another PC) to Netbeans so that I can deploy the application (EJBs) from Netbeans. Think of the remote server as a live server (though it is not).
Is it possible to add a remote Glassfish server to Netbeans 7.4. It only seems to allow you to add a local instance.
Assuming you have done asadmin enable-secure-admin (etc) on your remote server, the only way I have found is to remotely mount the (physical) server and then you can point Netbeans at the glassfish directory on the remotely mounted server.

Running a Java project remotely

I've got this new project at work. We are using Eclipse for the project. There are two run configurations, server and client. I have to launch the server and the client independently, and connect to the server using the client. Now, it so happens that this has to be done on both Windows and Linux. (four possible combinations: WS-LC, WC-LS, WS-WC, LS-LC, where W-windows, L-linux, C-client and S-server)
I have Linux on my machine (in which Eclipse is running) and run Windows on a VM. Is there a way I can make Eclipse launch the application in the VM?
I understand I have to build the application locally to a shared folder and send a launch command to windows (using openssh?, not sure). What are the best practices used in this scenario.
EDIT: I need to use this during development, to test my changes to the code. The same application provides both client & server. (yes, horrible, i know :X )
You can publish the server functions as JMX Beans using the MBean interface standard. Then use JMX Console to remotely connect to the server JVM and launch the application.
Eclipse has integration points for remote servers, look to "tomcat configuration" for an example of how it integrates with one remote server.
Whether your application can use an existing server integration solution or not depends heavily on details which aren't present. If you want to actually launch a stand-alone Java process from your remote machine, you generally need a program to capture the request and launch the process.

What is Tomcat Running?

I'm trying to see if a WAR I just built is even running inside of Tomcat (7.0.19). I am deploying to a linux box and so my only two options are the Tomcat admin console (web app) or, hopefully, determining webapp status through the terminal.
I already know how to get in through the console web app; I am wondering if there is any way to see the status (ACTIVE/INACTIVE/TERMINATED, etc) of deployed web apps from the terminal.
Thanks in advance.
PSI-Probe is a great application for monitoring your applications deployed to a tomcat instance. It will tell you if an application is running or down. If the application is not deployed, it will simply not be in the list.
curl --user user:pass http://localhost:8080/manager/text/list
It prints
OK - Listed applications for virtual host localhost
/manager:running:0:manager
/docs:running:0:docs
/examples:running:0:examples
/host-manager:running:0:host-manager
/myapp:running:0:myapp
Your user needs the manager-script role. Documentation: Manager App HOW-TO, List_Currently_Deployed_Applications
You can probably do it using JMX.
Find appropriate MBean that shows this information on local tomcat using regular JConsole. If you want to connect JConsole to remote you will probably have some problems with firewall, so you have other solution.
Take command line JMX client and run it on the monitored host through SSH terminal. I used the following command line JMX client: cmdline-jmxclient-0.10.3.jar
wget http://<username>:<password>#<hostname>:<port>/manager/list -O - -q
(Not sure about Tomcat 7 though)

Categories