This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes What does Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "What does "managed environment" really mean?" Watch "What does "managed environment" really mean?" New topic
Author

What does "managed environment" really mean?

Ylva Degerfeldt
Ranch Hand

Joined: Feb 12, 2008
Posts: 30
Hi everyone,

This might look like a "stupid question" but I still have to ask it since I'm rather confused about it..

What does "managed environment" really mean? (The reason I need to know that right now is because I want to learn how to write a correct Hibernate config. file, but I'll ask more about that in a more appropriate forum.)

I'm currently doing a thesis where I'm investigating what the benefits are of using the Struts and Hibernate frameworks, compared with using just JSPs, servlets and EJBs.

I've already finished my version without the frameworks and now I'm trying to transform it into using Struts and Hibernate. I think I shouldn't use EJBs in this version, so then I guess I have to use a lot of POJOs instead (plus some configuration files and the Struts form- and action classes and JSPs of course).
So now I'm wondering: Am I using a managed or non-managed environment?

I was thinking that regular Java classes (POJOS) always are non-managed, but then I read (in some book or article) some examples (but not enough) of what "managed environment" means and one of those examples was "code which runs on an application server" - and I'm not entirely sure that my POJOs don't do that.

I just know that EJB containers mean "managed code" and the book "Hibernate in action" says that a servlet container is a "non-managed environment".

So the real question for me is: Should I use Hibernate configuration for a non-managed environment? (I think the answer is Yes but I'm not completely sure.)

I'd be very happy if someone could shred some light on this issue for me.

Thanks in advance!

/Ylva
Ylva Degerfeldt
Ranch Hand

Joined: Feb 12, 2008
Posts: 30
I forgot to add that I'm using the Sun Application Server 9, and that's a big part of why I'm confused about this matter ('cause I don't know everything that's happening "under the surface" there).

/Ylva
Roland Thomas Lichti
Greenhorn

Joined: Jul 19, 2008
Posts: 4
"Managed environment" has two dimensions:

managed connections (to databases for example)

managed transactions (which normally means managed connections, too).


Container Managed Transactions are used in EJBs, servlets are always non-transactional (ok, you can use user transactions, but than the environment is not managed).

For servlets it is possible to use the application server to get the database connection (via JNDI) - then the AS manages the connection for you and does the pooling and so on. Or you can use JDBC directely - then it is unmanaged.

If it comes down to hibernate it depends: do you configure hibernate to use JDNI to get the database connection, you have a managed connection - if you don't use JNDI you have not a managed environment.

Hope this answer helps at least a little bit.

bye,
Roland
Ylva Degerfeldt
Ranch Hand

Joined: Feb 12, 2008
Posts: 30
Thanks for the reply, Roland!

Yes, it helped a bit. Then I'm using a non-managed environment (for Hibernate) according to an example I've looked at. But the rest of my questions will be about Hibernate so I'll ask them on the Object Relational Mapping forum.

Thanks again!

/Ylva
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What does "managed environment" really mean?