Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, January 31, 2012

Cron Job to restart Jetty Server

If you have an Java hosting on a virtual server, you normally have limited resources for that. That means you only have a certain amount of RAM. This leads to memory problems when deploying large applications. Restart the server by hand is annoying. Fortunately there are cron jobs. A cron job is a task in Linux which is to be executed at specific times automatically. The simplest way to start a cron job in Linux is to place a shell script below one of the following folders:
/etc/cron.daily
/etc/cron.weekly
/etc/cron.monthly

I intend to show a shell script for Jetty 8 server which is installed in /opt/jetty-distribution-8.1.0.RC2/ (path on my virtual server). The script checks the process id of the running Jetty server, kills it if it was found and restarts the server with the command "nohup java -jar start.jar".
#! /bin/sh

jettyPid='pgrep -f "java -jar start.jar"'

if [ "$jettyPid" != "" ]
then
kill -9 $jettyPid
fi

jettyHome="/opt/jetty-distribution-8.1.0.RC2/"
cd $jettyHome
nohup java -jar start.jar

exit
Alternative shorter variant:
#! /bin/sh

pgrep -f "java -jar start.jar" | xargs -i kill {}

cd /opt/jetty-distribution-8.1.0.RC2/
nohup java -jar start.jar

exit

Friday, December 16, 2011

Install Windows VHDs on Linux for testing websites with Internet Explorer

Need to test websites in multiple Internet Explorer versions under Linux / Mac OSX? No problem. Microsoft created free Windows Virtual PC VHDs with the purpose of allowing web designers to test websites in Internet Explorer 7-9. There is a script ievms simplifying the installation. But before you have to install the latest VirtualBox. You can do this e.g. via Package Manager (Ubuntu), Yast (OpenSuse) or via Linux terminal
 
sudo apt-get install virtualbox-4.1
 
The next step is the installation of VirtualBox Extension Pack. This is necessary for USB 2.0 devices, shared folders, better screen resolution, etc. The best way is to download and install the package for the VirtualBox Extension Pack manually.
 
wget http://download.virtualbox.org/virtualbox/4.1.6/Oracle_VM_VirtualBox_Extension_Pack-4.1.6-74713.vbox-extpack
VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.1.6-74713.vbox-extpack
 
Open VirtialBox tnen and go to File > Preferences > Extensions tab. Click there the "add" button and browse to the VirtualBox Extension Pack. Now you need to install curl (tool to transfer data from or to a server) and unrar (command-line applications for extracting RAR archives). In Ubuntu, install them using the command below.
 
sudo apt-get install curl unrar
 
To download and run the mentioned above script, use the following command in a terminal.
 
curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | bash
 
The above command will download Windows VHDs for IE7, IE8 and IE9. If you only need one specific Internet Explorer version, e.g. IE9, you can run:
 
curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS="9" bash
 
At this point, the download will start and it will take a while. The VHD archives are massive and can take hours to download. Each version is installed into a subdirectory of ~/.ievms/vhd/. At the end you can delete the downloaded archives (*.exe and *.rar files) below this folder if you want to free up some space. You are ready to test websites in IE7-IE9 now. The password for all VMs is "Password1". The picture below shows a VirtualBox with IE9.


The next picture shows that I set shared folders to exchange data between Windows 7 in VM and my Kubuntu 11.10 (Oneiric Ocelot).


You can start your web application on Linux. But how to access a running web application on Windows (VirtualBox)? Linux has a command tool ifconfig to configure, control and query TCP/IP network interface parameters. Open a terminal and type ifconfig. Find an IP address you Linux mashine is accessible from. I have e.g. 192.168.254.21 for wlan0 interface. You are able to call now
 
http://192.168.254.21:8080/...
 
in Interner Exloper on Windows. The IP address is like a localhost for your web application running on Linix. Remaning part behind this address is the same on both OS.

Saturday, April 30, 2011

Get running Broadcom WLAN under OpenSuse 11.4

I described how I did it in OpenSuse 11.3. OpenSuse 11.4 is shipped with an open source driver brcm80211 on board and you don't need proprietary broadcom-wl-... drivers anymore (downloaded by PackMan) for many new Broadcom cards. Please check this page for compatibility issues before you start with an installation. To see details to the available Broadcom card, use the commando lspci. My output is e.g.:

/sbin/lspci -nnk | grep -i -A2 broad
12:00.0 Network controller [0280]: Broadcom Corporation BCM4313 802.11b/g/n Wireless LAN Controller [14e4:4727] (rev 01)
Subsystem: Dell Device [1028:0010]
13:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller [10ec:8168] (rev 03)

The driver brcm80211 supports BCM4313 and BCM43224, BCM43225, BCM4329 chips. The installation is straightforward.

1) Remove all WLAN configurations in NetworkManager.
2) Install kernel-firmware from a DVD with OpenSuse 11.4. That's is the file kernel-firmware-2.6.38-1.2.1.noarch.rpm. You should see after that all brcm80211 stuff under /lib/firmware/brcm
3) You will see Broadcom WLAN Controller with the device name wlan0 in Yast's Network Settings. All stuff is recognized well. Broadcom WLAN Controller needs a small configuration if you have a WLAN router (my one is FRITZ!Box Fon WLAN 7270). You should set default gateway and input WAP or WEP key for the authentication.
4) Reboot and enjoy the wireless LAN.

