Nabsha's Blog-About

Just another WordPress.com weblog

Public Bookmarks

Algo

Dev

Android

Advertisements

A dirty fix to intermittent Blueprint camel test failures

Recently on a project, I faced a problem that our builds would fail because one of the test cases would fail. The error occurred almost 20% of the time and was pretty annoying to wait for the build to complete to ensure if you were lucky or not.

A typical trace of the log would look like

java.lang.RuntimeException: Gave up waiting for service (objectClass=org.apache.camel.CamelContext)
        at org.apache.camel.test.blueprint.CamelBlueprintHelper.getOsgiService(CamelBlueprintHelper.java:240)
        at org.apache.camel.test.blueprint.CamelBlueprintHelper.getOsgiService(CamelBlueprintHelper.java:202)
        at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.createCamelContext(CamelBlueprintTestSupport.java:352)
        at org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:247)
        at org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:217)
        at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.setUp(CamelBlueprintTestSupport.java:183)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:254)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:149)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

After some debugging, I was able to identify that the CamelContext service was null but Blueprint container was still trying to resolve it. Because of intermittent nature of the issue, I expected some race condition and stumbled upon following code in BlueprintExtender.java

            String val = context.getProperty("org.apache.aries.blueprint.synchronous");
            if (Boolean.parseBoolean(val)) {
                LOGGER.debug("Starting creation of blueprint bundle {} synchronously", bundle.getSymbolicName());
                blueprintContainer.run();
            } else {
                LOGGER.debug("Scheduling creation of blueprint bundle {} asynchronously", bundle.getSymbolicName());
                blueprintContainer.schedule();
            }

So in order to avoid race condition I set the following context property,

System.setProperty("org.apache.aries.blueprint.synchronous")

and the error disappeared

A little bit of research revealed similar findings were posted earlier as well.
https://access.redhat.com/solutions/640943

JSONPath using jayway

