Why isn't energy conserved in this collision problem? I am stuck in a question where energy conservation is failing and momentum conservation is correct. I think I might be doing something wrong, that's why I'm asking this question.
The problem is as follows:

A bullet of mass $25\,g$ is fired horizontally into a ballistic pendulum of mass $5.0\,kg$ and gets embedded in it. If the centre of pendulum rises by a distance of $10\,cm$, find the speed of the bullet.
(H.C. Verma, Centre of Mass, Q47)


Let the mass of the bullet be $m=25\,g$.
Let the mass of the pendulum be $M=5\,kg$.
Let the peak height be $h=0.1\,m$.
Let the initial and final velocities be $u$ and $v$ respectively.
Method 1: (Momentum Conservation)
$$mu=(M+m)v \implies v=\frac{mu}{M+m}\\ \text{Also, }\frac{1}{2}(M+m)v^2=(M+m)gh\\ \implies u^2=2\biggl(\frac{M+m}{m}\biggr)^2gh\\ \implies u=201\sqrt2 \text{ m/s}$$
Method 2: (Energy Conservation)
Since both the masses move together after the collision, and because the velocity at highest point is null, therefore:
$$\frac{1}{2}mu^2=\frac{1}{2}(M+m)v^2=(M+m)gh\\ \implies u^2=2gh\biggl(\frac{M+m}{m}\biggr) \implies u=\sqrt{402}$$

To summarize myself, I am curious about the following:
Why do the results differ? Shouldn't the energy be conserved as well as the momentum? Since it should be, then what is the flaw in my calculations?
 A: You can use energy conservation, but you have to take into account the heat produced by friction as the bullet entered the block, the rotational energy imparted into the mass itself in case the bullet hits it off-center, not to mention the energy used to deform both bullet and mass (does that automatically transfer into heat?) I'm sure i've missed a few as well.
It's theoretically possible, but not recommended.
A: As in another answer, it's just that some of the kinetic energy is spent on heating the bob of the pendulum.
Energy conservation figures in the calculations when either there is effectively zero energy converted into heat, as in, say, the gravitational interaction of celestial bodies; or the heat figures in the dynamics, such as in the propagation of a shock, or flow of gas along a duct.
A: Energy is conserved only in elastic collisions, which is not this case. You can think it as energy is dissipated as heat when the bullet hits the pendulum, thus it's conserved too, though that's not seems so clear.
The point of using momentum is precisely that we don't need worry about the heat transference of the system and get along using just the given data. Also, momentum gives us very usefull information over the direction of the resulting velocity, which isn't present at energy calculations.
Be aware that some problems must be solved using both momentum and energy conservation. 
A: The energy IS conserved .... And I urge you to ignore any answer that says it isn't since it can lead to confusion.
It just happens to be in heat/sound rather than kinetic; and since these aren't usually measured or included in the question details, there is not sufficient information to calculate using conservation of energy.
Were you told in the question that a soundwave of (say) 30J and heating of 50J was done to the system; then you could subtract that 80J from your speeding bullet energy and get the same answer.
A: 
Shouldn't the energy be conserved as well as the momentum?

But this is a perfectly inelastic collision, i.e., kinetic energy is not conserved (maximally not conserved in fact).
From the Wikipedia article Inelastic collision:

An inelastic collision, in contrast to an elastic collision, is a
  collision in which kinetic energy is not conserved due to the action
  of internal friction.
...
A perfectly inelastic collision occurs when the maximum amount of
  kinetic energy of a system is lost. In a perfectly inelastic
  collision, i.e., a zero coefficient of restitution, the colliding
  particles stick together.