Edit: I  was asked whether b43 drivers (for old BCM chips) should be removed. Yes, you can remove b43 and broadcom-wl-... drivers or do them blacklisted (see blacklist config files under /etc/modprobe.d/), so that they are not loaded at all.

Sunday, March 20, 2011

Install Java 1.6 and Tomcat 6 under Ubuntu

I have installed Java und Tomcat on my VPS http://www.fractalsoft.net many times but never noted necessary steps. Here some helpful infos.

1) Issue following command to find out current jdk version in apt-get
apt-cache search jdk

2) Install java JRE with apt-get install
sudo apt-get install openjdk-6-jre

3) Set environment variable JAVA_HOME. Copy following statement and append to /etc/profile or .bashrc
export JAVA_HOME="/usr/lib/jvm/java-6-openjdk;"

4) Install Tomcat 6
sudo apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-user tomcat6-docs tomcat6-examples

5) Change tomcat server to run on port 80 in
/var/lib/tomcat6/conf/server.xml (symbolic link) or etc/tomcat6/server.xml

7) Start tomcat server sudo /etc/init.d/tomcat6 start
Stop tomcat server sudo /etc/init.d/tomcat6 stop
Restart tomcat server sudo /etc/init.d/tomcat6 restart
Get tomcat server status sudo /etc/init.d/tomcat6 status

8) To enable admin web based features add the following lines to
/etc/tomcat6/tomcat-user.xml

<role rolename="manager"/>
<role rolename="admin"/>
<user name="admin" password="admin" roles="manager,admin"/>

Manager app http://www.fractalsoft.net/manager/html has now user / pwd = “admin”.

9) Adjust default Tomcat page below /var/lib/tomcat6/webapps/ROOT/index.html if nessesary.

Edit: If you get this exception
SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.ExceptionInInitializerError
...
Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission com.sun.aas.installRoot read) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:342)
...
and the deployte web application doesn't start, set TOMCAT6_SECURITY=no (instead of yes) in the file /etc/init.d/tomcat6. Restart your Tomcat after that (login via ssh username@hostname and call sudo /etc/init.d/tomcat6 restart). Thanks to this post from ICEFaces forum!

Saturday, November 6, 2010

Install SUN Java-Plugin für Firefox under OpenSuse 11.x

IcedTea-Plugin is the standard Java-Pligin for Applets in OpenSuse. It's provided by openjdk. Some application, e.g. ElstarOnline, don't work with IcedTea and need Java-Plugin from SUN. Steps to install SUN's Java-Plugin:

1) Download SUN's JRE from http://www.java.com/de/download/. Current version is 1.6.0_21.

2) Install it. I've installed it under /usr/local/java/jre1.6.0_21

3) Create the following symbolic link in /usr/lib/browser-plugins/ (root rights are needed)
     sudo ln -s /usr/local/java/jre1.6.0_21/lib/i386/libnpjp2.so /usr/lib/browser-plugins/

4) Start Firefox and go to the Extras --> Add-ons --> Plugins

5) Deactivate IcedTea NPR Web Browser Plugin
    Activate (if not yet activated) Java(TM) Plug-in 1.6.0.21

Sunday, October 3, 2010

Install Dropbox under OpenSuse 11.3

Dropbox is a great online tool to share data between computers. The software for OpenSuse can be found either here http://software.opensuse.org/113/en and installed directly or you have to add this repository
http://download.opensuse.org/repositories/openSUSE:/11.3:/Contrib/standard/
to the YAST and install it by YAST. After installation open a terminal and type
dropbox start -i
Just follow the prompts to create an account and choose a dropbox folder on your PC.

Tuesday, September 21, 2010

Install Skype under OpenSuse 11.x

If you have installed Skype and it crashes while starting you maybe have an old version of Skype. Here are steps to install Skype on Linux:

1) Delete currently installed Skype
zypper rm skype

2) Delete hidden file .skype in the user home directory.

3) Make sure you have installed libpng12-0 package. Install it by YaST if needed.

4) Grab the current Skype version from http://www.skype.com/intl/en/get-skype/on-your-computer/linux/ and install it. You can also install it directly, e.g.
rpm -Uvh http://download.skype.com/linux/skype-2.1.0.81-suse.i586.rpm

WLAN with Dell notebook and OpenSuse 11.x

Dell notebooks are normally equipped with Broadcom card for WLAN. All 802.11n Broadcom devices need to use the Broadcom STA driver. You need to accomplish the following steps to install such drivers:

1) Download current drivers from http://packman.links2linux.de/package/broadcom-wl. You need two drivers. In my case
broadcom-wl-5.60.48.36-7.pm.8.5.i586.rpm
broadcom-wl-kmp-default-5.60.48.36_k2.6.34.7_0.2-7.pm.8.5.i586.rpm

2) Open Linux terminal and go to the directory where you downloaded these drivers. Let run two commandos one after another
rpm -ivh broadcom-wl-kmp-default-5.60.48.36_k2.6.34.7_0.2-7.pm.8.5.i586.rpm
rpm -ivh broadcom-wl-5.60.48.36-7.pm.8.5.i586.rpm --force

3) Reboot your PC. If you still don't have a WLAN connection go to the YaST and configure WLAN in network devices. You should see at least your drivers.