The old EJB-QL compiler in 3.0beta did not print error messages when it was passed bad ejb-ql.
My guess is that o.divisao is collection valued or o.divisao.id is not the same type as parameter 1 (EJB-QL is strongly typed).
If you can't figure it out, try the new EJB-QL compiler is CVS (yes, you will have to build from source).
The problem was with <declared-sql> elements. Once I removed all <declared-sql>'s, the problem was gone. I think I got the wrong idea about this element. I'll look into the new JBoss-QL to do sorting.