Magic Function – PHP Slugify UTF8 – Support Latin / Arabic / chinese …

<?php
    function slug($str, $limit = null) {
        if ($limit) {
            $str = mb_substr($str, 0, $limit, "utf-8");
        }
        $text = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
        // replace non letter or digits by -
        $text = preg_replace('~[^\\pL\d]+~u', '-', $text);
        // trim
        $text = trim($text, '-');
        return $text;
    }

 

Facebook developer

A workaround for facebook Graph API issue – How to get group ID number from its URL

In this article,  I would like to share my solution to get a Facebook group ID number from its URL.

Right now, this operation could not be done using Facebook Graph API or FQL. I have no idea why that old dated issue still not fixed by Facebook !

In this solution I have used a bot which login to Facebook, then go to the target group  and extracts group id in somewhere from the HTML content.

Here is the code source of a working solution based on PHP cURL library and DOM Xpath.

FacebookBot.php 

<?php
class FacebookBot {

    public static $HTTP_POST = "http-post";
    public static $HTTP_GET = "http-get";
    private $email;
    private $pass;
    private $uagent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)";
    private $cookies = "./cookies.txt";

    public function __construct($email, $pass) {
        $this->email = $email;
        $this->pass = $pass;

        touch($this->cookies);
    }

    private static function toFbMobileUrl($url) {
        return str_replace('//www.facebook.', '//m.facebook.', $url);
    }

    private function callUrl($url, $calltype, $data, &$output) {
        try {
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_TIMEOUT, 30);
            curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //return or not output data
            curl_setopt($curl, CURLOPT_ENCODING, "");
            curl_setopt($curl, CURLOPT_COOKIEFILE, $this->cookies);
            curl_setopt($curl, CURLOPT_COOKIEJAR, $this->cookies);
            curl_setopt($curl, CURLOPT_USERAGENT, $this->uagent);

            if ($calltype == self::$HTTP_POST) {
                $tmp = array();
                foreach ($data as $param_key => $param_value) {
                    $tmp[] = "$param_key=$param_value";
                }
                $data_str = implode("&", $tmp);
                curl_setopt($curl, CURLOPT_POST, 1);
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data_str);
            }
            $output = curl_exec($curl);
            curl_close($curl);
            unset($curl);
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    }

    public function login() {
        $url = "https://m.facebook.com/login.php";
        $post_data = array();
        $post_data['email'] = $this->email;
        $post_data['pass'] = $this->pass;
        $this->callUrl($url, self::$HTTP_POST, $post_data, $output);
    }

    public function logout() {
        $this->callUrl("https://m.facebook.com/", self::$HTTP_GET, null, $html);

        $dom = new DOMDocument;
        @$dom->loadxml($html);
        $links = $dom->getElementsByTagName('a');
        foreach ($links as $link) {
            if (strpos($link->getAttribute('href'), 'logout.php')) {
                $logout = $link->getAttribute('href');
                break;
            }
        }
        $url = 'https://m.facebook.com' . $logout;
        $this->callUrl($url, self::$HTTP_GET, null, $html);
    }

    public function destroyCookies() {
        unlink($this->cookies);
    }

    public function getGroupIdByUrl($url) {
        try {
            $this->callUrl(self::toFbMobileUrl($url), self::$HTTP_GET, null, $html);
            $dom = new DOMDocument;
            @$dom->loadHTML($html);
            $xpath = new DOMXpath($dom);
            $elements = $xpath->query("//a[starts-with(@href, '/groups/')]");
            if ($elements->length > 0) {
                $element = $elements->item(0);
                preg_match("/([0-9]+)/", $element->getAttribute('href'), $matches);
            } else {
                throw new Exception("could not find group id", 1);
            }
            return $matches[0];
        } catch (Exception $e) {
            throw $e;
        }
    }

}

 GetGroupIdFromUrl.php

<?php

$group_url=<a facebook group url>;
$email=<your facebook login>;
$pass=<your facebook password>;

