Jenkins and Microsoft projects

We have a .Net solutions which contains an Outlook Addin project and an installer project (vdproj). We have jenkins running as continuous integration/build tool.

The first challenge I had is to set assembly version from jenkins instead of setting from project. This is done by “echo” jenkins version info into project/properties/AssemblyInfo.cs file.

The second challenge I had is to build vdproj installer project. I was using MSBuild to build outlook addin project but unfortunately MSBuild cannot build vdproj file. After googling I have to use devenv.com command line to build the solution.

The third challenge is to set ApplicationVersion. The ApplicationVersion is used in manifest file and if that remains same, ClickOnce installer will complaint same manifest has already been installed. I only realised this problem recently. The first solution is to pass ApplicationVersion in MSBuild. But MSBuild cannot be used for vdproj. So I run MSBuild first then devenv. Unfortunately everytime devenv will rebuild my outlook addin project and thus reset ApplicationVersion. After a few trying I found the link: http://stackoverflow.com/questions/4192407/passing-msbuild-options-when-calling-devenv

All you need to do is just passing ApplicationVersion through environment variable before calling devenv.com. So below works:

 

Multicast and Promiscuous Traffic

We use multicast for EH cache replication between multiple nodes.

But one day we had an issue that our PROD environment received data from some testing environments. And trouble shooting gave us a hard time on it as we don’t really understand how multicast working. We are using same port but different multicast group IP address on different address, so we had thought such setup should be safe enough to segregate different environment.

Somehow the data still come across boundaries. After digging into my networking class textbook and finally remembered how multicasting works.

The command Join Multicast Group is a layer 3 (network layer) protocol thus only cares about IP address. It will pass data around same multicast group so if one host join two multicast groups at same time the data may cross over between two multicast groups.

The UDP is at layer 4 (transport layer) and supposed to use both destination address (here it should be multicast group IP) and port for filtering. However, Java (we thought it’s java issue at this moment) couldn’t bind it to multicast group IP, so we only bound it any host which causing the issue as the code shown below.

We found a link which provides a small Java program to listening on Multicast group. The way of calling is quite similar to the code that has been used in EH Cache.

The interesting part is MulticastSocket s = new MulticastSocket(port);

It creates the socket to a given port but any host. This is understandable as most time in TCP you only care about traffic that comes to certain port, but not IP address if you have a host servicing both localhost and LAN. But for UDP, since it’s connectionless, the IP address is only used for filtering.

But if we try to bind MulticastSocket to both multicast group and port like below

When we run the code, java will complaint the IP 239.255.255.250 is not available on the host. It expected a IP address that assigned to the host, which is for TCP case.

Finally we found out it’s actually an entry in Wikipedia and it has a term called Promiscuous Traffic. And also it mentions this is a Linux kernel issue. So we run above code which creates sockets binding to both IP and port on windows and no error given! The program actually is able to segregate two multicast groups. I also found the bug reported on Linux side but seems it was not properly treated.

Oracle SQL Developer and missing ocijdbc11.dll

I had oracle express installed and also using SQL Developer. But when I tried to use any TNS name in its connection setup SQL Developer always complaints missing ocijdbc11.dll in java.library.path.

Searching internet and found the link: http://mikesmithers.wordpress.com/2010/01/03/solved-%E2%80%93-the-mystery-of-sqldeveloper-and-the-missing-ocijdbc11/

So in short, just set %ORACLE_HOME% environment variable solved the problem.

Oracle SQL Precision and Scale

Precision and Scale are two basic parts of Oracle number data type, and almost every Oracle SQL developer will encounter it. But recently I was confused on how much exactly Oracle SQL can store when giving precision and scale.

There are topics on SOF (http://stackoverflow.com/questions/5689369/what-is-the-difference-between-precision-and-scale-in-oracle) and also the definitions are given in Oracle document (http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT313).

But one point I couldn’t find anywhere (maybe I didn’t notice in document), is that when exactly Oracle DB will throw error when storing numbers.

I had thought since Precision is number of total digits in a number and Scale is number of digits that right to decimal point, if the Precision is violated, i.e., when total number of digits more than defined Precision, Oracle will throw out error.

But it turns out that both Precision and Scale alone are not used to determine the error. It actually only throw out error when:
Number of Significant Digits (usually digits to the left of decimal point) > Precision – Scale

So if a number type defined as Number(8,2), so we have below scenario:

123456.12 Valid Stored as 123456.12
123456.123 Valid Stored as 123456.12
1234567 Invalid

Similarly, for type Number(8,-2):

1234567890 Valid Stored as 1234567800
123456.123 Valid Stored as 123400
12345678901 Invalid

Another interesting thing is that if you define the type as Number only, without giving Precision and Scale, Oracle will automatically take maximum precision which is 38, and use flexible scale based on input. But once you give the Precision, the scale will automatically becomes 0. So Number(38) is same as Number(38,0).

Oracle SQL Developer Password Storage

I have forgotten my password to one of our Oracle database server due to “change password every three months” policy. Luckily I have it stored in my Oracle SQL Developer application. I know the password will be stored in a encrypted format but since it must be sent in plain text to server I’m sure the encryption is reversible.

Google it giving me a few interesting result. The first is a Oracle SQL Developer extension to reveal password (https://code.google.com/p/show-me-password-sql-developer/). I’ve installed it but somehow it’s not always working. The extension option is not always available in right-click menu, and also it does not show all the stored passwords.

Another result points me to a gist (https://gist.github.com/ajokela/1846191), which has the code to decrypt the password.

Below code is copied from the gist, credit belongs to its original author.

Microsoft EWS API for Java and NTLMv2 Authentication

Microsoft has provided its JAVA API for Exchange Web Services (EWS) http://archive.msdn.microsoft.com/ewsjavaapi

However the Apache HttpClient it used couldn’t pass NLTMv2 authentication. In the provided library it does use Samba JCIFS for NTLMv2 authentication, but the flags it uses are wrong.

Original Code:

Apache HttpClient website has provided way to use JCIFS for NTLM: http://hc.apache.org/httpcomponents-client-4.2.x/ntlm.html

We have modified EWS API accordingly:

Hello bread, again

So, my journey started again.

This time I bought another brand yeast, and it turned out almost all previous failure were caused by the lousy yeast I used!

Same amount of flour and water, in last batch I have put the bucket in room temperature for around 8 hours and it rose 1-2 cm to the lid. But with the new yeast, in 2 hours it reached the lid and I have to move some out into another bucket. And look at the holes, they are totally different.

IMG_8801

And also the result, the bread tastes much much better. It’s a success!

IMG_0248