Skip to content Home Downloads Java PDF Library PDF to HTML5/SVG Help Forums IDR Shop Blog Tutorial: Setting up Glassfish On a Linux Server Leave a reply 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. In this article I will take you through the steps I took to set up Glassfish and deploy an application with it. Ill be using Ubuntu Server 12.04.4 setup on a local virtual machine, but Ive also used the same methods on CentOS servers so its fair to say this will work in most major distributions of Linux. Installing a JDK from Oracle To download the most recent JDK from Oracle you cant simply use wget to fetch the jdk directly. My initial idea was to just download the jdk to my desktop and use Secure Copy (scp) to copy it over to my server. The issue with this option is that it isnt as viable an option on Windows as it is on Linux or Unix, due to the lack of a built in scp function. However, Irani over on StackOverflow has provided a better solution which uses wget with a specific cookie. So in your SSH terminal type the following: wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux- x64.tar.gz Now we need to extract the compressed JDK into a folder. Type the following command: tar xzf jdk-7u51-linux-x64.tar.gz This will extract the JDK into a new directory (in this case called jdk1.7.0_51). Remember the location of directory, it will be important in the next step. Setting up Glassfish Luckily, downloading Glassfish is a lot simpler than the JDk. Type into the terminal: wget http://download.java.net/glassfish/4.0/release/glassfish-4.0.zip Once downloaded, it needs to be extracted with unzip: unzip glassfish-4.0.zip You should now have a directory called glassfish4, The next step is to associate the JDK we downloaded previously with Glassfish itself. To do this, we need to edit the file asenv.conf which is located in glassfish4/glassfish/config/. 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" Save the changes and exit your editor. Now we can start the server, navigate to glassfish4/bin and run the following command: ./asadmin start-domain Your server has now started, to check if its working you can go to your servers IP address or URL with the default Glassfish port 8080. You should see a page similar to the following:
Deploying an Application Now the server is up and running, we can deploy our application to glassfish. For the sake of simplicity, Ill be uploading the compiled war file from our server example, which you can find on Github. We have two options to deploy our application. The first is to use Secure Copy (scp) to copy the application to the server and deploy via command line. The other is to enable remote admin and upload it via Glassfishs web interface. Both of these are viable options so Ill explain both. Via Command Line The first step is that we need to copy the war file to the server. *nix based computers have scp natively available via the command line, for Windows youll have to search around for a program that can emulate the functionality. In a terminal window insert the following: scp /path/to/application.war username@server.location.com:~ Once its 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): ./path/to/glassfish4/bin/asadmin deploy --contextroot "/pdf2html5" /path/to/application.war Now if we navigate to our server in the browser, we can see the application is succesfully deployed:
Note that the port is only 1080 because Im using port forwarding between my desktop and the virtual machine. Usually itll be 8080. Via the Web Interface Glassfish also comes with a web environment which gives you a graphical interface to work with. However for security reasons its disabled by default. To enable it, you must first set a password for the admin account type: glassfish4/bin/asadmin change-admin-password Youll be prompted for the admin user name (which is admin by default), then the current password (which is blank by default so just press enter) finally youll be asked to enter your password and confirm it.
Now thats a password is set you can enable the remote admin, type the following and then enter the admin name and password: ./asadmin enable-secure-admin
Now restart the server with the following: ./asadmin restart-domain Now we can access the web interface, go to your servers address with the admin port on the end (4848 by default) and you should see a login window, enter your admin username and password to log in. From here select Applications from the bar on the left.
Then select Deploy.
Press the choose file button and select the war file you want to upload, you can also optionally select the context path.
Finally press OK and the file will be uploaded and deployed. And there you have it, you now have Glassfish set up on your server and your application is good to go. This post is part of our GlassFish Articles Index series. In these articles, we aim to explore Glassfish in different ways, from useful tutorials, to JaveOne and general. If youre a first-time reader, or simply want to be notified when we post new articles and updates, you can keep up to date by social media (Twitter, Facebook and Google+) or the Blog RSS. Related Posts: Tutorial : How to Create a Border Glow Effect in JavaFX Tutorial Calling Java from a Bash Script The Definitive list Run-Deploy-Stop all the major Java Application Servers Choosing a Java Application Server Adding Google Analytics to Web Content The following two tabs change content below. Bio Latest Posts
Simon Lissack Developer at IDR Solutions Simon Lissack is a developer at IDR Solutions, working on JavaFX, Android and the Cloud Conversion service. This entry was posted in GlassFish, Linux, Tutorial and tagged GlassFish, servers, tutorial on February 26, 2014 by Simon Lissack. Post navigation PDF XFA File Processing Handling Arc elements Tutorial : How to Create a Border Glow Effect in JavaFX Leave a Reply Search for: Try our Software click here to learn more about the Java PDF Library and click here to learn more about the Java PDF to HTML5 Converter. Follow Us Twitter Facebook Google+ Youtube Blog RSS Newsfeed RSS Subscribe to the Blog Follow Mark Stephens and the JPedal team and their adventures with Java and PDF development. Email Address
Categories Adobe (30) Android (7) Book Reviews (6) BOS conference (24) Cloud (10) Conferences (23) Eclipse (14) Extraction (53) Fonts (50) Forms (19) GlassFish (21) Guest Blogger (4) Guide (29) HTML (163) http (2) Idea (7) Image (69) Java (187) JavaFX (52) JavaOne (52) JavaScript (18) Linux (4) Mac (5) NetBeans (49) News (62) Online Conversion (15) Open Source (22) Opinion (191) PDF (248) PDF forms (25) PHP (1) Plugin (10) Podcasts (8) Print (12) Search (13) Series Index (12) SVG (31) Text (35) Tutorial (15) Uncategorized (19) Version Control (8) Viewer (36) Web Services (7) XFA (7) Top Articles & Pages My Views on Female Programmers in the IT Industry Tutorial : How to Create Stacked Menus in JavaFX 5 Java Formatting options in NetBeans you probably missed Understanding the PDF File Format: Overview 4 ways to convert PDF to HTML5 Replacing the deprecated Java JPEG classes for Java 7 Printing PDF files from Java Understanding the PDF file Format PDF Xref tables explained Setting up VisualVM in under 5 minutes The easy way to discover if a PDF file contains 'structured content' Copyright IDRsolutions 2014
Mingetty's Blog Technical blog covering topics about Linux/Unix troubleshooting,technologies and security by mingetty & Revion.com - Premier Oracle, Oracle apex hosting Tuesday, November 6, 2012 Installing Glassfish server on Linux Installing Glassfish server on Linux
This installs it into: /usr/java/jdk1.7.0_05 ? You can check where files are with the commands:
rpm -ql jdk-1.7.0_05-fcs.x86_64|more
In rhel/fedora you can either remove dummy java symlink or point to your actual install. I am talking about:
/etc/alternatives/java
ls -la /etc/alternatives/java lrwxrwxrwx 1 root root 46 2011-09-05 18:46 /etc/alternatives/java -> /usr/lib/jvm/jre-1.6.0- openjdk.x86_64/bin/java rm /etc/alternatives/java rm: remove symbolic link `/etc/alternatives/java? y ln -s /usr/java/jdk1.7.0_05/bin/java /etc/alternatives/java ls -la /etc/alternatives/java lrwxrwxrwx 1 root root 30 2012-06-13 10:45 /etc/alternatives/java -> /usr/java/jdk1.7.0_05/bin/java java -version java version 1.7.0_05?
Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)
Lets take care of symlink for our JAVA_HOME ln -s /usr/java/jdk1.7.0_05 /usr/local/java ls -la /usr/local/java lrwxrwxrwx 1 root root 21 2012-06-13 10:44 /usr/local/java -> /usr/java/jdk1.7.0_05
2. Download glassfish server for Linux:
chmod +x ogs-3.1.2-unix.sh
*Please note* if you are planning to bind to ports < 1024 you need to run it as root, otherwise any local/Kerberos user is fine. Theres also a workaround to bind to port 80. You can contact me for more info.
sh ./ogs-3.1.2-unix.sh
Unfortunterally, by default it requires X windows. There are command line options available too, however I do have vnc and this is the method I chose to install. You would have to vnc as oracle into your server. You can check my Enabling VNC server on Linux as 1,2,3 quick guide.
Once GUI opens up just follow on-screen instructions Glassfish is installed in : /usr/local/glassfish3
I created stop and start scripts:
cat stop.sh
bin/asadmin stop-domain domain1 cat start.sh
nohup bin/asadmin start-domain verbose &
At this point you can launch firefox locally and point your browser to: http://localhost:4848
Posted by Tim Davis at 1:31 PM Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest Labels: Installing Glassfish server on Linux Location: NYC, New York USA No comments: Post a Comment Newer Post Older Post Home Subscribe to: Post Comments (Atom) About Me
Tim Davis View my complete profile about me [ expanded ] Working with Unix/Linux, Oracle, Clustering and CORE services technologies since 1999 prompted me to start my blog to assist other curious minds. Social Line: Openness, enthusiasm and individualism are the main traits. Ambitious, with lots of drive and a strong will to lead. Poor follower. Fiercely independent, usually take the side of the underdog in any controversy. Champion of lost causes and losing battles. This trait is due to a strong belief in own abilities to turn any situation around. I also would like to thank fygrave [ Fyodor ] for helping me get off to a good start in around 1997. Blog Archive 2014 (1) 2013 (3) 2012 (7) o November (7) VSFTPD logging incorrect timestamp Luns policy round robin esxi Installing Glassfish server on Linux Install and configure Apex Listener with Glassfish... How to configure CSR for Jboss Enabling VNC server on Linux How to restart the Veritas Enterprise Administrato...
Followers Popular Posts Install and configure Apex Listener with Glassfish server So this suppose to be very thorough tutorial with print screens. Unfortunately, images were lost during migration :( here you go anyway! ... Installing Apex Listener 2.x In this example i am installing Oracle Apex Listener 2.x and integrating into Glassfish 3.2. This article only covers installing listener ... Installing Glassfish server on Linux Installing Glassfish server on Linux 1. Install SDK http://www.oracle.com/technetwork/java/javase/downloads/jdk7- downloads-1637583.html ... How to restart the Veritas Enterprise Administrator and Storage Agent Its no doubt sometimes using VEA to connect and manage VERITAS Volume manager is handy. All of a sudden I ended up getting error... couldn't add command channel 127.0.0.1#953: address in use Spent sometime around this error using chroot bind 9.x couldn't add command channel 127.0.0.1#953: address in use Guys, assuming you... VSFTPD logging incorrect timestamp Bumped into wrong time stamp in xferlog today. for some reason vsftpd has timezone of it's own & does not follow OS timezone... Th... Enabling VNC server on Linux Enabling VNC server on Linux as 1,2,3 Enabling VNC server on Linux as 1,2,3 ( quick and dirty way) for oracle user on RHEL/Fedora: In ... (no title) How to redirect in Glassfish server 3.x URL Redirection Within a Domain You can use the url-prefix element of the redirect_ property... How to configure CSR for Jboss Its often provided by good quality CA. How to configure 2048 bit CSR for Jboss step 1: create keystore: keytool -genkey -alias myali... Luns policy round robin esxi This article describes how to set policy for path selection to Round Robin ( default is Fixed) via command line. Doing it via Vsphere GUI c... Subscribe To Posts Comments Simple template. Powered by Blogger.