Recently on a project I used jayways(https://github.com/jayway/JsonPath) implementation of JSONPath specification as found on http://goessner.net/articles/JsonPath/. The project is indeed ill documented, but has plenty of features packed in it.

The API looks pretty simple, and thats where it all started for me as I was looking for a simpler solution to access a node in a json document. Essentially I had to extract fields from the json document according to some user configured expressions. I was looking for a solution that could do something like xpath, and I found JsonPath. jxpath could’ve been another candidate, but that would have demanded another marshalling from json to java object which I was not interested in because of performance penalties.

But I hit performance issues, and realized upon profiling that 90% of my process is spent in parse, then second candidate was evaluate(which happens to be in read(jsonpath)).

So here are my my findings,
# If you already have a Json Object (like JsonNode or Gson), and you dont want marshall/unmarshall that object, and pass it as it is to the JSONPath library, then there is no such option. You have to pass a json as string, or from some stream to get it working.

# If a document is to be parsed multiple times with different jsonpath expression then it is best to read the json string once using .parse() and then call .read() on a compiled jsonpath. It will be much faster that way.

# For me JacksonProviders performed better than default (SmartJsonPathProvider) implementation.

# JsonParser options can be used to optimize performance

Small things matter…

How to run different JMX Clients with JMXMP support

How to run different JMX Clients with JMXMP support


 

JConsole

jconsole -debug -J-Djava.class.path="%JAVA_HOME%/lib/jconsole.jar;%JAVA_HOME%/lib/tools.jar;%JAVA_HOME%/lib/opendmk_jmxremote_optional_jar-1.0-b01-ea.jar"

JVisualvm

jvisualvm -cp "%JAVA_HOME%/lib/tools.jar;%JAVA_HOME%/lib/opendmk_jmxremote_optional_jar-1.0-b01-ea.jar"

Enabling jmxmp connector in Glassfish v4.0

Today I was working on optimizing one of our webapps running on glassfish server and I had to find out how the overall JVM is doing. So i started digging about the JMX MBean server exposed by the glassfish server. By default Glassfish exposes jmx over RMI and this causes lots of issues while working under strict firewall rules.

The escape goat here is jmxmp, and to get it working you need to change jmx-connector configuration in ${glassfish_home}/glassfish/domains/domain/config/domain.xml as following,

<jmx-connector port="8686" protocol="jmxmp" address="0.0.0.0" security-enabled="false" auth-realm-name="admin-realm" name="system"></jmx-connector>

I could not find the necessary documentation in the glassfish site and tried my luck with one of the comments I found while googling.

In end, I am happy it worked…

My research on Open-source web-based Scrum tool

Since past two weeks I have been searching for a tool to help scrum introduction in the team. My main requirements were that it should be free, open source and web-based. On this journey, I found many good tools like icescrum, scrumdo, agileexpress and kunagi. I will be going thru them one by one

  • icescrum: It comes with a very easy to install installers(like one of those from bitnami). Runs in tomcat and mostly works. The issue with this tool is its bad color combination in user interface.
  • scrumdo: This also looks neat from the screenshot but I could not get it to work because its installation required a lot of tweaking like setting cronjobs and python.
  • agileexpress: From screenshots, this tool looks neat but I never got it to work because it required an installation of MySQL or PostGREs. The support for HSQL was broken due to compatibility with older version of scrumdo with LiquiBase
  • kunagi: This is the most stable and simple tool that I have come across which has neat user interface, works out of the box and some good features like backlog and burndown charts. I am banking with this tool as it is providing all the needed stuff in getting started with scrum in my team. You just have to thru the war in webapps and woala, it works. With some very good in-app documentation, it really eases the learning pain I found in other tools. I yet have to exp[lore featuers like collaboration and forums which just enriches it into a complete solution.

I am just loving it and I hope other who find this blog will find my personal experience helpful in deciding which way to go on their journey for a free web-based scrum tool. Happy Scrumming.

Conclusion of 360 degree research on Custom ROMs for Samsung GS4, GT-I9500

Finally after 3 days of 360 degree research on which custom ROM to use, I am settling with Wanamlite. In my research I tried both AOSP and TouchWiz based ROMs. All AOSP-based ROMs have issues with the Camera and as I observed overall stability as the apps will crash often. From UI perspective AOSP is good choice, but stability is more important for a device like phone. From TouchWiz camp, I tested Omega and Wanamlite, Omega has lots of bloatware and you feel the drag due to the apps, which can be mitigated but Wanamlite has them out of box. Omega has some 3minit framework which I yet have to explore.
Bottom line, if you have Samsung galaxy S4, GT-I9500, then go for a TouchWiz-based ROM, so far AOSP camp does’nt have a reliable solution for this device.
Cheers.

Document Attestation from Ministry of Foreign Affairs In Riyadh, KSA

Objective:

To attest the English translation of Government Document in Arabic(e.g. Birth Certificate) from Ministry of Foreign Affairs in Riyadh, Saudia Arabia

Process:

  1. Get the document translated from one of the translators located at  King Abdullah Street at this location 24.725199,46.656745
  2. Other then translation of the original, get a letter stating the attached document is a true translation. This document should be in both English and Arabic translation side-by-side. This document is kind of a guarantee letter from translator agency that the translation is correct. Both of these documents(english translation and guarantee letter) should be sealed together by the translator.
  3. Now visit Ministry of Foreign Affairs Office at this location 24.648999,46.690829, and attest the original birth certificate from here. The entrance is exactly at the location provided above. If you are travelling by cab, then drop near these coordinates.
  4. From this office, have the original document attested. The agent will charge you 30 SAR and will put a stamp and seal on the back of the document.
  5. Next, Head to Chamber Of Commerce (24.666982,46.707552). Chamber of commerce will not attest if you only show english translation of the original document. They will only attest the Guarantee document, sealed with the translation. If you did not get the guarantee document, their are a couple of translators outside who can help you get the translation.
  6. From Chamber Of Commerce, attest the guarantee letter, the agent will charge you 25 SAR for this service.
  7. Then in the same building Ministry has arranged to place MOFA office to fulfill attestation needs. There are usually a lot of people speaking English, so you can’t get lost here at least.
  8. From the MOFA attestation office, attest the same guarantee letter again. The agent will ask for MOFA attestation of original birth certificate and then proceed with attestation of the guarantee letter with translated birth certificate. He will charge you 30 SAR for this service.
  9. This should be it and now this document should be valid around the world
  10. The total cost of attesting one document costs around 85 SAR. The distribution is 30 SAR for Original Document attestation from MOFA, 25 SAR for attesting Translated Document from Chamber Of Commerce, and 30 SAR for attesting Translated Document from MOFA

 

maven local repository artifact not resolved

Today I was writing a small tool that required using a 3rd party artifact that existed in my local repository. When I tried adding just the dependency, maven failed to resolve it. then I also had to add the original repository from where the actual jar was pulled and it worked… Saved by,
http://maven.40175.n5.nabble.com/Not-finding-artifact-in-local-repo-td3727753.html

Shared mount point becomes read-only

Today, I booted MS windows on my machine and when I came back on linux, I found that my shared partition was mounted as read-only partition. I assume it got messed up when I booted to windows.  A quick investigation unveiled that fat table got corrupted. To fix the situation I had to invoke following filesystem check and the problem was fixed.


fsck -a /dev/sda2

Thank you Linux

A Look @ My Desktop