try {
    include_once './FacebookBot.php';
    $fbbot = new FacebookBot($email, $pass);
    $fbbot->login();
    $gid = $fbbot->getGroupIdByUrl($group_url);
    $fbbot->logout();
    $fbbot->destroyCookies();
    echo "Group id: ".$gid;
} catch (Exception $e) {
    die("An error has been occurred !");
}

Try it here (Live demo) :

If  you have found  a bug or an alternative solution, please dont’t hesitate to post a comment or send me a private message. Thank you.

 

 

A Step-By-Step tutorial on building your own Safari extension (part 2)

PART 2: Building the extension

Getting started

This is the second part of the tutorial, If you missed the first part of this tutorial, you can find it here.

Open listed files using your preferred IDE or text editor:

  • global.hml
  • popover.html
  •  listner.js

Sublime Text 2

The End Script

The main goal of using an End Script,because it has access to the DOM of the web page. This is the only place where we can put ourJS code with the ability to addthe event listener on the visited page elements.

listener.js souce code

function clickHandler(o,recursive) {
	var e=(recursive)?o:o.target;
	if ($(e).is('a')) { 
		/*
		clicked element is a link so 
		send a message with link information
	    to global file (calls handleMessage function) 
	    */
	    safari.self.tab.dispatchMessage("link", $(e).get(0).href);
	} else {
		/*
		if the clicked element is not a link so 
		we need to go up to the parent element 
		recursively util a link tag is found.
	    */
		var parent = $(e).parents("a").get(0);
		if(parent) {
			clickHandler(parent,true);
		}
	}
}
/*
bind clickHandler function for each 
existing element of the document.
clickHandler will trigger when user
click on a element.
*/
$(document).on("click",clickHandler);

 As you can see in the source code above in line 28, the advantage of using JQuery.on() that the attached click Event handler clickHandler() will work for both current and FUTURE elements (like a new element created by a script). The purpose is that when the user clicks on an element clickHandler() will be executed and the clicked element (the object) itself will be passed as parameter to this function. Inside this function we check the element type. If it is a link or an element wrapped by a link tag <a> we dispatch a message containing link information to the Global Page.

The Global Page

global.html source code:

<!DOCTYPE html>
<html>
   <head>
    <script type="text/javascript" charset="utf-8">
        const gui = safari.extension.popovers[0].contentWindow //Create the popover instance
		function handleMessage(msg){
				if (msg.name == "link"){
					//exectue addLink() inside popover
					gui.addLink(msg.message);
				}
		}
		//creating the event listener
		safari.application.addEventListener("message",handleMessage, false);
     </script>
   </head>
   <body></body>
</html>

 As show above in the Global Page source code, the event listener in line 13 is executed once Safari launches or when enabling the extension, it tells handleMessage() to catch incoming messages from external scripts. When dispatchMessage() is executed inside “listener.js”, the message will be immediately cached by handleMessage() from the global page. Inside this function the message type is checked then addLink() from “popover.html” is called with passing the link URL as parameter. addLink() will update the container from the Popover by adding a new row. You should know that you can’t update Popover interface from the global page because it hasn’t got access to Popover DOM.

The Popover

The popover.html is the user interface. It’s based on usual Web scripting technologies HTML, CSS and JavaScript. As mentioned earlier we placed addLink() inside this script file because this is the only place we can access the Popover DOM.

popover.html source code:

