Category Archives: Linux

Common pitfalls installing Oracle XE 11 under Oracle Linux 6

First thing to check is the hostname inside /etc/hosts to ensure the install process can find the net listener. During the installation of Oracle Linux you set the hostname for example to oracle-vm.localdomain. Open with nano /etc/hosts and keep sure you have a line like this.

127.0.0.1 oracle-vm.localdomain localhost localhost.localdomain localhost4 localhost4.localdomain4

Next thing is to keep sure you have shared memory configured. Enter df -k and see if a line starts with shmfs. If not then enter

mount -t tmpfs shmfs -o size=2048m /dev/shm

and change your fstab to have shared memory available after next boot:

shmfs /dev/shm tmpfs size=2048m 0 0

Oracle XE for Linux is only available for X64 systems. Enter uname -a and see if it ends with

x86_64 x86_64 x86_64 GNU/Linux

If not reinstall your system with the x64 version of your linux distribution.

Keep sure your system is up to date with yum update.

After Download of Oracle Database Express Edition 11g unzip the File to a folder. Install the rpm with

rpm -ivH Disk1/oracle-xe-11.2.0-1.0.x86_64.rpm

and enter

/etc/init.d/oracle-xe configure

Check if the install process outputs ends with

Starting Oracle Net Listener…Done
Configuring database…Done
Starting Oracle Database 11g Express Edition instance…Done
Installation completed successfully.

or the log files under

/u01/app/oracle/product/11.2.0/xe/config/log.

On success you have a icon called “Get started with Oracle… .desktop”. Click on the icon and mark the link as trust worthy. It will open a browser

http://localhost:9000/apex/f?p=4950

If asked for a user name and password use SYSTEM and your chosen password as credentials.

Running headless webdriver based selenium junit tests inside jenkins under ubuntu linux

My test setup is for a little wicket 1.5.x based web application with ui tests running during integration-test phase of maven 3.x. The problem here is that my ubuntu 12.01 server has only a console and no gnome or kde running like a desktop linux. Inside eclipse is a test, which starts a browser like firefox to run automated clicks, no problem. I decided to use the webdriver based selenium tests which can use several driver for the different browser. Each driver supports a different browser like chrome, internet explorer or firefox. My tests starts a firefox with explicit locale setting. The wicket application is i18n localized for english an german speaking customer. On the server is a jenkins ci installed with subversion polling to run automated tests during maven build. You can run the scenario with no problems as well under hudson as ci. The solution use xvfb a virtual xwindow system for firefox as desktop. It will automatically started and stopped by jenkins during a job build.

Software Installation on the server

Installation of xvfb

apt-get install xvfb gtk2-engines-pixbuf

Installation of fonts

apt-get install xfonts-base xfonts-75dpi xfonts-100dpi
apt-get install xfonts-scalable xfonts-cyrillic

Installation of tools for testing xvfb

apt-get install x11-apps imagemagick

Testing server installation

1. Console run server

Xvfb -ac :99 -screen 0 1280x1024x16

2. console start firefox

export DISPLAY=:99
firefox http://ralf.schaeftlein.com

3. console make a screenshot

xwd -root -display :99 | convert xwd:- capture.png

And see a result like this when you retrieve the file capture.png via ssh

 

 

 

 

 
 

Jenkins Configuration

Init.d Script for xvfb

Save content as file under /etc/inid.d/xvfb

XVFB=/usr/bin/Xvfb
XVFBARGS="$DISPLAY -ac -screen 0 1280x1024x16"
PIDFILE=/var/hudson/xvfb_${DISPLAY:1}.pid
case "$1" in
  start)
    echo -n "Starting virtual X frame buffer: Xvfb"
    /sbin/start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
    echo "."
    ;;
  stop)
    echo -n "Stopping virtual X frame buffer: Xvfb"
    /sbin/start-stop-daemon --stop --quiet --pidfile $PIDFILE
    echo "."
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  *)
  echo "Usage: /etc/init.d/xvfb {start|stop|restart}"
  exit 1
esac
exit 0

Set rights for jenkins running user on the script

