I used a similar fix on my '08 works great for awhile but after some time and the opening and closing of the doors and summer heat the foam breaks down and glue falls off. I looked for rubber weather stripping to use in the place of the foam but couldn't find one that would work in this area. After i installed the metal header channel my leaks stopped, but it appears from the interior photo you have a '11 plus Jeep. Another member on here had his leak in the area you took a photo of and he had his doors adjusted and his leak stopped.
2008 Black X 2" Rusty's lift, 33's XRC rear Bumper ( Traded in on Arctic)
2012 Arctic Edition (Traded in on Truck )