• Post Reply Bookmark Topic Watch Topic
  • New Topic

slsb using connection in ejbCreate

 
Mark Lybarger
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm trying to find in the spec if using a db connection obtained from a datasource is regulated in ejbCreate. we have a bean that uses a connection in ejbCreate to just get some static data and cache it away.

the closest i can find is in 7.8.3 of the ejb 2.0 spec (next to last bullet) where it discusses that accessing a resource manager during a method which no transactional context is available is disallowed.

does the effectively mean that a slsb cannot use a connection during ejbCreate? what's wrong with just selecting some data from a db? is this similar to the filesystem restriction, or the static variable restriction (all must be final) where it's most likely going to be ok?

thoughts, comments? thanks!
 
Brian Tinnel
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do think it is like file access and statics. In other words, nothing will prevent you from doing it, but it might not be wise to do it. I would think that it is possible that some app servers could actually prevent you from accessing a Resource Manager during ejbCreate. So, while you might be able to do it, you aren't guarateed that the next version of your app server, or a different app server, will allow it.

I usually implement some form of lazy initialization for those types of fields so that the first access fills them in.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!