Thursday, December 29, 2011

maven2 and maven3 : m2 repository

Early of my post I discussed about keeping maven2 and maven3 in the same machine. But I forgot to discuss about the .m2 repository. Please note that the m2 repositories of maven2 and maven3 cannot be the same. Because there are some differences in pom files in maven3 which maven2 cannot understand. So we have to keep two different spaces for maven2 and maven3. If you use one of these then you can use the default m2 repository directly instead you have to rm -rf your existing m2 repository if you going with maven3. If you want to keep both here is a tip you can follow.
First decide which one take default and which one take a custom place (you can put both in a custom place also).  Then you have to change the settings.xml of maven. 
Settngs.xml file can be found in following places and you can change any of it.
  • The Maven install: $M2_HOME/conf/settings.xml
  • A user's install: ${user.home}/.m2/settings.xml
Now you have to add the following part to the settings.xml file.
/path/to/local/repo


Now you are done.

Note: If you used aptitude to install maven then maven install settings.xml can be found in /etc/maven2. 

WSO2 Governance Registry-Configurable Governance Artifacts part-4

In my previous posts I discussed about how to add new meta data model. In this post I am going to discuss about how to add a menu item by adding a menu element to the registry extension file.

    governance_list_processes_menu                   
    List                                 
    org.wso2.carbon.event.mgt.ui.i18n.Resources 
    governance_processes_menu      
    ../generic/list.jsp                          
    key=process                      
    region3    
    1                                    
    manage                   
    ../images/list.gif                     
    /permission/admin/manage/resources/govern/processes/list


The menu definitions are standard to the Carbon Platform, and you can copy any generic menu configuration into this block. Given below is a simple description of the elements in above elements.

id - Menu identifier
i18n-key - Name for the new menu item appeared in the list get from the Resource.properties file for the given key
i18n-bundle - Place where you put the Resource.properties file
parent-menu - Parent menu
link - On click
url-params - Parameters parse on url
region - Which reagion this belongs
order - Appearance number in the list
style-class - CSS
icon - Icon
require-permission - User permission required to see the menu

However, if there is a specifying menu items to point to JSPs that have been specifically created for representing governance artifacts it need to be mindful of some parameters.

 1. ../generic/add_edit.jsp requires the parameters,
  • key, which has to be equal to artifactkey defined above.
  • lifecycleAttribute, which is the attribute used to define the lifecycle.
  • breadcrumb, which is the title of the breadcrumb link for the add_edit.jsp page.
2. ../generic/list.jsp requires key, which has to be equal to artifactkey defined in the registry extension file.
3. ../generic/configure.jsp requires the parameters,
  • key, which has to be equal to artifactkey defined in the registry extension file.
  • lifecycleAttribute, which is the attribute used to define the lifecycle.
  • breadcrumb, which is the title of the breadcrumb link for the configure.jsp page.
  • add_edit_region, the value of the region parameter of the add_edit.jsp page. This is same as the region which you'd specify in the menu definition that you'd use to create a link to the add_edit.jsp page.
  • add_edit_item, the value of the item parameter of the add_edit.jsp page. This is same as the menu id which you'd specify in the menu definition that you'd use to create a link to the add_edit.jsp page.
  •  add_edit_breadcrumb, which is the title of the breadcrumb link for the add_edit.jsp page.

Wednesday, December 21, 2011

WSO2 Governance Registry-Configurable Governance Artifacts part-3

In the first and second part I described how to create a registry extension file. Now I am going to describe how to deploy it in the WSO2 Governance Registry. You can download WSO2 Governance Registry from here.

1. Extract the downloaded zip file to any place you like.
2. Start up the WSO2 Governance Registry
execute: sh GREG_HOME/bin/wso2server.sh
3. Go to Main->Browse->Detail view and add the registry extension file to any location you like.
4. Sign-out and Sign-in
5. Now you can see Event and Events in Metadata Add and List pans.



6. Click Event in Add pan. You can see a window use to add an Event.



7. Fill the given fields and see whether all the items work properly. If not you have made a mistake in the registry extension file.
8. Press Save.
9. Click Events in List pan. You can see a list of Events you saved.



10. When you click on one you can see the data you saved as follows.



Or you can see the content in standard view by clicking Standard view.



Now you can try your custom artifact by changing registry extension file.

WSO2 Governance Registry-Configurable Governance Artifacts part-2

