You can set the entityManagerJndiName or entityManagerFactoryJndiName in the @ServerFilter annotation (note: it's definitely missing in the docs...)
It's not sure that Tomee puts the EMF in a global JNDI by default, thus it may be also necessary to add a persistence-context-ref in web.xml.
Next your example will not work as is. Collection loading is an asynchronous operation and you have to use a callback to iterate over the elements:
for (Account account : futurResult.get().getResultList()) {
Iterator<Box> iterator = account.getBoxes().iterator(); => does not work
}
for (Account account : futurResult.get().getResultList()) {
((PersistentCollection)account.getBoxes()).withInitialized(new InitializationCallback() {
public void call(PersistentCollection boxes) {
Iterator<Box> iterator = boxes.iterator();
}
});
}
or in Java 8:
for (Account account : futurResult.get().getResultList()) {
((PersistentCollection)account.getBoxes()).withInitialized(boxes -> { Iterator<Box> iterator = boxes.iterator(); ... });
}