I have an EJB marked as a web service using the @WebService annotation. At the moment, this EJB is being packaged into an EAR file without an additional WAR file.
I'm trying to persuade the container to inject an instance of Ehcache into my EJB. I don't know anything about Seam, and would prefer not to have to learn it. However, following examples I found via Google, I attempted to achieve my goal by putting a components.xml file where the ClassLoader can find it, and including
protected EhCacheProvider provider
at the top of my class definition. JBoss didn't complain about anything, but the 'provider' field was never initialized. I'm guessing this is happening because I'm trying to use Seam without really understanding it.
The following code, on the other hand, works beautifully:
However, I'm guessing this is not really what I want, since the container isn't managing the CacheManager or the Cache.
My goal is to persuade the container to initialize a CacheManager (or even better, a Cache configured from my ehcache.xml), and keep it around forever. I'm using the cache to hold POJOs which have nothing to do with Hibernate. Is it possible to do this without Seam? Is it possible to do without creating a WAR file separate from my EJB?