In the first part I discussed about creating a registry extension file up to content element. In this post I try to cover how to create a content which describe the data model of the artifact.
Here is a sample content.

    <table name="Details">
        
            Name
        
        
            Date
        
        
            Venue
        
    </table>
    <table name="Rules">
        
            Gender
            
                male
                female
            
        
        
            Description
        
        
            Auther
        
    </table>
    <table name="Participants">
        
            HouseName
        
        
            Contact
            
                TitansLegionsCloud BotsWild Boars
            
        
    </table>
    <table name="Service Lifecycle">
        
            Lifecycle Name
            
        
    </table>
    <table name="SLA" columns="3">
        
            Document TypeURLComment
        
        
            SLA
        
        
            SLA1
        
        
            SLA2
        
    </table>

Artifact datamodel can be sub-catagorized under different topics. This separation can be acheive by introducing table element. You can see there are five table elements in the above sample registry extension file. table element consists of different fields. There are several types of fields.
  • text
  • text-area
  • options
  • option-text

Now lets look at how each type and some of their attributes associated with it.

text
Defines a text field.

 Name



path and url attributes

 SLA

path attribute is set then input expected to be a path. Also enabling this gives the option of browsing within the repository. But you can type the path as well.
If url attribute is set then the input expected to be a url.
If the input is a url or a path to a source in the repository then you can use both as in the example appear.


text-area
Defines a text area field.

 Description


options
Defines a field with a combo-box with the given values.

 Gender
 
  male
  female
 


option-text
Defines a composite field with a options field and a text field. Values of the options field need to define as a child element of field.

 Contact
 
  TitansLegionsCloud BotsWild Boars
 


maxoccurs attribute

 Contact
 
  TitansLegionsCloud BotsWild Boars
 

This attribute enables store multiple entries under same field.


Here is how it looks like after saving multiple values.


Since maximum occurrance is unbounded this can keep unlimited entries. If you want limit the number you can define maxoccurs to bounded value.

Associating a lifecycle using options field


options field can be use to select a lifecycle to the artifact instance using above code. This will list down the existing lifecycles to choose one which will associated with the instance. Not associating a lifecycle is also possible. This can be done by adding the following field.

 Lifecycle Name
 


Multi-type attributes

reqired attribute
required attribute makes a field required in order to create a artifact instance. In here I used the reqired attribute for text type, it can be used with other types also. Required fields are indicated using a red star as shown in the figure below.

 Name




Table attributes

columns attribute
columns attribute is use to set the number of fields in each row. Following fields are put in to the table in the order of they appear. Also number of heading child elements in the subheading element needs to be same as the number of columns.
<table name="External Links" columns="3">
 
  Document TypeURLComment
 
 
  URL
 
 
  URL1
 
 
  URL2
 
</table>



Now we have an idea about elements of registry extension file. In the next part we will see how we can add this extension to the WSO2 Governance Registry.

Tuesday, December 20, 2011

WSO2 Governance Registry-Configurable Governance Artifacts part-1

WSO2 Governance Registry give the full flexibility over extending its functionalities and capabilities. One of its configurable capability is extending its Metadata model in a way such that anyone can store any custom type of data like Services, WSDLs, etc. which are already there. This only needs to add a XML file (registry extension or .rxt file) as a resource to the registry which include the new Metadata model artifact. Here I am discussing about creattion of registry extension file which introduce a Event data model.


    event
    /events/@{details_name}
    details_name
    http://www.wso2.com/rxt/event
    
        
            
                
            
        
        
            
                
            
        
    
    
        <table name="Details">
            
                Name
            
            
                Date
            
            
                Venue
            
        </table>
        <table name="Rules">
            
                Gender
                
                    male
                    female
                
            
            
                Description
            
            
                Auther
            
        </table>
        <table name="Participants">
            
                HouseName
            
            
                Contact
                
                    TitansLegionsCloud BotsWild Boars
                
            
        </table>
        <table name="Service Lifecycle">
            
                Lifecycle Name
                
            
        </table>
        <table name="SLA" columns="3">
            
                Document TypeURLComment
            
            
                SLA
            
            
                SLA1
            
            
                SLA2
            
        </table>
    


Now lets identify main elements one by one.

artifactType element

This is the root element of the new artifact which is going to define. It has several attributes.

type - Define the mediatype of the artifact. This should be in the format of "application/vnd.[SOMENAME]+xml".  SOMENAME can contain any alphanumeric character, '-' (hyphen) or '.' (period).
shortName - Short name for the artifact
singularLabel - Singular label of artifact
pluralLabel - Plural label of artifact
hasNamespace - Whether artifact has a namespace (boolean)
iconSet - Icon set number which use as the artifact icons