chown jenkins:root /etc/init.d/xvfb
chmod ug+rwx /etc/init.d/xvfb

Add display environment variable to jenkins init.d script

export DISPLAY=:99

Create a new jenkins job

Create a new jenkins job for your web project stored in subversion

 Add to pre and post build step a shell script to start and stop xvfb

 

 

 

 

 

 

 

 

Configure maven pom of the web project

Define special tests in surefire to run as integration tests and jetty as integration application server

			
				org.apache.maven.plugins
				maven-surefire-plugin
				2.4.3
				
					true
				
				
					
						surefire-test
						test
						
							test
						
						
							false
							
								**/itest/**
							
						
					

					
						surefire-itest
						integration-test
						
							test
						
						
							false
							
								**/itest/**
							
						
					
				
			
			
				org.mortbay.jetty
				maven-jetty-plugin
				6.1.26
				
					10
					foo
					9998
					/${project.artifactId}
					true
					${basedir}/src/test/webapp/WEB-INF/web.xml
					
						
							9999
							60000
						
					
				
				
					
						start-jetty
						pre-integration-test
						
							run
						
						
							0
							true
						
					
					
						stop-jetty
						post-integration-test
						
							stop
						
					
				
			

Add dependency to selenium maven artifacts

		
			org.seleniumhq.selenium.client-drivers
			selenium-java-client-driver
			1.0.2
			test
		
		
			org.seleniumhq.selenium
			selenium-java
			2.21.0
			test
		

Record ui steps and write a selenium junit test

Install the selenium ide as firefox plugin

Start firefox and install the xpi file as new plugin. Restart firefox afterwards.

Record ui steps

  1. Open the menu, choose web developer and their selenium ide.
  2. Start inside eclipse the tomcat with your web application
  3. Open in firefox the web application
  4. Click  inside selenium ide on the red record button for start recording
  5. Click through your web application
  6. Click again on the red record button for stop recording
  7. Choose from menu “Export as testcase” and their “Junit4 (Webdriver backed)”
  8. Save file as test.java

Create an new selenium junit test file

  1. Copy the test.java into your eclipse project into the src/test/java folder
  2. Adopt the class definition and setup method like this
public class SeleniumTest {

	private Log log = LogFactory.getLog(getClass());

	protected Selenium selenium;

	@Before
	public void setUp() throws Exception {
		FirefoxProfile profile = new FirefoxProfile();
		// enable german language locale
		profile.setPreference("intl.accept_languages", "de-de,de");
		profile.setEnableNativeEvents(true);
		profile.layoutOnDisk();
		WebDriver driver = new FirefoxDriver(profile);
		String baseUrl = "http://localhost:9999/"; // port jetty surefire integration test
		selenium = new WebDriverBackedSelenium(driver, baseUrl);
	}

– insert java code –

  1. Check into subversion and control jenkins job console.

Configuring solr, tomcat 7 with mod_jk and apache 2.2

As follow up post to setting up solr i show you how to integrate tomcat into Apache as main web server:

The setup was made under ubuntu 11.10 with the following prerequisites:

  • CATALINA_HOME is /usr/share/tomcat7
  • JAVA_HOME is /usr/lib/jvm/default-java
  • HOSTNAME in my case is ubuntu-vm.localdomain

 

  1. apt-get install libapache2-mod-jk
  2. nano /etc/apache2/workers.properties with the following contents
workers.tomcat_home=/usr/share/tomcat7
workers.java_home=/usr/lib/jvm/default-java
ps=/
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1
  1. nano /etc/apache2/mods-available/jk.conf with the following contents

        # Where to find workers.properties
        JkWorkersFile /etc/apache2/workers.properties
        # Where to put jk shared memory
        JkShmFile     /var/log/apache2/mod_jk.shm
        # Where to put jk logs
        JkLogFile     /var/log/apache2/mod_jk.log
        # Set the jk log level [debug/error/info]
        JkLogLevel    info
        # Select the timestamp log format
        JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
        # solr redirect
        JkMount /solr* ajp13

  1. less /etc/apache2/mods-available/jk.load to see the following contents
    1. LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
  2. run a2enmod jk to see if mod_jk is enabled
    1. Module jk already enabled
  3. less /usr/share/tomcat7/conf/server.xml to see a line like this
    1. <Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ />
  4. nano /etc/apache2/sites-available/default and insert a line into the virtualHost:80 section
    1. JKMountCopy On
  5. restart apache2 with service apach2 restart
  6. Open a browser on your client to open http://ubuntu-vm.localdomain/solr/admin/

Installing Solr 3.5 under Tomcat 7

Solr is a open source Enterprise Search Engine. It can be deployed as war file in servlet containers like tomcat or jetty.

This short howto show you run solr with the current Tomcat 7 version:

  1. Download Solr as Zip
  2. Unzip it e.g. in /usr/share/ with folder structure
    1. mv apache-solr-3.5.0.zip /usr/share
    2. cd /usr/share
    3. unzip apache-solr-3.5.0.zip
    4. result is a folder /usr/share/apache-solr-3.5.0
  3. Create a new folder e.g /usr/share/solr as base folder for the configuration
    1. cp -a /usr/share/apache-solr-3.5.0/example/solr /usr/share/solr
    2. cp /usr/share/apache-solr-3.5.0/dist/*.war /usr/share/solr
    3. ln -s /usr/share/solr/apache-solr-3.5.0.war /usr/share/solr.war
    4. mkdir /usr/share/solr/data< for index data/li>
    5. mkdir /usr/share/solr/lib for additional jars
    6. cp /usr/share/apache-solr-3.5.0/dist/apache-solr-velocity-3.5.0.jar /usr/share/solr/lib
    7. cp -a /usr/share/apache-solr-3.5.0/contrib/ /usr/share/solr/
    8. nano /usr/share/solr/conf/solrconfig.xml and change the lib settings
    // ...
      
    
    
      
      
      
      
    
    
    1. chown -R tomcat:tomcat /usr/share/solr if tomcat server runs as user tomcat
  4. Add URIEncoding to tomcat connector settings
    1. nano /usr/share/tomcat7/conf/server.xml
    2. search for the connector on port 8080
    3. add the URIEncoding like this:
    
    
  5. Create a tomcat configuration file for solr (CATALINA_HOME is /usr/share/tomcat7)
    1. cd /usr/share/tomcat7/conf
    2. mkdir Catalina (if not exists)
    3. cd Catalina
    4. mkdir localhost (if not exists)
    5. cd localhost
    6. nano solr.xml
  6. Paste the following configuration and save the file


  

  1. Set properties for tomcat and solr inside /usr/share/tomcat7/bin/setenv.sh
  2. Paste the following configuration and save the file
export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/usr/share/solr"
export JAVA_OPTS="$JAVA_OPTS -Dsolr.data.dir=/usr/share/solr/data"
export JAVA_OPTS="$JAVA_OPTS -Dsolr.velocity.enabled=true"
export JAVA_HOME="/usr/lib/jvm/default-java"
  1. (Re)start tomcat
    1. /etc/init.d/tomcat7 restart
  2. Open browser and go to http://YOUR_SERVER_HOSTNAME:8080/solr/admin/ assuming that tomcat runs under default port 8080

I use the provided sample xml files to see if import and query functionality works:

  1. cd /usr/share/apache-solr-3.5.0/example/exampledocs
  2. nano post.sh
  3. change the URL parameter to your environment e.g. to URL=http://localhost:8080/solr/update
  4. ./post.sh *.xml
  5. Open the admin ui under http://YOUR_SERVER_HOSTNAME:8080/solr/admin/
  6. click the search button

see my follow up post for Configuring solr, tomcat 7 with mod_jk and apache 2.2

Centos 6.2 with Firefox 9 and Google Chrome 16

Centos recently published v6.2

 

Out of the box is Firefox 3.x and no Google Chrome installed.

Steps to install Google Chrome 16 (as root)

Steps to install Firefox 9 (as before as root).

To install the Virtual box Guest Additions:

  1. yum update
  2. yum install gcc
  3. yum install kernel-devel
  4. Mount Guest Additions iso image
  5. Run autostart on the cd
  6. Enter root password
  7. After install reboot vm