<!DOCTYPE html>
<html>
   <head>
  <script type="text/javascript" charset="utf-8" src="jquery-1.7.min.js"></script>
  <style type="text/css">
		body {
			color: #333;
			font-family: tahoma;
			font-size: 10px;
			background: #F7F7F7;
		}

		h1 {
			text-align: center;;
			font-size: 12px;
			color: #990000;
		}

		#container {
			outline: 1px solid #AAA;
			padding: 4px;
			background: #FFF;
			height: 350px;
			overflow-y: auto;

		 } 
	    .entry {
	    	padding-top: 6px;
	    }

	    .link {
			cursor: hand; 
			cursor: pointer;
			color: #0099CC;
	    }
	    .link:hover {
			color: blue;
	    }

	    .time {
	    	padding-right: 4px;
	    }
  </style>
	<script type="text/javascript" charset="utf-8">
			function addLink(link) {
				$("#start").after('<div class="entry"><span class="time">'+getDateTime()+'</span><span class="link" onclick=\'openLink("'+link+'")\'>'+getShortString(link,34)+'</span></div>');
			}

			function getShortString( str, limit ) {
				if (str.length > limit) {
				 return str.substring(0,limit)+"...";
				} else {
					return str;
				}

			}
			function openLink(link) {
					safari.application.activeBrowserWindow.openTab().url=link;
			}

			function getDateTime() {
				var currentdate = new Date(); 
				var datetime =  ('0' +currentdate.getDate()).slice(-2) + "/"
				            + ('0' +(currentdate.getMonth()+1)).slice(-2)  + "/" 
				            + currentdate.getFullYear() + " "  
				            + ('0' +currentdate.getHours()).slice(-2) + ":"  
				            + ('0' +currentdate.getMinutes()).slice(-2);
				return datetime;
			}

	</script>
   </head>
   <h1>Visited Links Logger</h1>
   <body>
   	<div id="container">
   		<span id="start" style="display:none"/>
   	</div>
   </body>
</html>

 The picture below summarizes the above text. safarituto-arch

Testing Extension Package

The development of Visited Links Logger Safari extension has come to the end and it’s now time to test it. Ready?  So, go to the Extension Builder then click on Reload button which will update our extension by new the modifications we made.

Safari extension builder reload button

Now everything should be fine, try to visit a few web pages and click on the links inside, you will get a result like in the picture below.

Final Safari Extension

Building Extension Package

At this point we are still in the development stage and we haven’t made a finished extension yet, the extension is stored as a folder that contains some source files and an icon, for the moment it can’t be delivered to any end-users. All we need to do next is to generate a compact package. Once again the Extension Builder makes this task very easy to do by a single click on the Build Package button (see the picture below) then choose where you want to save your package.

Extension builder build package As a result, you should have a new package named: “VistedLinksLogger.safariextz”, it can be installed by opening the file or dragging it to Safari. You can also publish this extension in the Apple extension gallery.

Here is the project (zipped) : VisitedLinksLogger.safariextension.zip

I hope this tutorial was very helpful. If you need more help, please don’t hesitate to contact me or leave a comment and I will try to reply ASAP. To end off, I would like to thank Paola Pereira for the English review.

A Step-By-Step tutorial on building your own Safari extension (part 1)

Hello and welcome to this tutorial which is primarily focused on new Safari extension developers. The main goal of this tutorial is to demonstrate you how to build your own Safari extension from A to Z. We have chosen a good example of extension which involves various features that you have to learn. Within this tutorial, you will discover how simple and easy it is to create your own Safari extension.
This tutorial is divided into two parts:

Part 1 : Configuring the extension

In this part, you prepare the environment, enable Extension builder, create a toolbar icon, create and configure the popover.

Part 2 : Building the extension

In this part, you create (start and end) injected script, work with the Global Page, work with jQuery event listener, build the extension user interface (Popover), pass messages between scripts, build extension package.

Introducing the extension

We are asked to build a Safari extension that could log all visited links while you are surfing with a Safari browser.  All we need to log is the date on which the link was clicked and the URL. This is an additional specification:

  • The interface containing the log should be a sidebar or a popup window that could be shown by clicking on a button located in the toolbar.
  • Information about logged click (date and URL) should be placed in a single row (line).
  • The URL text should be clickable and underlined, when clicked it opens the URL in a new tab or window.
  • The top row should correspond with the most recent clicked link.
  • The log should be viewed in a medium-sized frame (maximum size: 400×500 pixels).
  • When the log passes the bottom border of the frame a vertical scroll bar must be shown.
  • When a row passes the right border of the frame, an excerpt of the URL must be shown followed by (…).

The mock-up below explains pretty much everything.

