• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confusing Question/Answer

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When a system exception happens ina bean and its holding resources, who is responsible to release resources?

the answer says, its container's responsibility but I think its neither container's nor bean provider's responsibilty because container just logs the error, rollback/mark transaction, discard the instance and wrap exception into EJBException and throw it back to client. It doesnt even call preDestroy method so Bean provider's responsibility also goes out of question.

Am I wrong or right?
 
Vinay Nath
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anybody???
 
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am too confused on it. But when I tried the same, on JBOSS, the predestroy method got executed. But the spec says that Pre-destroy may not be called.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is the container providers's role to release managed resources in this situation, when discarding the bean instance. Of course, unmanaged resources cannot be dealt by the container.

In the core specification, about the bean provider's responsability for system exceptions (14.2.2 System Exceptions), it is stated that the Bean Provider does not have to perform any cleanup actions before throwing a non-application exception. It is the container that is responsible for the cleanup.

You'll find even more details at the "14.3.11 Release of Resources" section, about the Container's responsability : When the container discards an instance because of a system exception, the container should release all the resources held by the instance that were acquired through the resource factories declared in the enterprise bean environment (See Subsection 16.7).
Note: While the container should release the connections to the resource managers that the instance acquired through the resource factories declared in the enterprise bean environment, the container cannot, in general, release �unmanaged� resources that the instance may have acquired through the JDK APIs. For example, if the instance has opened a TCP/IP connection, most container implementations will not be able to release the connection. The connection will be eventually released by the JVM garbage collector mechanism.
 
Vinay Nath
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help guys!!!

I hope in real exam, the questions will be much more specific, like managed-unmanaged resources.
 
reply
    Bookmark Topic Watch Topic
  • New Topic