This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EE and resource lookup etc.  RSS feed

 
martin mucha
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm facing a problem with obtaining entitymanager on tomcat now. I really need to solve this, but that's not the question I want to ask. The problem is more general.

Every java book I read, and there was plenty of them, focused mainly on most simple cases just to be able to show how easy it is. But it's NOT that easy. So is there any location where is summarized, what objects are managed in which containers, which container uses what jndi path to lookup an entity manager for example or what configuration has to be made to be able to do so? I would like to read it not to bother others with my questions...

My actual problem is (now) to be able to get anyhow entity manager in tomcat 6 servlet (is it managed or not?), but I think I have to be able to obtain it elsewhere also (and I can not rely on passing entity manager from another location).

thanks in advance,
martin
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch.

martin mucha wrote:... focused mainly on most simple cases just to be able to show how easy it is. But it's NOT that easy.n


The reason the books focus on simple cases is that everyone's application is different, so it is extremely difficult to come up with a detailed example that will apply to a large audience.
Just to be sure, you are not attempting to deploy an EJB application on Tomcat, right? Tomcat does not implement the complete Java EE specification. It's only a servlet container. If you give us a better idea of what you are doing, perhaps we can be of some help.
 
martin mucha
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the answer.

Yes, I know that its not easy to come up with detailed example in situation when for example JNDI paths for session beans, hope I'm right now, was not standardized allowing configurations to be different on each vendor. But its highly misleading to pronounce "it's easy" when it's definetely not when you planning to create something "bigger" which should work in many containers. So this question asked about presence of some advanced book/article/page discussing using different AS and their specialities.

No no, I'm not trying to deploy EJB application on tomcat, I'm aware it's not fully compliant EE server. I have here SE app (which uses EntityManager with resource-local transaction type), which I need to integrate to some webapp.
---
The rough dea is: I obtain EntityManager or EntityManagerFactory somehow and will controll transactions manually, similary as I do in SE.
The problems:

First one:

I probably should be able to create entityManager like
EntityManagerFactory emf = Persistence.createEntityManagerFactory("pu");
with
<persistence-unit name="pu" transaction-type="RESOURCE_LOCAL">

but, as I've read, this won't work on Glassfish for example, which prohibits usage of RESOURCE_LOCAL transaction-type.

Second one:

since tomcat does not, as I've read, support JTA, trying to use UserTransaction won't spell any success.


The question: is there a way *how* to create webapp using EntityManager which runs on glassfish and on tomcat (after some reconfiguration of datasource etc)?

 
martin mucha
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again.

I spend now like three days trying just to get EntityManager in servlet in Tomcat 6. As desperation grows, I do not care anymore about compatibility among AS. Is there anyone who actually saw EntityManager working in Tomcat AND who is willing to answer few questions? (where and how configure datasource, how to configure persistence.xml and how to obtain EntityManager).

thanks in advance.
martin.

Ps. I tried walkthroughs like
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial
and many more, but with no success, so I would like if someone could help me in interactive mode
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!