safarituto-mockup

PART 1: Configuring the extension

Getting started

This is everything we will need to build our extension:

  1. Operating System: Mac OS and Windows.Linux? I’m a Linux user and unfortunately there is no official version of Safari for Linux, so I have used Ubuntu Linux in the development stage and Windows on Oracle Virtual Box to test my extension on Safari.
  2. A recent version of Safari browser version 5 or higher (version 5.x.x recommended)
  3. Your favorite IDE or simply a text editor (In this tutorial I have used Sublime Text 2, you can download it from this link)
  4. A Safari Developer certificate is needed in order to use Extension Builder. Register by clicking this link then go to the Safari Extension Certificate Utility and follow the instructions.

After installing Safari, the first thing you need to do is to activate the develop menu in the menu Bar in order to use the Extension Builder.

Extension Builder is a powerful extension development utility included out-of-the-box with Safari.

To activate the develop menu go to the general setting menu and choose preferences then click Advances tab (as show below). By checking the box “show develop menu in menu bar” you will activate the develop menu.

 

Safari preferences - advanced

It’s time now to open Extension Builder, so go to the develop menu (see the picture below) then click on “show extension builder”.

Safari develop menu

 

As shown in the picture below, when you start the Extension builder the first time you will discover that there is no extension.

Safari Extension builder

In the next section we will start to configure our extension.

Configure our extension

Make sure that you have launched the Extension Builder then create a new extension by clicking the (add) icon button located in the bottom-left corner of the Extension Builder window.

When the file save dialog opens, type “VisitedLinksLogger” in the file name input box, then click on the Save button. (See the picture below).

Save as dialog

When you have clicked on the Save button, behind the scenes, a new folder has been created in the desired location. This folder is the extension project root directory (you can see the folder below) that currently contains only one file named “Info.plist” in which project settings and metadata are stored.

safarituto-extension-folder

Safari Extension builder

Extension configuration

First step we need to do is to provide information about our extension. Fill in Extension Info section as shown in the next picture. Feel free to provide your own information.

safarituto-extension-builder3

In Extension Website Access section set Access Level to ALL, then check “Include secure pages” in order to include all web sites.

safarituto-extension-builder4

Global Page

During this current step we will define the Global Page file. A Global Page contains a code that’s loaded once, when Safari launches or when your extension is enabled. This page is never displayed.

To define your Global Page go to the extension root folder  “VisitedLinksLogger.safariextension” then create a new empty file named “global.html” thereafter go back to the Extension Builder and in the Extension Global Page section select “global.html” from the drop-down list.

safarituto-extension-builder5

Toolbar button

As advised in the beginning of this tutorial our extension must include a button with icon in the toolbar.To create this toolbar button, start by downloading the icon from this link or you can choose your own. Note that it is highly recommended that the size of the icon should be 18×18 (pixels).

Once you have the icon you must place it in the root of the extension folder.In the next step we will configure the toolbar button using the Extension Builder. In order to create a new toolbar button click on “add new toolbar item” and fill in the information (label, Image and identifier) as seen below, then select your toolbar icon from the Image drop-down list.

 

safarituto-extension-builder6

Right now, nothing will happen if you try to click on the tool bar icon because we haven’t specified an event for it yet.

The Popover

At the beginning of this tutorial we were asked to build a popup window that would contain visited links log and this popup should be shown or hidden when we click on the toolbar icon we added previously.

The appropriate choice that meets the specifications is to use a Popover; it’s the extension user interface in which visited links log will be shown. So don’t stress about how to build Popover interface, it requires a basic HTML and JS skills.

Like a regular webpage you will need to create a single HTML file in the extension root folder then name it “popover.html”.

Now let’s move once again to the Extension Builder in order to configure our Popover. Go to the Popovers section, click on add new Popover button then enter the information as shown in the picture below.

Here is a description of each property:

  • Identifier : The name of the Popover
  • File: popover html file (interface).
  • Width and Height: popover dimension in pixel.

safarituto-extension-builder7

