Friday, August 29, 2014

WebLogic: disabling JMS message consumption at startup

One can TEMPORARILY disable consumption from a JMS Destination (JMSServer / Active Destinations/Monitor) , but when you restart, the queue is enabled again. This in production can be fatal.

One can disable PERMANENTLY consumption with this setting in the queue configuration:





See http://docs.oracle.com/cd/E23943_01/apirefs.1111/e13952/taskhelp/jms_modules/distributed_queues/ConfigureUDQPauseMessages.html





Wednesday, August 27, 2014

OSB and SLA alerts in Eclipse

When you define a SLA alert in the OSB Console (sbconsole) this xml is added you your .proxy file :
  <ser:alertRules>
    <ser:alertRule name="slow" enabled="true">
      <aler:description>slow</aler:description>
      <aler:AlertFrequency>every-time</aler:AlertFrequency>
      <aler:AlertSeverity>normal</aler:AlertSeverity>
      <aler:StopProcessing>false</aler:StopProcessing>
      <aler:Condition type="statistics">
        <aler:config aggregation-interval="10" xsi:type="mon:monitoringConditionType" xmlns:mon="http://www.bea.com/wli/monitoring/alert/condition/monitoringstatistic">
          <mon:monCondExpr>
            <mon:function>max</mon:function>
            <mon:lhs>Project$PVtest/PVtest/Transport/response-time</mon:lhs>
            <mon:lhs-operand-type xsi:nil="true"/>
            <mon:lhsDisplayName>Response Time</mon:lhsDisplayName>
            <mon:operator>></mon:operator>
            <mon:rhs>600000</mon:rhs>
          </mon:monCondExpr>
        </aler:config>
      </aler:Condition>
      <aler:AlertDestination ref="PVtest/pier"/>
      <aler:AlertSummary>slow</aler:AlertSummary>
    </ser:alertRule>
  </ser:alertRules>

where PVtest/pier is an AlertDestination.

The horrifying thing is that if I import into eclipse this sbconfig.jar, the alertRules is emptied.

You can find some reference in the comments here and here. Of course I am shocked and horrified, because this is horrible and horrific.

So if you want to have those SLA, you must be very careful with Eclipse....

Sunday, August 24, 2014

Videos on how to upgrade to SoaSuite 12c

Oracle official documentation on how to install or upgrade

Really excellent presentation covering all the steps to upgrade your domains to 12c, including DB migration:



















Video Tutorial on Oracle Service Bus 12 development in JDeveloper


it's soooo much easier than in the old Eclipse IDE.... here everything is integrated (IDE, running embedded WebLogic server, Test Console, logs) and you can create a WSDL using an inline wizard.... it LOOKS like development is a lot easier ....

many thanks to Marcelo Jabali for the video



Saturday, August 23, 2014

More books: When Nietzsche wept, This time we went too far

When Nietzsche Wept very enjoyable novel by Irvin Yalom, about the life and work of 3 extraordinary Austrian and German intellectuals: Friedrich Nietzsche, Josef Breuer and Sigmund Freud.




"This time we went too far" is the harrowing account of the Cast Lead operation in Gaza 2008, by Norman Finkelstein. A must read, very scholar and accurate. Lot of details on the Goldstone report.

Of the same author, the somehow more specialistic "Goldstone Recants", on the "weird" recantation of Goldstone.









Friday, August 22, 2014

Solidarity with the children of Gaza

In case you want to help stitch together the children that the Israeli "Defense" Force have so surgically torn apart, you can send money to:

Account details:


Account Name:  Bethlehem Arab Society for Rehabilitation
Account No. 1101-024285-111
IBAN: FR76 1797 9000 0100 0242 8511 172

Bank details:

Europe Arab Bank plc
26, Avenue des Champs E’lyse’es
75365 Paris Cedex 08
Tel: 33 1 45 61 60 00
Fax: 33 1 42 89 09 78
Swift: ARABFRPP



I have just sent 200 CHF...

Wednesday, August 20, 2014

Git, configuring SSH on Windows

a great feature of git ssh is that, when it fails, you are left with very vague error messages that can point to 1000s of different causes. It could hardly stink more. Really only for the expert.


git and ssh, two skunks



c:\pierre>git clone ssh://git@stash.acme.com:7999/pup/puppet-pippov2.git
Cloning into 'puppet-pippov2'...
Could not create directory '/c/WINDOWS/system32/config/systemprofile/.ssh'.
The authenticity of host '[stash.acme.com]:7999 ([10.56.8.198]:7999)' can't be established.
RSA key fingerprint is fb:09:c7:a7:79:07:99:35:3a:88:51:18:59:a6:8e:75.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/c/WINDOWS/system32/config/systemprofile/.ssh/known_hosts).
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


I really have no clue where this systemprofile is coming from... must be some Windows default...

