Is this linear optimal control problem uncontrollable? If someone could help me with this problem I would be greatly appreciative.

Control the system
  $$\dot{x}=x+u$$
  From $$x(0)=0 \space to\space x(T)=2$$ 
  Where $T\in\mathbb{R}_+$ is free
s.t. 
  $$J=\int_{0}^{T}\frac{1}{2}u^2dt$$ is minimised.

My Approach
Let
$$
\\f_0(t,x,u)=\frac{1}{2}u^2
\\f_1(t,x,u)=x+u
$$
The Hamiltonian of this problem is given by:
$$
\\H=-f_0+\psi \times f_1
\\=-\frac{1}{2}u^2+\psi(x+u)
$$
By the PMP we wish to choose $u$ s.t. it maximises $H$,
$$
\\\frac{\partial H}{\partial u}=0
\\\Rightarrow\psi=u
$$
The costate equation gives us
$$
\\\dot\psi= -\frac{\partial H}{\partial x}
\\\Rightarrow\dot\psi=-\psi
\\\Rightarrow\psi=Ae^{-t}
$$
Subbing this back into the system gives
$$
\\x(t)=Be^{t}-\frac{A}{2}e^{-t}
\\u(t)=Ae^{-t}
$$
Now along the optimal trajectory, again by the PMP, $H$ must be $0$. As this applies along any point of the trajectory, we have (after a bit of algebra)
$$
\\H(t=0)=0
\\\Rightarrow A = 0 \space or \space B = 0
$$
Now this is where I am confused, if $A=0$ or $B=0$ we have 
$$x(t) = -\frac{A}{2}e^{-t} \space or \space x(t) = Be^{t} $$
But given $x(0)=0$ that would imply that in both cases $x(t)=0$. Which clearly does not give the optimal solution as it will never reach $x(T)=2$.
I'm not sure if I have made some fundamental error along the way, or if the system is just not controllable, but would appreciate some guidance either way.
 A: OK, you started well, but then something went wrong. You've found $u(t)=\psi(t)$. That's right. The equation for $\psi(t)$ is correct either. I'll just write it as $\psi(t)=\psi_0 e^{-t}$, where $\psi_0=\psi(0)$.
Then you substitute your $u(t)=\psi(t)$ into the DE for $x$, i.e., $\dot{x}=x+\psi_0e^{-t}$, and solve it to get $$x(t)=x_0e^t + \int_0^t e^{t-\tau}\psi_0 e^{-\tau}d\tau=x_0 e^t + \psi_0 \frac{e^t-e^{-t}}{2}.$$
Taking into account that $x(0)=0$ and using some hyperbolic trigonometry notation we obtain $$x(t)=\psi_0 \sinh(t).$$
It remains to sustitute the final time $T$ and solve the preceding equation to get $\psi_0=\frac{2}{\sinh(T)}$ whence you can compute the optimal control etc.
ADDED: Assume now that $T$ is free. We can compute the cost function $J=\frac{4}{e^{2T}-1}$, which attains minimum at $T\to \infty$ which is equivalent to $\psi_0=0$ and hence, $u(t)=0$. This implies that the problem does not have a solution. 
It is interesting that for $T>5$ the cost $J$ becomes infinitesimally small, so one can get a practically optimal solution by setting  $T$ to an arbitrary constant larger than 5. But this is a different story.