Up until now we have created a popover and a toolbar button but we have not yet configured this button to show the Popover when clicked. To configure our button we to go back to Toolbar Item 1 section and select myPopover from Popover drop-down list.

safarituto-extension-builder8

Injected Scripts

Our extension needs two kinds of scripts, a Start Script and End Script. Unlike the global page and Popover file we created in the last part, injected scripts are loaded each time a page is loaded. Here is the difference between a Start Script and an End Script:

  • Start script: executes when the document has been created but before the webpage has been parsed.
  • End Script: executes when the DOM is fully loaded

Start Script

To ease JavaScript development we will use JQuery library. In most cases,  JQuery functions are called when DOM is fully loaded. Our extension will need to call a JQuery function inside the end script. Since JQuery should be loaded first, it must be configured as a Start Script.

Download JQuery library 1.7 and higher or directly from this link, once the download is completed put the library (with .js extension) in the our extension root directory, then go back to Safari Extension Builder, in Start Scripts section click on “New Script” button then select added JQuery library from the drop-down list.

safarituto-extension-builder9

End Script

Create a new empty file “listener.js” and put it under the extension root directory then repeat the same steps in Start Script.Check that you have selected “listener.js” in the End Scripts drop-down list.

safarituto-extension-builder10

We have finished extension configuration,  last thing to do is to install Your Extension by clicking “Install” button on the right-top corner of Extension builder.

safarituto-extension-builder11

Once you have clicked on Install, go to Safari main window and near the address bar you should see the extension button, when you click on this a blank popover will be displayed.

Safari extension toolbar element button icon

Safari Extension popover

We have come to the end of the first part of the tutorial. During this part we have learned how to configure a Safari extension using Extension Builder which is a powerful extension development utility included out-of-the-box with Safari Browser.

The second part of the tutorial mainly focuses on the business logic side of our extension. We will dive into Injected Scripts, Global Page, passing messages between scripts and building the GUI. Please continue with second part here.

AMSTRAD CPC 6128

Feeling Nostalgic for The Amstrad CPC 6128

Schneider / Amstrad CPC 6128
Schneider / Amstrad CPC 6128

 I could never forget the day when I had my first micro computer Amstrad CPC 6128 it was in early 1990s ( I was 8 ) –  This computer really amazed me the first time, It was for me like a sophisticated device designed only to run video games.  I spend days and nights playing video games that some of them still stuck in my brain: like Jet Set Willy, Cauldron, Gyroscope, Ariane 2 and so many others. But the one which I liked more was Jet Set Willy (see the screenshot below).

Jet Set Willy
Jet Set Willy

CPC 6128 specs

It was composed of a keyboard and a green-scale monitor – I have seen all games in GREEN !

CPC 6128 Green-Scale Monitor
CPC 6128 Green-Scale Monitor

The keyboard was the main part and contains all ! everything, the motherboard, the microprocessor (Zilog Z80 4 Mhz), RAM (128 kbytes), and the 3″ floppy disk drive AND NO hard drive :-).

CPC 6128 3" Double-Sided floppy disk (360 kB Total)
CPC 6128 3″ Double-Sided floppy disk (360 kB Total)

My first geek experience

I was 12 when I discovered some kid friendly books about BASIC programming language in the library, which contained  examples of programs and easy to understand BASIC instructions. The first book I have read was “Computers 3. Their use at home” original title in french “Les ordinateurs 3. Leur emploi à  la maison”  published in 1984 by Gamma. (see the book cover below).

Les ordinateurs "leur emploi à la maison"
Les ordinateurs “leur emploi à la maison”

My first lines of code I have ever write were in locomotive BASIC, the main purpose of the program is to convert Miles to kilometers (see the code below)

10 REM CONVERSION MILES EN KILOMETRES
20 PRINT "ENTREZ LES MILES:"
30 INPUT m
40 LET k=1.609*m
50 PRINT m;"MILE(S)=";k;"KILOMETRE(S)"

