For me it seems that there is more than one kinematic tree in the example.
Link1 -> Link3 is one tree
Link2 -> Link3 is another tree.
For testing you can try
Link1 -> Link2
Link2 -> Link3
Thanks for helping, but getting an exception by connecting two different Links (link1 and Link2) with one childLink (link3) is the main problem. Changing the joints between the links doesn't help me.
Posted data creates an illegal chain. You try to create 2 joints to the same link, which is not legal device since compilation requires to have a single base link in the kinematics chain.