path/to/glassfish4/bin/asadmin deploy -contextroot "/pdf2html5" /path/to/application.war In a terminal window insert the following: scp /path/to/application.war it’s on the server, ssh back into your server and type the following (“–contextroot” is an optional flag, but it means we know where out application is being deployed to). *nix based computers have scp natively available via the command line, for Windows you’ll have to search around for a program that can emulate the functionality. The first step is that we need to copy the war file to the server. Both of these are viable options so I’ll explain both. The other is to enable remote admin and upload it via Glassfish’s web interface. The first is to use Secure Copy (scp) to copy the application to the server and deploy via command line. We have two options to deploy our application. For the sake of simplicity, I’ll be uploading the compiled war file from our server example, which you can find on Github. Now the server is up and running, we can deploy our application to glassfish. You should see a page similar to the following: Your server has now started, to check if it’s working you can go to your server’s IP address or URL with the default Glassfish port 8080. Now we can start the server, navigate to glassfish4/bin and run the following command. Using a command line text editor such as vi or nano add the following line to the bottom of the file and change the path in the quotes to match the absolute path to your JDK location: AS_JAVA="/usr/java/jdk1.7.0_51" To do this, we need to edit the file nf which is located in glassfish4/glassfish/config/. You should now have a directory called glassfish4, The next step is to associate the JDK we downloaded previously with Glassfish itself. Once downloaded, it needs to be extracted with unzip: unzip glassfish-4.0.zip Luckily, downloading Glassfish is a lot simpler than the JDk. Remember the location of directory, it will be important in the next step. This will extract the JDK into a new directory (in this case called jdk1.7.0_51). Type the following command: tar xzf jdk-7u51-linux-圆4.tar.gz Now we need to extract the compressed JDK into a folder. So in your SSH terminal type the following: wget -no-cookies -header "Cookie: gpw_e24=http%3A%2F%2F However, Irani over on StackOverflow has provided a better solution which uses wget with a specific cookie. The issue with this option is that it isn’t as viable an option on Windows as it is on Linux or Unix, due to the lack of a built in scp function. My initial idea was to just download the jdk to my desktop and use Secure Copy (scp) to copy it over to my server. ![]() ![]() To download the most recent JDK from Oracle you can’t simply use wget to fetch the jdk directly. ![]() I’ll be using Ubuntu Server 12.04.4 setup on a local virtual machine, but I’ve also used the same methods on CentOS servers so it’s fair to say this will work in most major distributions of Linux. In this article, I will take you through the steps I took to set up Glassfish and deploy an application with it. Setting up Glassfish for our Web Service based PDF converter was a relatively straight-forward job, but there are some nuances to be aware of. ![]() Tutorial: Setting up Glassfish On a Linux Server Simon Lissack Simon Lissack is a developer at IDR Solutions, working on JavaFX, Android and the Cloud Conversion service.
0 Comments
Leave a Reply. |