I was so excited, when I have executed the program the first time. I could never forget the days and nights spent in my bedroom trying to write much complex programs and video games. It was my first geek experience !

At the end, thanks for reading this article and if you too, feel nostalgic to Amstrad CPC, use this link to download Caprice 32 an Open Source Amstrad CPC emulator, enjoy it !

Caprice32 Amstrad CPC Emulator on Ubuntu Linux
Caprice32 Amstrad CPC Emulator on Ubuntu Linux

java tunisia flag

15 Instructive video Tutorials For Java Programming Language Beginners In Tunisian Dialect !

java tunisia flag

Before I start,  just a quick special thanks to the creator of these instructive video tutorials Mohamed Turki, a software engineering student in Tunisia. Also a freelance Web Developer & Designer.

All video tutorials included in this post were originally uploaded  by the author  in youtube in mid-2011.

1 – Introduction To Java

– What is Java?
– What do you need before you start?
– How to download the JDK and Eclipse

2 – Hello Tunisia

– How Java works?
– Structure of a Java program
– HelloTunisia program

3 – Class

– How to create a class that defines a new type
– Elements of a class ( Variables & Methods)
– How to create variables and methods
– How to create an object of the new type and use it

4 – Java car

– Create new types
– Create objects of the new types
– Manipulate these objects

5 – If and Switch Statements

Controlling program execution with IF and SWITCH statements
“P.S sorry about the low volume at the end of the video”

6 – Iteration

– For
– Do while
– While
– simple mycar examples ;-)

7 – Packages and Access Control

– Java documentation link : http://download.oracle.com/javase/6/docs/api/
– How to create packages
– Access Control

8 – Composition and Inheritance

9 – Static and Constructors

10 – Polymorphism

11 – Abstract methods, abstract classes, interfaces

Beginner Java Tutorial #12 – More on Interfaces

13 – ArrayList, LinkedList, Stack

14 – Set and Map

15 – Final Program

video fiha presk les concepts elli chofnehom fel les vid lo5rin el koll (collection framework, static methods, inheritance, interfaces, polymorphism, scanner etc)

How Linux is Built

While Linux is running our phones, friend requests, tweets, financial trades, ATMs and more, most of us don’t know how it’s actually built. This short video takes you inside the process by which the largest collaborative development project in the history of computing is organized. Based on the annual report “Who Writes Linux,” this is a powerful and inspiring story of how Linux has become a community-driven phenomenon. More information about Linux and The Linux Foundation can be found at http://www.linuxfoundation.org and http://www.linux.com

Instructions On How To Deploy OpenACS (TR-069) On JBoss AS 5.1

This article focuses on the deployement of OpenACS which is a powerful open-source Automatic Configuration Server (ACS) implementing CPE configuration protocol CWMP as specified in TR-069.  At the time when I write this article I have deployed the latest version “0.4 beta” which can be directly downloaded from the link below.

download link: http://sourceforge.net/projects/openacs/files/openacs-binary/0.4/openacs-bin-0.4.zip/download

In the four sections below are different instructions on how to prepare the deployment environment, JBoss AS 5.1 GA configuration and OpenACS deployment.

Note: As OS I used RedHat Enterprise Linux 5 – theses instructions can be done otherwise in other Linux distributions or other platforms like Windows or Mac.

1. Installing JDK 1.6

To install JDK 1.6, Open the terminal, log in as root and hit this command:

[email protected] [~]# yum install java-1.6.0-sun-devel

 

2. Installing JBoss AS 5.1 GA

As it was described in the wiki page of OpenACS, the application can be only deployed on JBoss AS 4.2.x and as you know our goal is to run it under JBoss AS 5.1. Even you will use JBoss AS 5.1 next, you still need JBoss AS 4.3 in order to recover some jar files from it- So let’s download JBoss AS 4.2.3 using the link below .

download link :
   http://sourceforge.net/projects/jboss/files/JBoss/JBoss-4.2.3.GA

As a second step you have to download JBoss AS 5.1 GA on which will run OpenACS.

