Thursday, January 29, 2009

How to fix the jsr173 missing artifact

How to fix the jsr173 missing artifact problem during a Maven build:

==========================================================
[ERROR] BUILD ERROR
[INFO] -------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) javax.xml:jsr173:jar:1.0

Try downloading the file manually from:
http://ftpna2.bea.com/pub/downloads/jsr173.jar
==========================================================


1. Go to /tmp
cd /tmp

2. Download the 14MB zip file:
http://cvs.apache.org/dist/incubator/beehive/v1.0-beta/bin/apache-beehive-incubating-beta.zip

wget http://cvs.apache.org/dist/incubator/beehive/v1.0-beta/bin/apache-beehive-incubating-beta.zip

3. Unzip the file
unzip apache-beehive-incubating-beta.zip

3. After unzipping, make sure that the jsr jar exists:
ls -la apache-beehive-incubating-beta/lib/common/jsr173_1.0_api.jar

Example output:
-rw-r--r-- 1 maven maven 26396 Mar 25 2005 apache-beehive-incubating-beta/lib/common/jsr173_1.0_api.jar

4. As user maven, install the file (use the right path to your mvn executable):
/maven/maven-2.0.6/bin/mvn install:install-file -DgroupId=javax.xml -DartifactId=jsr173 -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true -Dfile=/tmp/apache-beehive-incubating-beta/lib/common/jsr173_1.0_api.jar

Example output:

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ----------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [install:install-file] (aggregator-style)
[INFO] ----------------------------------------------------------------------------
[INFO] [install:install-file]
[INFO] Installing /tmp/apache-beehive-incubating-beta/lib/common/jsr173_1.0_api.jar to /maven/lib/javax/xml/jsr173/1.0/jsr173-1.0.Jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Thu Jan 29 09:56:38 EST 2009
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------
[maven@myserver tmp]$

5. rebuild the project

cd /path/to/project-directory
/maven/maven-2.0.6/bin/mvn --offline

...
[INFO] BUILD SUCCESSFUL
...

Done.

Tuesday, January 27, 2009

Deny yourself

"To deny our own impulses, is to deny that very same thing that makes us human" - Mouse, the Matrix

How to parse Apache log files

How to parse Apache log files using the cat, grep and awk command, in order to see what a particular person was browsing

To view the Apache access log file:
cat /var/log/apache/access_log

Log lines look as follows:
74.6.72.36 - - [01/Nov/2006:02:10:33 -0500] "GET /~lupsha/artificialintelligence/artificialintelligence.htm HTTP/1.0" 200 116 "-" "Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)"

To only view log lines that contain "Nov/2006" and "lupsha" and Mary's ip of "141.213.178.207", and to save all the contents of the log in another file called mary.txt, use grep as follows:
cat /var/log/apache/access_log | grep Nov/2006 | grep lupsha | grep 141.213.178.207 > /tmp/lupsha/mary.txt

The contents of /tmp/lupsha/mary.txt are now:
141.213.178.207 - - [10/Nov/2006:22:47:13 -0500] "GET /~lupsha/personal/pictures/2000.08.Trip.to.Crete/x-rethimnon-artistic.jpg HTTP/1.1" 200 7996 "http://socr.uwindsor.ca/~lupsha/personal/pictures/2000.08.Trip.to.Crete/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.1)"
141.213.178.207 - - [10/Nov/2006:22:47:13 -0500] "GET /~lupsha/personal/pictures/2000.08.Trip.to.Crete/x-rethimnon-artistic-2.jpg HTTP/1.1" 200 5503 "http://socr.uwindsor.ca/~lupsha/personal/pictures/2000.08.Trip.to.Crete/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.1)"
... etc

Take a log line as the one above, for example:
141.213.178.207 - - [10/Nov/2006:22:47:13 -0500] "GET /~lupsha/personal/pictures/2000.08.Trip.to.Crete/x-rethimnon-artistic.jpg HTTP/1.1" 200 7996 "http://socr.uwindsor.ca/~lupsha/personal/pictures/2000.08.Trip.to.Crete/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.1)"

We wish to take the path
/~lupsha/personal/pictures/2000.08.Trip.to.Crete/x-rethimnon-artistic.jpg
and convert it to:
<a href ="http://socr.uwindsor.ca/~lupsha/personal/pictures/2000.08.Trip.to.Crete/x-rethimnon-artistic.jpg"> [10/Nov/2006:22:47:13 </a>
so that a user can click on the link with the date in order to see what files were browsed.

We use the awk command as follows:
awk '{print "<a href=\"http://socr.uwindsor.ca"$7"\">" $4 "</a>"}' mary.txt > mary.html
The awk command above takes argument 7 and 4 from the log line and concatenates it to a custom html string, creating a link for the user.

by Alan Lupsha

Monday, January 26, 2009

How to get an email when someone logs into a shell account

Add the following 2 lines at the bottom of the .bashrc file. Replace YOURUSERNAME with the shell login and replace YOUR@EMAIL.ADDRESS with a valid email address:


echo "Today is $(date) User is: `who | grep YOURUSERNAME | awk '{ print $6 }'`" > ~/lastuser.txt

mail -s 'user YOURUSERNAME logged into server XYZ' YOUR@EMAIL.ADDRESS < ~/lastuser.txt