Have you tried with org.jboss.seam.Component.getInstance(name) ?
No I haven't tried that, this module of my app is not using Seam managed transactions so I cannot use Seam facilities to tackle this problem. The UI module is the only module that uses Seam.
Sorry if I may have posted in wrong forum but the other JBoss forums have no response or very slow response times.
Just hoping someone had to deal with a similar problem before and share his experience.
Are you trying to access different databases dynamically?
Perhaps you can use EL expression as below instead of injecting multiple EntityManager instances via @PersistenceContext.
I've never tried the above code but give it a shot.
I have @In(jected) multiple EntityManager instances in the past with SMPC.
Since the @PersistenceContext or @In injection will execute prior to any method calls on your session bean, you won't need to pass a param to your method.
And I don't think your following concern is valid:
What I don't like about this approach is the side effect of having all entityManagers join the active transaction even if only one of them is used.
AFAIK, EntityManager instances are used in isolation of one another unless there's a XA/2PC distributed transaction that occurs...
Another option is to create separate session beans for each EntityManager and call the correct session bean accordingly.