artifactKey element
event
This element defines the unique key which can be used to identify the artifact. This key is used when fetching configurations and loading customized UIs.

storagePath element
/consumers/@{namespace}/@{name}
This is the path where the instance data of artifact is stored. When evaluate this expression, it automatically replace @{name} with the name of the artifact, and @{namespace} with the namespace of the artifact. In addition to name and namespace, you can also specify any other attribute in the format @{ATTRIBUTE_NAME}. e.g. /trunk/processes/@{business_domain}/@{overview_version}

nameAttribute element
details_name
This is the main attribute which define the name of the artifact. This must be in the format, {$table}_{$base-column}.

namespaceAttribute element
http://www.wso2.com/rxt/event
This attribute which you will define the namespace of the artifact. some artifacts might not need a namespace, and therefore, this is optional. Namespaces are found in artifacts related to Web Services, but might not be common to others such as Policy and SLA.


ui element

    
        
            
        
        
            
        
    


This element define the view of the data instances when browsing for that data type. It can include the list of data types which are in the content of the artifact.



relationships element

    
    
    

relationships defines the relationships between the newly created artifact and other artifacts. We can find three types here.

isConsumedBy - Artifact which consume newly created artifact
uses - Artifact which use newly created artifact
usedBy - Artifact used by the newly created artifact

content element

    <table name="Details">
        
            Name
        
        
            Date
        
        
            Venue
        
    </table>
    <table name="Rules">
        
            Gender
            
                male
                female
            
        
        
            Description
        
        
            Auther
        
    </table>
    <table name="Participants">
        
            HouseName
        
        
            Contact
            
                TitansLegionsCloud BotsWild Boars
            
        
    </table>
    <table name="Service Lifecycle">
        
            Lifecycle Name
            
        
    </table>
    <table name="SLA" columns="3">
        
            Document TypeURLComment
        
        
            SLA
        
        
            SLA1
        
        
            SLA2
        
    </table>

This element defines the data model of the new artifact. Also it will use to auto-generate the ui of instantiate artifacts.
We will discuss about content in the next post.

Sunday, December 18, 2011

Started my career life with WSO2

I finished my degree from University of Moratuwa at the end of last month. Soon after the finishing, we were asked to join WSO2 as we selected from the interviews. So I had a busy "end November" with preparation (filling docs and boring stuff). 
If I describe in one sentence, WSO2 is a open source middleware company which provide middleware stack for enterprise solutions.


1st December 2011, it is the first day at office and there were 21 fresh graduates who join WSO2 in the same day. Actually I am not exited because there were lot of familiar faces in WSO2 who were there at my intern. In the very first day we were assigned to different sub-products in WSO2 SOA platform. I was assigned to WSO2 Governance Registry.

Thursday, December 15, 2011

maven2 - maven3 and java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher

I typically use  maven2 as my builder manager  and I had to install maven3 to use in the same machine for build a new source code. I used following simple hack for this.
1. Download and extract maven3 distribution to any place as you prefer.
(MAVEN3_HOME = path of root of the extracted  distribution)
2. Rename one of the mvn file in MAVEN3_HOME/bin
You can use rename MAVEN3_HOME/bin/mvn mvn3 or mv  MAVEN3_HOME/bin/mvn mvn3
3. Add MAVEN3_HOME/bin to the environment variable in /etc/environment or /etc/bash.bashrc
4. Restart the shell/terminal
Now you can use both maven2 and maven3 using mvn and mvn3 commands.

Also you cannot use maven2 and maven3 shared m2 repository. You can do that by allocating different spaces for maven2 m2 repo and maven3 m2 repo. For more details click here.

After doing this when I execute mvn3 clean install I got the following exception.
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher

Solution:
First guess: The cause of this should be installing maven2 and maven3 in the same machine. But theoretically this cannot happened. Because we invoke maven2 and maven3 using different commands which locates in different places.
Second guess: There may some environmental variable which belongs to maven2 accessed by maven3. Fortunately the second guess was right. I exported M2_HOME in /etc/bash.bashrc file which direct to the maven2 root. After commenting out that piece of code mvn3 clean install worked fine for me.
WARNING: Programs which uses M2_HOME variable may not work properly after this modification.


NOTE: This is only one cause which throws this exception. There may more. Here is another example which throws the same exception but when executing maven2.