title: EJB and working with binary files - best practice
body: <p>We have two ways of keeping files - database or filesystem.</p>
  
  <p>So I have EJB, that can be connected to as from servlet as from java application. 
  The problem is with working with binary files. I found  <a href="http://www.oracle.com/technetwork/java/restrictions-142267.html" rel="nofollow noreferrer">here</a> that it's a restriction for EJB (NOT FOR OTHER JAVA EE CONTAINERS) to write/read files to/from filesystem. They say keep in database.</p>
  
  <p>Ok. I said. But <a href="https://softwareengineering.stackexchange.com/questions/150669/is-it-a-bad-practice-to-store-large-files-10-mb-in-a-database">here</a> and <a href="https://dba.stackexchange.com/questions/2445/files-in-the-database-or-not">here</a> everybody says that's a very bad idea. And I totally agree with it.</p>
  
  <p>Another solution is JCR in Apache Jackrabbit implementation. But I consider it as both of ways. <a href="http://wiki.apache.org/jackrabbit/DataStore" rel="nofollow noreferrer">Here</a> it says it keeps files also in filesystem.</p>
  
  <p>So what is the best practice? Why can't we write files to filesystem without JCR?</p>