How to read files and use JNI from EJB?

Discussions

EJB design: How to read files and use JNI from EJB?

  1. How to read files and use JNI from EJB? (1 messages)

    I need to read files stored on server's machine
    from my session bean but EJB specification prohibits
    any I/O operations with files.
    1. I would like to know reasons for this limitation
    2. The same question is for JNI usage
    3. As I understand that to make possible operations
    with files and JNI calls it is necessary to implement
    a resource adapter according to JCA. Which is add-on
    value in the resource adapter? What it is allowed to
    make native and file operations but EJB not?
    4. Could you advice some ready Resource adaptter implementations for performing file I/O operations?
  2. I have written EJBs that read the file system and start threads, both of which are "prohibited" by the spec (I haven't tried JNI, but I bet it works too). I don't think these limitations are necessarily enforced by the EJB container but are intended more as best practice advice.

    The idea is that an EJB is something that is intended to be extremely portable. Since the J2EE container is managing its deployment, you shouldn't assume it will be deployed in the presence of a particular file system or on a particular hardware architecture. This is sound advice for any Java programming if you intend to distribute your code to a large number of customers or run it in a highly dynamic environment.

    If, on the other hand, you know exactly where you'll be deploying this thing and you're the only one using it, you may not have these concerns.