tag:blogger.com,1999:blog-36182224398981978982024-03-12T19:04:08.936-07:00U.S. Tech Blog ...<b>U.S. Wickramasighe</b>http://www.blogger.com/profile/12790070345301543502noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-3618222439898197898.post-17918129804293218452011-11-09T02:08:00.001-08:002011-11-09T13:12:24.362-08:00How to enable simple message re-delivery with WSO2 ESB Endpoints<font face="arial,helvetica,sans-serif">It has been a while since i blogged :)</font>...In this article i thought of explaining how to configure WSO2 ESB to enable simple message redelivery. Way we do that is through ESB endpoints more specifically through a failover endpoint. Reason i thought of coming up with this topic was the simple fact that, there are several mechanisms to do this kind of thing and enforce different levels of reliability through WSO2 ESB. And many a times users would go for advanced options not knowing that there are simpler ways to achieve what is relevant for their setup or the environment. <br /> <br />Let's define the following simple configuration in the ESB with a failover endpoint .Please note we are connecting to a sample Axis2 Server as the backend service. This is shipped with WSO2 ESB by default. please refer to (<a href="http://wso2.org/project/esb/java/4.0.0/docs/samples_setup_guide.html#Starting" target="_blank">http://wso2.org/project/esb/java/4.0.0/docs/samples_setup_guide.html#Starting</a>) for more information on how to set that up. <br /><pre name="code" class="xml"><br /><proxy name="StockQuoteProxy" transports="https http" startOnLoad="true" trace="disable"><br /> <target endpoint="RetryEndpoint"><br /> <inSequence><br /> <log level="full"/><br /> </inSequence><br /> <outSequence><br /> <send/><br /> </outSequence><br /> </target><br /> <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/><br /> </proxy><br /> <endpoint name="RetryEndpoint"><br /> <failover><br /> <endpoint name="StockQuote"><br /> <address uri="http://localhost:9000/services/SimpleStockQuoteService"><br /> <suspendOnFailure><br /> <errorCodes>-1</errorCodes><br /> <progressionFactor>1.0</progressionFactor><br /> </suspendOnFailure><br /> </address><br /> </endpoint><br /> </failover><br /> </endpoint><br /><br /></pre><br />Try sending the message to StockQuoteProxy. You can use our default axis2 Client (<a href="http://wso2.org/project/esb/java/4.0.0/docs/samples_setup_guide.html#Using" target="_blank">http://wso2.org/project/esb/java/4.0.0/docs/samples_setup_guide.html#Using</a>) to do that...<br /> <br /><pre name="code" class="xml"><br />ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy<br /></pre><br /><br />You'll get a response back as usual..Now let's make the back-end service(ie:- <a href="http://localhost:9000/services/SimpleStockQuoteService" target="_blank">http://localhost:9000/services/SimpleStockQuoteService</a>) temporarily unavailable and try to send the message again.<br /><br /> This time you'll notice through the console , that ESB is trying to re-attempt the message delivery . So now if you were able to make the endpoint available again you would see the response coming back to the client (of course if the client does NOT time out).. This way we can enable a simple retry-re-delivery mechanism through failover endpoints. <br /> <br />Failover endpoints usually fallback to the endpoint that is not in a suspended state. However since we have NOT specified multiple endpoints to fail-over , trick is making the child endpoint active at all times. We do that by specifying errorCodes -1 == > make endpoint suspend to NO error code <br /> ie:-<br /><pre name="code" class="xml"><br /><suspendOnFailure><br /> <errorCodes>-1</errorCodes><br /> <progressionFactor>1.0</progressionFactor><br /></suspendOnFailure> <br /></pre><br />However this may not be desirable for some scenarios. There may be some critical errors (ie:- connection errors which may last for some time such as i/o or network errors) that you know you would not want ESB to waste time and resources , on redelivery. In that case you can define an error code/s that endpoint would really get suspended on and actually suspend for a time window, until the endpoint could probably recover..<br /><br /><pre name="code" class="xml"><br /><suspendOnFailure><br /> <!-suspend for an I/O failure-><br /> <errorCodes>101000</errorCodes><br /> <progressionFactor>1.0</progressionFactor><br /> <!-here suspend for 100 sec-><br /> <initialDuration>100000</initialDuration><br /></suspendOnFailure> <br /></pre><br />So here is the gist of what i have been trying to convey, -> If you encounter a scenario where you want to have simple redelivery on , you can opt for a failover endpoint setup though ESB. These are cases such as back end services may be unavailable for a very short period of time or you don't really want to configure transactional flows that will complicate the existing configurations,etc. For other scenarios again , ESB has many useful components that will ensure reliable delivery, transactions and QoS. JMS based transactions, Message stores and processors and dead letter channels , WS-RM through ESB are to name a few....<b>U.S. Wickramasighe</b>http://www.blogger.com/profile/12790070345301543502noreply@blogger.com2tag:blogger.com,1999:blog-3618222439898197898.post-22159639049565676032010-10-03T04:54:00.000-07:002010-10-03T06:10:06.289-07:00Understanding Application Sever Runtimes in Java environment...Lot of Application servers or containers deploy different mechanisms for runtime loading of classes and libraries...Understanding these mechanics is really important for resolving conflicts in Enterprise Applications and Runtime environments (ie:-J2EE envs , OSGi containers running on top of App servers ,etc)...Most of the modern Application containers deploy a method called "Bootstrapping" to isolate container specific and application specific runtime dependencies..What "Bootstrapping" effectively does is provide an "unpolluted" classpath for application modules so that they can work independently from container classpath , avoiding any conflicts which other wise would have occurred..(conflicts in the sense unresolved Classes, Class Cast exceptions ,unexpected initialization of code ie:- static initializers , etc )...This means that with "Bootsrapping" an application module can run a different version of a dependent library/class from a version that container depends on without affecting each other...To understand "Bootsrapping" one needs to have a good overall view on java class loading mechanisms..I came across the following article that nicely explains these concepts with several practical runtime deployment perspectives.. <a href="http://www.theserverside.com/news/1364680/Understanding-J2EE-Application-Server-ClassLoading-Architectures">http://www.theserverside.com/news/1364680/Understanding-J2EE-Application-Server-ClassLoading-Architectures</a> .. hope this would be useful for those who are interested.....<b>U.S. Wickramasighe</b>http://www.blogger.com/profile/12790070345301543502noreply@blogger.com2tag:blogger.com,1999:blog-3618222439898197898.post-2822915879307705852010-10-01T01:25:00.000-07:002010-10-15T13:13:17.847-07:00Disabling touch pad in Ubuntu 10.04i found it very annoying to use a touchpad in Ubuntu specially when typing...To add to the trouble my laptop does not have a manual turnoff switch for touchpads.....i came across the <a href="http://www.andrewferrier.com/blog/2010/06/04/disabling-synaptics-touchpad-with-ubuntu-10-04/">following post</a> which describes how to disable Synaptic touchpad with a GUI interface..<br /><br />If you are too lazy to remember and run 'gpointing-device-settings' in terminal , add command into the Applications submenu by --> (right click) Applications --> Edit Menus --> New Item<br /><br /><br />Update :------------------------------------------------------------------------------------ although at first 'gpointing-device-settings' looked great , it had certain limitations(ie:- timeouts can't be set,configuration issues)..therefore i had to go for a more crude method..<br />use 'xinput' to find device id for your touch pad..<br />$xinput list<br />mine was 13 (ie:-AlpsPS/2 ALPS GlidePoint id=13 [slave pointer (2)). I used this id to disable touchpad using <br />$xinput set-prop 13 --type=int --format=8 "Device Enabled" 0<br /><br />Use System --> Preferences --> Startup Applications to add a startup script if you want to disable your touchpad from start :)<b>U.S. Wickramasighe</b>http://www.blogger.com/profile/12790070345301543502noreply@blogger.com5tag:blogger.com,1999:blog-3618222439898197898.post-79416067003296638482010-03-18T14:52:00.000-07:002010-03-20T14:31:33.490-07:00Eclipse plugins and ExtensionsEclipse plugins architecture is an extended layer of OSGi. It basically wraps OSGi layer (such as Equinox) to provide a rich framework for it’s plugins and extensions. What that obviously means is , deepdown inside runs the same mechanics of imported/exported bundle packages and their dependency loading runtime as described/portrayed in OSGi specs/platforms. Eclipse plugin information is defined in a configuration file called plugin.xml .Eclipse’s plugin loader (or kernel) is an implementation of OSGi R4 specification that is responsible for loading and unloading plugins. However Plugin Loader does not load all the dependencies(ie:-classes/libraries) at the start-up since doing so would be an overhead for most of the systems (especially very large/complex systems). Plugin Loader employees a mechanism called “lazy loading” to load plugins and dependent classes and packages only when they are needed at the later most possible time. It actually do this by constructing a dependency hierarchy at startup by reading the information contained in plugin.xml of all the available plugins and loading them in to memory. So when a particular plugin wants to load classes from a different plugin (exported by the plugin/bundle) it would load them using the EclipsePlugin Registry (memory structure that was loaded at the startup) , as and when needed by the programming flow.<br />Eclipse’s way of dependency management is two fold , which are<br /> <br />1)Creating dependencies<br />-describes which external plugins are required by the plugin at hand. For example for the operation of a plugin A we may require external classes/packages exported by a specific plugin B ,which can be depicted as “Plugin B required by PluginA”. By doing so “plugin A” get exposed to all the packages/classes exposed by “plugin B” . This is similar to specifying [Require-Bundle: PluginB] in Plugin A’s MANIFEST.MF . Some times a plugin may only need several exported packages of a specific plugin ,not all of them ,which can be depicted as “package a,b,c of Plugin B required by PluginA” . This is similar to specifying [Import-Package: b.org.ui] in Plugin A’s MANIFEST.MF . However there’s an additional complication .For example If another plugin C exports a package with the same name "b.org.ui" ,then there’s a chance of conflict to arise since we are no longer depending on a specific plugin but a package. <br /><br />2)Creating Extensions and Extension Points<br />-defines how the plugin at hand can be involved in extending the functionality provided by other plugins (extensions) and what points of contact can a plugin provide so that other plugins can augment their functionality using the core functionality given –( extension points) . In other words extension-point acts as a pluggable interface/abstraction for outside plugins, while extensions act as a plugged component that has enhanced functionality. We can define extensions and extension-points in plugin.xml file .A respective Extension-point is normally written according to a specific schema (defining extending class ,name,plugin specific parameters,etc ) and plugin extensions should be solely responsible to extend accordingly to their respective schemas of the extending extension points. For Example we can create a customized View Panel in Eclipse by extending "org.eclipse.ui.views" extension point of org.eclipse.ui plugin . In our plugin say “org.simple.demo” we can have the following extension defined in our plugin.xml to create our customized view.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_iaXGeUfplkQ/S6U5OBtIOWI/AAAAAAAAADY/9UZDOmnbQNU/s1600-h/blog.jpg"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 450px; height: 167px;" src="http://4.bp.blogspot.com/_iaXGeUfplkQ/S6U5OBtIOWI/AAAAAAAAADY/9UZDOmnbQNU/s400/blog.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5450825837140523362" /></a><br />For above plugin to work properly we have to create "org.simple.demo.views.DemoView" class and extend it accordingly as specified in the documentations to "org.eclipse.ui" package classes. (ie:- more specifically by extending org.eclipse.ui.ViewPart and overriding #createPartControl(Composite) method ) .if the extension plugin is successfully deployed , as defined in the extension ,our view panel should appear under “DemoCategory” with the name “Demo view Panel” and it would have the ”sample.gif” icon on the title bar of the panel . (by intuitive observation we can see that this extension schema allows us to define multiple views under same category by declaring the same category id on view tag’s attributes for each view. However as good practice you should always go through the schema documentation of the relevant extension points for further clarification) .<br /> It would be very interesting to look into how our extended plugin actually works at runtime . As mentioned at the beginning plugin-loader would load necessary information about different plugins at startup (ie:-known as creating Eclipse ExtensionRegistry) . Our plugin is actually an extension of "org.eclipse.ui" plugin ,hence using the information gathered at the startup(ie:-extension information of all the plugins that has extended on org.eclipse.ui.views extension- point) "org.eclipse.ui" would load all it’s extended views into the main panel displaying each and every category and their symbolic representation of views under them. Actual View will only be loaded(using the ExtensionRegistry information ie:-class name respective to the extension) when a user actually clicks the relevant view entry on the main panel containing list of views. This is known as “lazy loading” ,where actual class, in this case org.simple.demo.views.DemoView is loaded on demand. <br /><br />Note that if we plan to create a plugin manually we should precisely reflect our intentions(especially related to dependency management) in plugin.xml (which is the file that eclipse abstraction layer operates on) as well as MANFEST.MF( which is the file that underlying OSGi runtime operates on). This could be especially difficult if we consider the unintuitive specifications of bundle properties needed to be written in Manisfest.MF (as in exporting, requiring bundles, naming conventions,etc) as well as numerous xml tagging schemas needed in specifying extensions and extension points which will drastically vary on plugin we are going to extend. Fortunately Eclipse provides plugin developers with PDE (Plugin development Environment) which gives a nice an easy user interface to workwith together with a elegant set of tools to seamlessly integrate and extend plugins without much hassle. Eclipse Plugin Manifest Editor categorize itself into five main sections/pages in creating a new plugin .Changes made in this sections directly reflects in MANIFEST.MF most of the time.<br /><br />• Overview - defines plugin name, id (uniquely identifies a plugin ) , version, description, etc. You can also optionally declare a plugin Activator class if you want system setup code to be put in <br /><br />• Dependencies - responsible for creating plugin dependencies (ie:-Required plugins/bundles and imported packages)<br /><br />• Runtime - Defining exported packages for the consumption of other plugins(ie:- export package) .Additionally you can define the bundle classpaths for external jars for use within the plugin.<br /><br />• Extensions - defining extensions and related parameters.<br /><br />• Extension Points - defining extension points for a plugin and it’s schema<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_iaXGeUfplkQ/S6U-MP_aYaI/AAAAAAAAADo/CW13-K8ZHDM/s1600-h/manifest-editor-overview_s.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 289px;" src="http://2.bp.blogspot.com/_iaXGeUfplkQ/S6U-MP_aYaI/AAAAAAAAADo/CW13-K8ZHDM/s400/manifest-editor-overview_s.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5450831304173707682" /></a><br />[Snapshot of Plugin Manifest Editor]<br /><br /><span style="font-weight:bold;">Code behind Extension Points</span><br /><br /> You may wonder how a plugin can load the extensions (may be declared in itself or by other plugins – most of the time ) defined by the respective extension-point it has. As mentioned at the beginning answer lies in the Eclipse extension Registry which eclipse kernel builds at startup. For this to materialize extension Registry needs the Extension-point Name on which the extensions are declared and the respective Plugin-ID .Following code snippet shows the code needed to acquire the declared extensions.<br /><pre name="code" class="java"><br />IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(“org.eclipse.ui”, "views").getExtensions();<br /><br />for (int i = 0; i < extensions.length; i++) {<br /><br />IConfigurationElement[] configElements =<br />extensions[i].getConfigurationElements();<br />}<br /></pre><br /> “extensions” return an array extensions extended by extension-point “org.eclipse.ui.views” .”configElements” is an array of elements defined under each extension as declared in plugin.xml . For example in our sample ui panel “DemoView” scenario , this relates to the xml elements <category> and <view> declared in our “org.simple.demo” plugin extension under <extension> element. Each IConfigurationElement is a XML object model element which can be traversed in a tree like manner . An IConfigurationElement can be used to load classes as well ,if their attributes do contain a class element (ie:-class Name) as in the case where <view> element contained a attribute named “class”. Following code snippet demonstrates this.<br /><pre name="code" class="java"><br />try {<br />view = (ViewPart) viewConfigElement.createExecutableExtension(“class”);<br /><br />} catch (Exception e) {<br /><br /> Log.logError(<br />"Failed to instantiate factory: "<br />+ viewConfigElement.getAttribute(“class”)<br />+ " in type: "<br />+ id<br />+ " in plugin: "<br />+ configElement.getDeclaringExtension()<br />.getNamespaceIdentifier(),e);<br />}<br /></pre><br />This is the most common way of loading classes dynamically on eclipse plugins ,especially as in “lazy loading” scenarios.<br /><br />This article only gave a basic understanding on the mechanics of eclipse platform –dependency management, extensions and extension points ,etc. There is lot more to be explored in eclipse and lots of API’s to be figured out to build a useful Eclipse RPC or Plugin App. However I hope my article series (including OSGi) have given you that initial stepping stone for achieving that goal. Please feel free to put feedback ,your ideas,etc here as well.<br /><br /><br /><script language="javascript"><br />dp.SyntaxHighlighter.ClipboardSwf = 'http://sites.google.com/site/mastershield2007/Home/clipboard.swf';<br />dp.SyntaxHighlighter.HighlightAll('code');<br /></script><b>U.S. Wickramasighe</b>http://www.blogger.com/profile/12790070345301543502noreply@blogger.com1tag:blogger.com,1999:blog-3618222439898197898.post-64982358636516029732009-05-14T01:19:00.001-07:002010-02-18T21:58:02.343-08:00Insight into OSGi and Eclipse ExtensionsI've been working on OSGi(Open Statndards Gateway initiative) and Eclipse extensions for a while. Both are of course very good frameworks (infact Eclipse Extension framework depends on OSGi ) that has sprung up not very long ago and has become very popular gradually. Obviously Eclipse's popularity as a project and IDE has served immensely towards the recognition of OSGi as a framework. Technically speaking Eclipse and all it's components (except it's kernel) runs on top of an OSGi framework implementation named equinox. Hence lot of software products and platforms are now turning into OSGi to make their software more extensible or scalable.<br /><br />As most of you know , within the core of OSGi lies a class-loading mechanism , where each bundle (as so called in OSGi) would take the responsibility of loading classes of their own , and would facilitate exposing of a subset of classes to the outside world while others will remain internal to the respective bundles. Although OSGi uses same Jar and Manifest mechanisms to achieve this, it is a radical change from Sun's Jar specification where all the classes and packages are implicitly exposed while clients can use any class within, they want (of course if the respective class implementation supports it). It's OSGi Runtime that deals with loading the bundles , managing dependencies(resolving) and registering and consuming services...<br /><br />OSGi Service is simply an plain old java object (POJO) which can be either state-full or stateless , or any kind of a java Object that does some useful stuff. These objects should be registered under a interface key name and hence in order to register correctly as an OSGi service , service objects need to implement the specified Interfaces. Inorder to register a service you need the BundleContext object , which is almost always taken from a Bundle Activator provided by the OSGi framework to the "start(BudleContext)" at the start of each bundle.Following shows an example..<span class="fullpost"><br /><span style="font-size:85%;"><span style=";font-family:webdings;font-size:85%;" ><br /><span style="font-size:100%;"><pre name="code" class="java">public class TestMailboxActivator implements BundleActivator{<br />public void start ( BundleContext context ) throws Exception {<br /><br /> IMailbox mbox = new TestMailbox ( ) ;<br /> Properties mailboxProps = new Properties();<br /> mailboxPropos.put("name","FixedTestMail");<br /> //registering the service under it's interface name<br /> context.registerService(IMailbox.class.getName(),mbox,mailboxProps);<br /> }<br />public void stop ( BundleContext context ) throws Exception { }<br />}<br />}</pre></span> </span></span> </span>For the classes to work and resolve properly ,IMailbox Interface should be exposed in the respective bundle(as declared in "export package" Manifest entry) or should be in the same bundle as TestMailbox (which is usually not the case). As in the example , services can be provided with key,value pairs as metadata which will be very useful indeed. However consuming services is little more challenging than registering them especially since we don't know when will services come and go due to their inheretly dynamic behavior.<br /><br />We may not know when will a bundle register a service object and when it will be destroyed.One way to resolve this problem is to always keep querrying service eachtime it need to be accessed as shown below.<br /><span class="fullpost"><pre name="code" class="Java"><br />ServiceReference ref = context.getServiceReference(IMailbox.class.getName());<br /> if(ref != null) { <br /> IMailbox mbox = (IMailbox)<br /> context.getService(ref); <br /> if(mbox != null) {<br /> int count;<br /> try{<br /> count = mbox.getMessageCount();<br /> }<br /> finally{<br /> context.ungetService(ref);<br /> }<br /> <br /> return count;<br /> }<br /> }<br /></pre></span><br />The method "ungetService" will tell the framework that it's nolonger using the service.This important since framework keeps a count of a particular service and when it reaches zero it will get it disposed.However using a ServiceTracker would make the above procedures a lot easier as well.<br /><br />ie:-<br /><pre name="code" class="Java"><br />ServiceTracker mboxTracker = new ServiceTracker(context,IMailbox.class.getName(),null);<br />mboxTracker.open();<br />IMailbox mbox = ( IMailbox ) mboxTracker . getService ( ) ;<br /></pre><br />Also Service trackers come useful when managing particular services that depend on other services as well. Suppose a service object "servicePayroll" depends on another service "payment" , where payroll object is useless without having payment in it's hand. Here "servicePayroll" service is dependant on "payment" and hence it is pointless to consume "servicePayroll" object if system already does not have a "payment" service registered in it. To solve this problem , we have listen in for the "payment" sevice to appear (when someone registers a "payment" service) and then register "servicePayroll" object so that now payroll is able to process payments and provide necessary details for it's clients.<br /><br />However things get little complicated when implementing this solution. One reason is we have to take notice of the "payment" services registered before our listener has even started as listener does not take care of this matter. So we should look up service registry to take into account the previously registered "payment" services. Also while we looking up the registry there may come a moment ,a "payment" object has been registered , however since we haven't registered our listener yet , this will go unnoticed. So we should register our service listener to listen to "payment" services first and then start lookup secondly.Again there will be some complications in overlapping and duplicate services so we should take care of them as well..<br /><br />This obviously is very complex and cumbersome code and that's where Sevice Trackers come into the rescue.ServiceTracker objects handle these scenarios for us and provide us with nice and easy interface to work with..Service tracker code is almost the same , but additionaly to handle listening and registering of dependent services we have to provide service tracker object with new "ServiceTrackerCustomizer" object..it Provides very useful and important addingService(ServiceReference) method , which is invoked whenever tracked service is found in the registry or when someone registers it.<br /><br /><pre name="code" class="Java"><br />ServiceTracker paymentTracker = new ServiceTracker(context,IPayment.class.getName(),new PaymentTrackerCustomizer(context));<br />mboxTracker.open();<br /><br />public Class PaymentTrackerCustomizer implements ServiceTrackerCustomizer(){<br /> private BundleContext context;<br />.......<br /><br />public Object addingService(ServiceReference ref){<br /> payment = (Payment)context.getService(ref)<br /> Payroll proll = new Payroll(payment);<br /><br /> //Returns ServiceRegistration object<br /> return context.registerService(IPayroll.class.getName(),proll,null);<br />}<br /><br />.........<br />}<br /></pre><br />addingService can return either null or any object (in this case ServiceRegistration object). Then when ever you call ServiceTracker's (ie:-paymentTracker) getService() method you will get the returned object (from addingService()) as the service object.<br /><br />So this is so far for now , about OSGi and Services. I'll talk about Eclipse extensions and extension points with the next post..So keep n touch and Thank you for reading...<br /><br /><br /><script language="javascript"><br />dp.SyntaxHighlighter.ClipboardSwf = 'http://sites.google.com/site/mastershield2007/Home/clipboard.swf';<br />dp.SyntaxHighlighter.HighlightAll('code');<br /></script><b>U.S. Wickramasighe</b>http://www.blogger.com/profile/12790070345301543502noreply@blogger.com1tag:blogger.com,1999:blog-3618222439898197898.post-41791228011132752392009-04-21T23:53:00.000-07:002009-05-20T13:18:28.159-07:00Running Eclipse on UbuntuFor starters, Running Eclipse IDE under Ubuntu would be a major hedache. You may encounter unusual number of errors including at Start-up , when running plugins , software updating , etc. Though the reason cannot be exactly pointed out , several issues standout among the rest ..First and foremost is the Eclipse SWT (Standard Widget ToolKit). Though a standard java lib ,SWT depends a lot on native platform features in order to provide nicer, richer graphical interface than AWT or Swing .<br /><br />Therefore SWT library needs to be installed (if not provided ) for each platform you are running in but still may encounter errors (ie:-XPCOM Error , Widert Disposed too early, etc) due to dependencies on web browser ,etc. Eclipse Runtime GCJ would be another reason behind many issues including when running plugins, software updates, java debugging , etc. GCJ is the java compiler + runtime provided by GCC (GCJ v1.5) , which is actually an open-source implementation of java kernel provided with ubuntu , which unfortunately Eclipse picks up as it's default JRE for most Linux platforms.GCJ is not properly tested and not a intended Runtime expected by Eclipse Developers hence would be the origin for a lot of in-compatibilities. <br /><br />Several work-arounds generally solve all these issues ,<br /><br /><ul><li>set Eclipse java virtual machine to java 1.5 0r 1.6 provided by SUN . This can be set in command line using ./eclipse -vm /${path to JDK Home}/bin/java or in eclipse.ini file specifying<br />-vm<br />/${path to JDK Home}/bin/java <br /></li></ul> <ul><li>if a Startup problem is there try updating Ubuntu or install latest xulrunner and XPCOM (sudo apt-get install xulrunner) packages for ubuntu and append to eclipse.ini<br />-Dorg.eclipse.swt.browser.XULRunnerPath=/usr/lib/xulrunner/xulrunner</li></ul><b>U.S. Wickramasighe</b>http://www.blogger.com/profile/12790070345301543502noreply@blogger.com1tag:blogger.com,1999:blog-3618222439898197898.post-2202651647500834212009-04-03T23:56:00.000-07:002009-05-28T13:15:51.597-07:00Using Maven2 (Contd..)Maven2 has very easy to use API for building Source code..I find it very easy to work with Maven2 due to this factor. Basic command for building is 'mvn install' but it's almost always a good idea to build using 'mvn clean install' since it does cleanup of already built code and then starts building fresh..<br />Before building always make sure your source code resides in '/src/main/java' and resources resides in '/src/main resources' . This is the default behavior for Maven2 and you can always modify it in super 'Pom' (or in you project pom as well ) which is the default root pom for all the pom's for Maven2.<br /><br /><span style="font-style: italic;">commands</span><br /><br />mvn clean install -> compile source and do necessary packaging<br /><br />mvn compile -> compile and run<br /><br /><span style="font-style: italic;">options</span><br /><br />-Dmaven.test.skip=true -> Sometimes it's better to skip unit tests and test cases , since it will be taking lot of time<br /><br />-o -> offline building . it's better to use this option if you know necessary plugins and dependencies are residing locally and upto date. Buiding with this option will take much less time since no downloading would occur from remote repositories.<br /><br />-U -> if maven displays an error of unavailable/error in a plugin use this option. this will force Maven to download the plugin and resume the life cycle<br /><br /><br /><span style="font-style: italic;">Notes</span><br /><br />Please note that if you are building a hudge tree of source code , maven will require a lot of memory to keep it's persistant data. So if the memory limit exceeds Maven2 build proccess will be terminated with out of memory error. So always make sure to set 'Xmx' Memory for Maven to a higher value in these scenarios..<br /><ul><li> open ${Maven_Home}/bin/mvn shell script file... (in Windows mvn.bat)<br /></li><li> Put set MAVEN_OPTS='-Xmx=1024m' at the start of the script file. Here 1024m can be replaced by any value you desire and only limited by the physical memory of your machine (should be a large value for aforementioned scenario)<br /></li></ul>For more information on Maven and it's build process go to <a href="http://maven.apache.org/">http://maven.apache.org/</a><br />------------------------------------------------------------------------------<br />My previous post <a href="http://udayangawiki.blogspot.com/2008/12/blogging-teplates.html">Using maven2 part1</a><b>U.S. Wickramasighe</b>http://www.blogger.com/profile/12790070345301543502noreply@blogger.com1tag:blogger.com,1999:blog-3618222439898197898.post-47991318985725894272008-12-07T07:35:00.000-08:002009-05-28T13:17:54.410-07:00Using Maven2 - For BeginnersMaven2 is completely new source code building System. Unlike previous types of builders (ie:- Ant, Make) Maven2 is not task oriented..In Abstract sense , for Maven2 you have 2 specify 'what' not 'where' / 'how to' in building your source code.<br /><br />Pom.xml is the descriptor file for Maven2 where you can specify ,<br /><br /><ul><li>code dependecies</li><li>Bundle information (Version, Artifact Id ,Group Id..)<br /></li><li>OSGi related stuff</li><li>plugin information (compiling,OSgi,Ant,etc )</li></ul>Maven2 has a local central repository (ie:- in Linux this is ~/.m2 directory) and also you can specify remote repositories as well incase to download the dependent code if not available in local one.<br /><br />'Pom.xml' descriptors canbe grouped hierachically when necessary to make your build more efficient and reliable . This is done by specifiying a parent for each child 'Pom' and specifying child 'Pom' modules in the parent as well.In this scenario Packaging type specifier for parent will always be 'Pom' while children will have necessary packaging types (ie:- bundle,jar ; Packaging type --> is how you define the output of the build )<br /><br />Maven2 recognizes each module/source build as an Artifact. Hence you need to specify Group Id, Artifact Id for each build.<br /><br /><ul><li>Group Id - which group does the build belong to .<br /></li><li>Artifact Id - Specific name/Identifier of the build</li></ul>So hence when you explore ~/.m2 repo , your build will be located (if you have already built it of course..) at ~/.m2/ ${GroupId}.replaceAll(".","/") /${ArtifactId}/${Version}<br /><br />I will discuss maven2 commands in the next Article...So stay tuned...<br /><br />------------------------------------------------------------------------------<br />My next post <a href="http://udayangawiki.blogspot.com/2009/04/using-maven2-contd.html">Using maven2 part2</a><b>U.S. Wickramasighe</b>http://www.blogger.com/profile/12790070345301543502noreply@blogger.com1tag:blogger.com,1999:blog-3618222439898197898.post-41196439297329546062008-12-07T07:33:00.000-08:002009-05-05T07:04:13.523-07:00HiThis is my First Blog...<br />I am very much new to Blogging and all so watch out for flops...<br />Please feel free to view and comment on my Articles..<br />Thnx<br /><br /><a href="http://technorati.com/claim/3ibbth3cxr" rel="me">Technorati Profile</a><b>U.S. Wickramasighe</b>http://www.blogger.com/profile/12790070345301543502noreply@blogger.com1