c:\pierre>echo %userprofile%
C:\Users\Pierluigi

c:\pierre>echo %HOME%
C:\WINDOWS\system32\config\systemprofile


Aha, see: the %HOME% variable is set to something WRONG.
I tried EXPLICITLY setting the %HOME% variable as a SYSTEM environment property (not a USER.... it didn't work....):
c:\pierre\vagrant>echo %HOME%
C:\Users\Pierluigi\

Now it all works. It can create the known_hosts file.
Windows stinks.

Git feature branch

More and more we are using "feature branch" rather than committing directly to master.

http://martinfowler.com/bliki/FeatureBranch.html

First, let's verify on which branch we are:
git checkout
Your branch is up-to-date with 'origin/master'.

and which branches are available in the current repo:
git branch
* master

it doesn't hurt to explicitly make sure we are on master:
git checkout master
Already on 'master'
Your branch is up-to-date with 'origin/master'.


and if needed, let's get the latest from the central repo:

git pull --rebase

we can now create a branch:

git checkout -b feature/pippo

and make sure the branch is actually created:

git branch
* feature/pippo
master


since I am paranoid, I again switch to this new branch:

git checkout feature/pippo
Already on 'feature/pippo'


I create a file:

echo ciao > ciao.txt

and

git add ciao.txt

and commit

git commit -m "added ciao"

if you switch to "master", ciao.txt disappears, because it's only in the "feature/pippo" branch:

git checkout master

ciao.txt is gone!

git checkout feature/pippo

ciao.txt is there again!



Now we need to push the branch to the central repo:

git push
fatal: The current branch feature/pippo has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin feature/pippo


you can simply do:
git push -u origin HEAD
Counting objects: 6, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 273 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To ssh://git@stash.acme.com:7999/gs/playgroup.git
 * [new branch]      HEAD -> feature/pippo
Branch feature/pippo set up to track remote branch feature/pippo from origin.


How to promote to master the changes in "feature/pippo" ? With a pull request, followed by a code review and a test! In github or stash you can create the pull request using the UI. This is a very cool and organized way to include changes to the master branch in a controlled, "atomic" way - a whole branch is a unit of changes that can be excluded as a whole if needed.



Thursday, August 14, 2014

Git detached HEAD

Normally I do all my git operations from command line. It might be more effort than using Eclipse/Geppetto plugin, but at least I know exactly what I am doing.

Recently I have made the terrible mistake of moving some files within the Geppetto (Eclipse) IDE.

Suddenly, the "HEAD detached" or "detached HEAD" message started appearing in my "git status":

git status
HEAD detached at 05eff15


and when I commit stuff, it sure succeeds but it's in the detached head, not in my master branch:

git commit -a -m " moved domains files"

[detached HEAD c67cdde]  moved domains files
 3 files changed, 82 insertions(+)


and when I try to push, I obviously get the message

git push

fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use

    git push origin HEAD:


equally, pull --rebase will fail:

git pull --rebase


From ssh://stash.acme.com:7999/pup/puppet-nesoav2
   14bba35..05eff15  master     -> origin/master
You are not currently on a branch. Please specify which
branch you want to rebase against. See git-pull(1) for details.

    git pull  


So basically I am screwed, unless I can rejoin my master branch and put in it all the commits I have done in the meantime in the detached HEAD. Bugger. I really wished git gave some BIGGER warning, since you don't really want to work normally in a detached HEAD.

I do this: first I join again my master branch:

git checkout master

Warning: you are leaving 3 commits behind, not connected to
any of your branches:

  c67cdde  moved domains files4b31fcfdd3893db49
  1ab0beb  moved domains filesrnetto@nespresso.com>
  ccdbcd0 usr files1:57:15 2014 +0200



ok this tells me that c67cdde is the hash of my last commit in detached HEAD.... let's go back to it:

git checkout c67cdde

Note: checking out 'c67cdde'.

You are in 'detached HEAD' state. 


then I create a new branch in which to commit that stuff:

git checkout -b tmp

Switched to a new branch 'tmp'




then I go back to master

git checkout master

and I merge the tmp branch

git merge tmp


Updating 05eff15..c67cdde
Fast-forward


I will confirm now that my latest commits are there in master:

git log -3

and I delete the now useless tmp branch git branch -d tmp

Wednesday, August 13, 2014

default: VirtualBox VM is already running.

I have cloned an existing Vagrantfile, changed the properties "config.vm.box" and "config.vm.host_name", and done a "vagrant up" hoping to have a brand new VM available. After all this is what Vagrant should be good at.

Nope. It keeps saying:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: VirtualBox VM is already running.


I had to do a "vagrant destroy" of my previously running VM, then a "vagrant up" of both.

ruby --version
ruby 2.0.0p353 (2013-11-22) [x64-mingw32]

vagrant --version
Vagrant 1.6.3


There you have a workaround.... however I am quite skeptical that Vagrant "fails" on such a basic operation... I am NOT impressed... I am unconditionally unimpressed by whatever turns around Ruby, the language is way too unstable and buggish when you compare to Java... I really wish all this Puppet/Vagrant world had not used Ruby as implementation language...



Monday, August 11, 2014

Oracle DB check contraints based on regular expression

It's good to know that for "check constraint" you can use any arbitrary regular expression http://docs.oracle.com/cd/E11882_01/server.112/e17118/conditions007.htm#SQLRF52150 .

Example:

create table PIPPO (name varchar2 (32));
alter table PIPPO add constraint check_name check (REGEXP_LIKE(name,'bi|bo|ba','c')); 


If you try inserting some crap you get:

Error starting at line 5 in command:
INSERT INTO "CMDBUSER"."PIPPO" (NAME) VALUES ('bu')
Error report:
SQL Error: ORA-02290: check constraint (CMDBUSER.CHECK_NAME) violated
02290. 00000 -  "check constraint (%s.%s) violated"
*Cause:    The values being inserted do not satisfy the named check
           
*Action:   do not insert values that violate the constraint.


If you get something like this below it means that your regex is bad or that the last parameter of REGEXP_LIKE is not legal (e.g. if you enter it UPPER CASE instead of lower case):

INSERT INTO "CMDBUSER"."PIPPO" (NAME) VALUES ('bu')
ORA-01760: illegal argument for function
ORA-06512: at line 1


The DB is the Foundation

I am surprised how little understood is still nowadays the importance of having clean, validated data in a DB.

DB schemas devoid of any NULL check, referential constraints and range checks are still commonplace, and management shuns attempts to enforce rigor perceiving it as "lack of flexibility". How flexible it is to have a "status" spelled in 5 different ways, or a date field represented as String and expressed in 10 different formats, or a boolean value expressed sometimes as True/False, other times as 0/1 and other times as YES/NO, I have no clue.

The DB is like the feet of your company, if feet are unstable, then your knees, your back, even your neck will start hurting and degenerating and making your life utterly miserable.

Statements like "we do all our validation in the front end" are ludicrous, ad history tell that Operations will make sure that a lot of DB changes will happen through custom scripts, independent UIs and even manually.

There are many analogies to DB constraints: control entropy (Physics), anti-cancerous cells (Biology), closed loop feedback (Control Systems), Secret Services (Fascist state - well all States are fascists inherently, so calling Fascist a State is a tautology)....

Saturday, August 9, 2014

Book: The Ethnic cleansing of Palestine



Professor Ilan Pappé does a wonderful job at explaining in the most minute (and horrific) details the events leading to the foundation of the State of Israel. It was simply a very well prepared, large scale military operation of Land Grabbing and Ethnic Cleansing quite similar in its dynamics to the one perpetrated by the Nazi Einsatzkommandos in Eastern Europe.

Zionist soldiers would reach villages mostly in the night, launch a few grenades, kill some people and expel the others, mostly without meeting any resistance, then loot their houses, grab their land and bulldoze mosks.

To his honor, Pappe never makes the all-too-easy comparison Zionism = Nazism, recognizing that the sole aim of the Zionist was to expel the Palestinians from their homeland, not to exterminate them. Of course they had to do some massive killing, but the target was mostly adult males. Nor they established death factories of the like of Nazi KZ, normally the Palestinian males would be shot on the spot in front of their families, while all the rest of the population was simply driven out in long foot marches to the neighboring countries.

The book also dismounts the Zionist myth of the "Israel besieged by Arabs" and "second Holocaust", showing that the Zionist had always an overwhelming military supremacy, and full support from the British. Jordan was always quite cooperative with them, and the other Arab armies were very limited in size, weaponry and coordination, and they intervened way too late when already 1 million Palestinians had been robbed of their land.

What makes this book even more valuable, is that it was written by a Jew whose family escaped from Nazi prosecution. This blunts the weapons of those ready to call Nazi and Anti-Semitic whoever criticizes Israel policies. Go get it.

Thursday, August 7, 2014

HTTP GET in Java, performance issues

My first version was:

import java.net.*;

URL url = new URL(theURL);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String wholeInput = "";
String inputLine = null;
while ((inputLine = in.readLine()) != null) 

{ wholeInput += inputLine; }



The above code proved to be EXTREMELY slow. The below version is MUCH faster:

URL url = new URL(theURL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String wholeInput = "";
String inputLine = null;
while ((inputLine = in.readLine()) != null) 
 { wholeInput += inputLine; }
in.close(); 


SOAP With Attachment with Java, working example

This code actually works , and produces a SOAM message with attachment of type application/octet-stream - which is totally acceptable, even if I would have preferred application/pdf.


import javax.xml.soap.*;
import java.net.URL;
import java.io.*;
import org.xml.sax.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import javax.activation.*;


// now all the SOAP code
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPHeader header = envelope.getHeader();

DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder builder = dbFactory.newDocumentBuilder();
// add the SOAP body as from text
StringReader sr = new StringReader(textToSend);
InputSource is = new InputSource(sr);
Document document = builder.parse(is);
SOAPBody body = envelope.getBody();
SOAPBodyElement docElement = body.addDocument(document);
// add attachment from file          

String filename = theBUSINESSIDVALUE.split("\\^")[0];
File fileAttachment = new File(rootFolderForMSS + filename + ".pdf");
FileDataSource fds = new FileDataSource(fileAttachment);
DataHandler dh = new DataHandler(fds);
out.write("content-type=" + dh.getContentType() + "
"); AttachmentPart attachment = message.createAttachmentPart(dh); String contentId = "<" + filename + ".pdf>"; attachment.setContentId(contentId); message.addAttachmentPart(attachment); SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); java.net.URL endpoint = new URL(POSTTOURL); SOAPMessage soapResponse = connection.call(message, endpoint);


I had tried this one before:

AttachmentPart attachment = message.createAttachmentPart();

String filename = theBUSINESSIDVALUE.split("\\^")[0];
File fileAttachment = new File(rootFolderForMSS + filename + ".pdf");
byte[] fileData = new byte[(int) fileAttachment.length()];
DataInputStream dis = new DataInputStream(new FileInputStream(fileAttachment));
dis.readFully(fileData);
dis.close();
  
String contentId = "<" + filename + ".pdf>";
attachment.setContent(new ByteArrayInputStream(fileData), "application/pdf");
attachment.setContentId(contentId);
message.addAttachmentPart(attachment);


but it was failing with this error
 javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/pdf
        at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:877)
        at javax.activation.DataHandler.writeTo(DataHandler.java:302)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1403)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:874)
        at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:444)
        at weblogic.xml.saaj.SOAPMessageImpl.writeMimeMessage(SOAPMessageImpl.java:959)
        at weblogic.xml.saaj.SOAPMessageImpl.writeTo(SOAPMessageImpl.java:832)
        at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:237)
        at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:144)



