If the bean is Singleton then having 100 different process instances call the same methods is a not a good idea(most of them will time out while waiting for somebody else to finish his call of the method).
It is the same with the Statefull, if I set the JndiObjectFactoryBean to cache the object - i get the same object, but this leads to the same exception. If statefull and cache off It will throw "method not found" exceptions (something with the proxy gets broken).
If stateless - works, but every call to the bean is creating a new object and injecting everything necessary in it, which is slow.
So:
1. Using JndiObjectFactoryBean:
Singleton - cache on - only one global object, timeout exception when several threads try to call the same method
Singleton - cache of - only one global object, timeout exception when several threads try to call the same method
Statefull - cache on - only one global object, timeout exception when several threads try to call the same method
Statefull - cache off - many objects, method not found exception
Stateless - cache on - huge amount of objects get created, works
Stateless - cache off - not tested, but i think the result will be like "Stageful no cache"
2. Using the class name directly (<bean id="core" class="com.packageName.Core">
The object does not get created as a bean at all, so nothing gets injected(i need to manually find the references to the helper beans by using JNDI), also only one object is created and reused so no pooling at all.
What is the recommended way to call methods in EJB's when there is also high concurrency?