Optimality conditions for a nonlinear stochastic knapsack problem