Introduction

This post describes how to install soapUI on Ubuntu 11.10 and solve potential issues with installation.

Installation

  1. Download linux version (soapui-4.0.1-linux-bin.zip file) of soapUI 4.0.1
  2. Unpack it to desired location
  3. Add execute permission to bin/soapui.sh file: chmod +x bin/soapui.sh
  4. Run soapUI ./soapui.sh

Troubleshooting

If you get following exception after running and your application closes:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f6490c0a5f1, pid=28611, tid=140070162761472
#
# JRE version: 6.0_29-b11
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.4-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libgconf-2.so.4+0x175f1]  __float128+0xc01
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

add -Dsoapui.jxbrowser.disable=true flag when executing soapUI.

In order to do so edit soapui.sh file and add the following line:

JAVA_OPTS="$JAVA_OPTS -Dsoapui.jxbrowser.disable=true"

Enjoy soapUI running.


Introduction

This post describes how to set up environment to be able to code and debug Alfresco on Tomcat in Eclipse.

To start with make sure you have downloaded and installed the following:

Also make sure that you have appropriate environment variables set up:

  • JAVA_HOME
  • JAVA_JDK
  • CATALINA_HOME
  • CATALINA_BASE
  • TOMCAT_HOME
  • APP_TOMCAT_HOME
  • ANT_HOME
  • JBOSS_HOME

Make sure that you allocate enough memory otherwise it will not run or you get various errors like ‘OutOfMemory: PermGen’. The setup certainly works with the following parameters.

JAVA_OPTS="-XX:MaxPermSize=1024m -Xms512m -Xmx4096m"

Import projects into Ecplise

In order to add alfresco projects into Eclipse import ‘root/projects’ directory that you checked out from svn.alfresco.com. In Eclipse select: File -> Import -> Existing Projects into Workspace

You should be able to see the window presented below. Select all the projects. You do not have to copy them into the work space.

If you are successful you should be able to see the projects in your package explorer as pictured below.

Now you should be able to track the changes that you do in your code using Subversive Ecplipse plugin which is very handy.

Do Alfresco build

Go to ‘root/projects’ directory and run:

ant build

When you are successful you should be able to locate alfresco.war (alfresco repository) and share.war (Slingshot web interface) files in the following locations:

  • root/projects/web-client/build/dist/alfresco.war
  • root/projects/slingshot/build/dist/share.war

Create web projects in Eclipse

To deploy alfresco.war and share.war files separate web projects should be created. I am going to describe only share.war installation. alfresco.war installation should be done analogically.

Select:

File -> New -> Dynamic Web Project

Enter war name as project name (in our case ‘share’). The project will be deployed under project name URL. If necessary it can be changed in ‘Properties’ of the project – Web Project Settings – Content root. Select Tomcat 7 ‘Target runtime’ or choose ‘New runtime…’ if you do not have Tomcat 7 added in your server list. This will enable the addition of Tomcat 7 runtime environment.

This should create Dynamic Web Project with the following structure.

Unpack your share.war file and copy its content to WebContent folder of ‘share’ project. Refresh project in Eclipse. All Alfresco jar files you will find in the following path:

WebContent/WEB-INF/lib/alfresco-*.jar

Instead of having static alfresco jar files we can generate them automatically from our projects in Eclipse. In that way when we change some code we can check the outcome in convenient way by automatic deployment of new jar files. Let’s say that we want to change some code in ‘Core’ project, which corresponds to ‘alfresco-core-x.jar’. In order to do so we remove alfresco-core-x.jar from WebContent/WEB-INF/lib, so old version will not be used. Following that we edit Properties of the project and change:

‘Project references’ to include Core project:

‘Deployment assembly’ to include source code from ‘Core’ project. Click ‘Add…’, select Project and ‘Core’ project. Node that Core.jar will be created and this jar will be added to your deployment.

‘Java build path’ to include source code from ‘Core’ project. Click ‘Add…’ and select ‘Core’ project. It might also be necessary to change order of exported libraries in some projects, e.g., Repository project, in case of compilation errors. Put system libraries first.

Run project on Tomcat

Once the project (share) is set up not we can add it to Tomcat server and run it. In order to do so go to ‘Servers’ view (Window -> Show view -> Servers). Right mouse click on Tomcat 7 server and select ‘Add and Remove…’. Add share project to be run on Tomcat. Publish data and start server.

If everything is successful you should be able to access your application via web browser: localhost:8080/share.

If you want to see all the files that were actually deployed you can find them in the following path: ‘workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/share’

You can change Tomcat configuration, e.g., increase memory by double clicking on appropriate server in ‘Servers’ view. Select ‘Open launch configuration’.

If there is no Tomcat 7 server you can add it by right mouse click and selecting ‘New -> Server’.


To make star character in bash to match hidden files, use dotglob option:

$ shopt -s dotglob

If directory contains both normal and hidden (.*) files, here what you will get without and with dotglob set:

$ ls *
file1.txt  file2.txt
$ shopt -s dotglob 
$ ls *
file1.txt  file2.txt  .htaccess  .htpassword

I find this one very useful, when you press just CTRL-G in vim you will get some basic file information:

"abc.tmp" 165 lines --36%--

When you use put count (a number) 1 before that command, the path will get expanded to full path (but shortened with ~ for the home directory). So when pressed:

1 CTRL-G

The output will change to:

"/tmp/abc.tmp" 165 lines --36%--

I wanted to iterate over set of directories and calculate total number of files inside each of them (recursively). xargs & find would do it just fine but you can not easily escape pipe inside xargs command. Here is the solution:

ls | xargs -n1 -I{} sh -c 'echo -n "{} "; find {} -type f | wc -l'

I usually set my postfix to relay via gmail SMTP to allow me for reliable external email delivery from my gmail address, with the convenience of the command-line. To send an email using mail utility I can simply use:

$ cat email.txt | mail email@example.com

This will generate an email with default X-Mailer tag, like:

X-Mailer: mail (GNU Mailutils 2.2)

To disable it, create a .mailrc configuration file in your home directory and unset xmailer option:

echo noxmailer >> ~/.mailrc

Here is the error from dmesg I’ve got when trying to mount external HDD:

[345826.197335] EXT3-fs error (device sdd1): ext3_check_descriptors: Block bitmap for group 1920 not in group (block 0)!
[345826.198130] EXT3-fs (sdd1): error: group descriptors corrupted

Trying to mount as ext2 didn’t change anything:

[346348.544459] EXT2-fs (sdd1): error: ext2_check_descriptors: Block bitmap for group 1920 not in group (block 0)!
[346348.544470] EXT2-fs (sdd1): group descriptors corrupted

fsck didn’t want to help and was stopping after this:

% fsck.ext3 /dev/sdd1           
e2fsck 1.41.14 (22-Dec-2010)
fsck.ext3: Group descriptors look bad... trying backup blocks...
fsck.ext3: A block group is missing an inode table while checking ext3 journal for /dev/sdd1

What you can try to do to recover at least some data is to use backup superblock. Run mke2fs command (as root):

% mke2fs -n /dev/sdd1
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
24420352 inodes, 97677200 blocks
4883860 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2981 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968

Notice the numbers at the end, let’s try fsck with one of the superblock backups:

% fsck.ext3 -b 71663616 -y /dev/sdd1
e2fsck 1.41.14 (22-Dec-2010)
/dev/sdd1 was not cleanly unmounted, check forced.
Resize inode not valid.  Recreate? yes
 
Pass 1: Checking inodes, blocks, and sizes
...

It did work for me, good luck and let me know how did you do!



Introduction

I have a collection of 160 photos that I would like to montage into a movie. Each photo was done on a different day and the brightness of each photo varies. This will definitely not look good on the photo, so I’ve decided to “normalize” the brightness across the images. That is:

  • Find a value for average brightness of my images.
  • Brighten those too dark, and darken those that are too bright. Contrast should also be adjusted.

Calculate average image brightness

I have used utility called identify from ImageMagick package

% identify -format "%[mean] %f\n" *JPG | sort -rn 
44153.8 2011.06.22.JPG
37955.8 2011.06.11.JPG
#...many more...
23019.2 2011.06.01.JPG
21256.8 2011.06.06.JPG

-format option allows for specifying what kind of information about the image we want to output. In this case I went for average brightness – %[mean] and filename – %f, see the full documentation if you’re interested in other possibilities.

The difference between top and bottom photos is quite big: 21256.8 for 2011.06.06.JPG and 44153.8 for 2011.06.22.JPG – see the photos below.

The darkest photo

The brightest photo

Now let’s calculate the average value of brightness – awk to the rescue!

% identify  -format "%[mean] %f\n" *JPG | sort -rn | awk 'BEGIN {FS=" "} { sum += $1; } END { printf "%s",sum/NR}' 
29481.9

Equalize the brightness

So I need to bring all the photos to the mean brightness of about 29481.9. The best option I’ve found to do that is to use -sigmoidal-contrast from ImageMagick. I don’t know what values for -sigmoidal-contrast I need to use, to get from one brightness to another, so I wrote a simple script that will try to do that using binary search algorithm. It’s really very quick & dirty script but it does the job. The main loop is as follows:

do {
$current = ($min + $max) / 2;
$brightness = adjust($current, $file);
$diff = $target - $brightness;
if($diff > 0) {
//we need to make it lighter
$min = $current;
} else {
//we need to make it darker
$max = $current;
}
$i++;
} while(abs($diff) > 200);

adjust function basically calls external convert utility to perform the adjustment:

convert $file -sigmoidal-contrast '$value,0%' $tmpfile

and then checks and returns the brightness after conversion. I use -sigmoidal-contrast option to increase brightness and +sigmoidal-contrast to decrease. Now, that’s much better:

The darkest photo after script run

The brightest photo after script run

Here is the complete script – as I’ve said: quick & dirty job.


Recently I had to locate the widest image in the set of photos in a directory. Here is how you can easily do it with identify command, from ImageMagick suit:

% identify -format '%w %f\n' * | sort -rn | head -n1
563 2010.12.30.JPG

You can see in the output that the widest image is 563 pixels wide and the filename is 2010.12.30.JPG.