You have a distribution

(1)
\begin{align} W(\text{a})=\frac{\mathscr{A}!}{\prod_ja_j!}\prod_j\Omega^{a_j} \end{align}

with the constraints

(2)
\begin{align} \sum_ja_j&=\mathscr{A}\\ \sum_ja_jE_j&=\mathscr{E} \end{align}

Now, you have the logarithm of your distribution (using Stirling's approximation in the second equality)

(3)
\begin{align} \ln W(a_j)=\ln{\mathscr{A}!}+\sum_ja_j\ln{\Omega_j}-\sum_j\ln{a_j!}=\mathscr{A}\ln{\mathscr{A}}-\mathscr{A}+\sum_ja_j\ln{\Omega_j}-\left(\sum_ja_j\ln{a_j}-a_j\right) \end{align}

Then, the Lagrangian of optimization is

(4)
\begin{align} \mathscr{L}=\ln{W(a_j)}-\alpha\left(\sum_ja_j-\mathscr{A}\right)-\beta\left(\sum_ja_jE_j-\mathscr{E}\right) \end{align}

Taking the derivative with respect to $a_j$

(5)
\begin{align} \frac{\partial\mathscr{L}}{\partial a_j}&=\left[\frac{\partial\left(\mathscr{A}\ln{\mathscr{A}}-\mathscr{A}\right)}{\partial a_j}\right]+\left[\frac{\partial\left(\sum_ja_j\ln{\Omega_j}\right)}{\partial a_j}\right]-\left[\frac{\partial\left(\sum_ja_j\ln{a_j}-a_j\right)}{\partial a_j}\right]-\alpha-\beta E_j=0\\ &=\left(\ln{\mathscr{A}}+1\right)+\left(\ln{\Omega_j}\right)-\left(\ln{a_j}+1\right)-\alpha-\beta E_j=0 \end{align}

Rearranging you have

(6)
\begin{align} \ln{\frac{\mathscr{A}}{a_j}}=\alpha+\beta E_j-\ln{\Omega_j}\qquad\qquad\text{or}\qquad\qquad\ln{\frac{a_j}{\mathscr{A}}}=\ln{\Omega_j}-\alpha-\beta E_j \end{align}

Taking the exponential and summing over $j$:

(7)
\begin{align} \sum_j\frac{a_j}{\mathscr{A}}=1=\sum_j\Omega_je^{-\alpha}e^{-\beta E_j} \end{align}

where $e^{-\alpha}=\left(\sum_j\Omega_je^{-\beta E_j}\right)^{-1}$ and $\beta=1/k_BT$. Finally you have the answer:

(8)
\begin{align} a_j^*=\frac{\Omega_je^{-E_j/k_BT}}{\sum_j\Omega_je^{-E_j/k_BT}} \end{align}