I've been reading a number of web pages and blogs that show how to use an EntityManager in a
servlet, and yet I have been unable to get a single example to work
In an existing
J2EE application, deployed to
JBoss, I can from any EJB do the following:
And it just works. However, if I try the same thing from a servlet (in the same J2EE application):
It fails with a NullPointerException because em never got injected (and JBoss never complained, either)
If I try it like this:
I get javax.naming.NameNotFoundException: persistence not bound
I've tried it with a persistence context ref in web.xml and without. It seems to make no difference whatsoever!
The whole JNDI "magical incantation" thing has always driven me up the wall, but this is sheer madness! How is one ever supposed to know what magical
string value to use where?