download link : http://sourceforge.net/projects/jboss/files/JBoss/JBoss-5.1.0.GA/jboss-5.1.0.GA-jdk6.zip/download

Installing JBoss is quite easy, after downloading the zip files you have only to decompress them using  a graphical mode or console zip utility. Follow the command as shown next, I used the unzip CLI utiliy included in the most of linux distributions.
Unzip  jboss-4.2.3.GA-jdk6.zip archive file:

[email protected] [~]# unzip jboss-4.2.3.GA-jdk6.zip

Do the same thing with jboss-5.1.0.GA-jdk6.zip archive file:

[email protected] [~]# unzip jboss-5.1.0.GA-jdk6.zip

 

Running JBoss 5.1 GA…
Now, let’s check that JBoss AS 5.1 runs with no problems, move to bin directory located in root folder of JBoss AS 5.1 and execute run.sh by following theses commands:

[email protected] [~]# cd jboss-5.1.0.GA/bin
[email protected] [~]# ./run.sh

JBoss startup can take a while, so be patient until a message like shown below will be printed in the screen. That’s fine !

10:57:18,603 INFO [ServerImpl] JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221053)] Started in 1m:4s:686ms

 

3. Configuring JBoss AS 5.1 to support OpenACS

As a first step, copy commons-httpclient.jar from JBoss AS 4.2.3 default server lib directory to the same directory in JBoss AS 5.1.

[email protected] [~]# cp jboss-4.2.3.GA/server/default/lib/commons-httpclient.jar jboss-5.1.0.GA/server/default/lib

download JDBC driver for MySQL mysql-connector-java-5.1.0-bin.jar using this link and copy it under lib directory of JBoss AS 5.1 of the default server.

[email protected] [~]# cp /my-download-path/mysql-connector-java-5.1.0-bin.jar jboss-5.1.0.GA/server/default/lib

Edit the file deployers/ejb-deployer-jboss-beans.xml

[email protected] [~]# vi  jboss-5.1.0.GA/server/default/deployers/ejb-deployer-jboss-beans.xml

and change the property value strictVerifier from true to false like shown in this snippet:

<!-- Setting this to 'true' will cause all deployments
to fail when the Verifier detected a problem with the contained
Beans. If false, warnings/errors will be logged but the deployment
will not fail.
-->
<property name="strictVerifier"><strong>false</strong></property>
</bean>

The final step in JBoss configuration is to copy the content of JBoss AS 4.2.3 /lib/endorsed into the same of folder in JBoss AS 5.1.

[email protected] [~]# cp jboss-4.2.3.GA/lib/endorsed/*  jboss-5.1.0.GA/lib/endorsed

By default when running JBoss AS 5.1 the option -Djava.endorsed.dirs is passed in run script parameters, if not add the line shown next at the end of run.conf file found under jboss-5.1.0.GA/bin

JAVA_OPTS="$JAVA_OPTS -Djava.endorsed.dirs=<YOUR_JBOSS_HOME>/lib/endorsed"

Note: <YOUR_JBOSS_HOME> should be changed by the absolute path of JBoss installation directory.

4. Deploying OpenACS

In order to deploy OpenACS, go back to the previously downloaded archive of OpenACS binary file and unzip it.

[email protected] [~]# unzip openacs-bin-0.4.zip
[email protected] [~]# cd openacs

Copy acs.ear and openacs-ds.xml to your default deployment directory, typically to server/default/deploy under jboss AS 5.1 GA installation dir.

openacs-ds.xml should be edited to meet your DB environement. Setup MySQL database server and create database and user to match the ones you’ve configured in openacs-ds.xml
acs-service.xml goes to server/default/deploy.

Finally you can start JBoss AS 5.1.

Note: In terms of best practices, it’s highly recommended to configure JBoss to run as a service/daemon

Web interface is accessible on your installation host under url /openacs ( e.g. http://localhost:8080/openacs. device should be configured to access ACS on URL http://your_host:8080/openacs/acs.

That’s all, I hope you’ll find this helpful.
All you comments are welcomed!