For more info see:

http://docs.oracle.com/javaee/5/tutorial/doc/bnbhr.html
http://docs.oracle.com/javase/6/docs/api/javax/activation/FileDataSource.html
http://docs.oracle.com/javase/6/docs/api/javax/activation/DataHandler.html


I would rather say that it could be all a LOT simpler.... Java Java...too verbose...

Wednesday, August 6, 2014

Java SOAP with Attachment in WebLogic

This is some code which more or less works:

import javax.xml.soap.*;
import java.net.URL;

String POSTTOURL = "http://yourhost:yourport/yourservice";

MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPHeader header = envelope.getHeader();
SOAPBody body = envelope.getBody();
...
set the body content here
...
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnectionFactory.createConnection();
java.net.URL endpoint = new URL(POSTTOURL);
SOAPMessage soapResponse = connection.call(message, endpoint);
out.write("soapResponse=" + soapResponse.getSOAPBody().toString());


The above code without any "body content" will generate this:
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"/>"
 operation="null"
 attachments="<con:attachments xmlns:con="http://www.bea.com/wli/sb/context"/>"
 outbound="null"
 fault="null"
 inbound="<con:endpoint name="BLA" xmlns:con="http://www.bea.com/wli/sb/context">
  <con:service/>
  <con:transport/>
  <con:security/>
</con:endpoint>"
 header="<soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"/>




I got this error message:
This class does not support SAAJ 1.1

Adding this in the setDomainEnv.sh for JAVA_OPTIONS seems to fix it:
-Djavax.xml.soap.MessageFactory=weblogic.xml.saaj.MessageFactoryImpl


See also document "Receive the Error "This Class Does Not Support SAAJ 1.1" when Running a P6 Web Services Application (Doc ID 1297252.1)" where they recommend:
JAVA_OPTIONS="${SAVE_JAVA_OPTIONS} 
-Djavax.xml.soap.MessageFactory=com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl 
-Djavax.xml.soap.SOAPConnectionFactory=weblogic.wsee.saaj.SOAPConnectionFactoryImpl"




Tuesday, August 5, 2014

stakeholders



this is becoming a popular term in IT.... let's see what Google says...

stake1
stāk/
noun
noun: stake; plural noun: stakes; noun: the stake
  1. 1.
a strong wooden or metal post with a point at one end, driven into the ground to support a tree, form part of a fence, act as a boundary mark, etc.


  1. 2.
historical
a wooden post to which a person was tied before being burned alive as a punishment.