Reading data from file in EJB

I would like to read data from files in EJBS (Stateless Session Bean I think). I've heard that the EJB sepcifications don't allow to use the package to access the filesystem. How can I resolve this problem? Possible solutions I've thought of are:
* Use a webserver to store the data
* put the files in a jar and access them using the getResource() in the classloader class
Could you comment on this plesae

The specification states:
"An enterprise bean must not use the package to attempt to access files and directories in the file system.
The file system APIs are not well-suited for business components to access data. Business components should use a resource manager API, such as JDBC, to store data."
From this I understand I cannot acces files directly, but it does not specifiy I can't use the package at all. It specifically says not to use the package to acces files and directories, they don't say anything about using the classes for other use.
however, a litle lower the specification states:
"The enterprise bean must not attempt to create a class loader; obtain the current class loader; set the context class loader; set security manager; create a new security manager; stop the JVM; or change the input, output, and error streams.
These functions are reserved for the EJB Container. Allowing the enterprise bean to use these functions could compromise security and decrease the Container�s ability to properly manage the runtime environment."
I'm not sure how to interpret this, but I believe this rule makes my solution invalid.
Please comment on this,

Similar Messages

  • How to read data from a file in OSB

    hi guys,
    Recently, I've got a problem with reading file from specific location. I've actually followed this post OSB 11g - Read or Poll File in OSB - Oracle Fusion Middleware Blog, and then
    I know how to read a file. However, it does not as expected. Because, I've found no way to read data from the file. Therefore, no chance to manipulate the data like assigning to a variable, or extracting ....
    Hence, is there any way to read data from file by using proxy service in OSB ??? No Java code ???
    by the way, supposed that there is no way to read data from a file in OSB. So, What purposes will the way in the post above be used for?
    Many thanks in advance
    HSSF stands for Horrible Spreadsheet Format, but it still works!

  • View Object to read data from a java file

    I am using JDeveloper and ADF-BC in my application.
    For one of my view objects , I want the data to be read from a java file which exposes some method to return a collection.
    I cannot use a static view object in this case.
    Please suggest the best way to implement this requirement.Basically build a view object that should read data from a java file.

    Depending on your use case you can either use a programmatic VO or directly expose the JV class as a data control.

  • How to read data from multiple files and append in columns in one file

    Hi Guys,
    I have a problem in appending data from files in different columns. I have attachement has file A and B which I am reading and not able to get data as in file Result.txt. Please comment on how can I do this
    Go to Solution.
    Write to ‏13 KB
    A.txt.txt ‏1 KB
    B.txt.txt ‏1 KB

    You cannot append columns to an existing file. Since the data is arrange line-by-line as one long linear string in the file, you can only append rows. A new row needs to be interlaced into the original file, shifting everything else. If you want to append rows, you need to build the entire output structure in memory and then write all at once.
    (I also don't think you need to set the file positions, it will be remembered from the last write operation.)
    Unless the files are gigantic, here's what I would do:
    (Also note that some of your rows have an extra tab at the end. If this is normal, you need a little bit more code to strop out empty columns. I include cleaned up files in the attachment. I also would not call them A.txt.txt etc. A plain A.txt is probably sufficient.)
    EDIT: It seems Dennis's solution is similar )
    LabVIEW Champion . Do more with less code and in less time .
    Write to ‏6 KB
    MergeColumns.png ‏6 KB

  • Read data from a text file, one line at a time.

    I need to read data from a text file, and display each line in a String Indicator on Front Panel. It displays each line, but I get Error 4, End Of Line, unless I enter an extra line of data in the file that I don't need. I tried Read From Text, made by Nat Instr, and it gave the same error.

    The Read from Text reads data from a text file line by line until the user stops the VI manually with the Stop button on the front panel, or until an error (such as "Error 4, End of file") occurs. If an error occurs, the Simple Error pops up a dialog that tells you which error occurred.
    The Read from Text uses a while loop, but if you knew how many lines you wanted to read, you could replace the while loop with a for loop set to read that many lines from the file.
    If you need something more dynamic because the number of lines in your files vary, then you could change the code of the Read from Text to the expect "Error 4, End of file" and handle it appropriately. This would require unbundling the error cluster that comes fro
    m the Read File function with the Unbundle By Name function, so that you can expose the individual error "status" and error "code" values stored in the cluster. If the value of the error "code" is 4, then you can change the error "status" from true to false, and you can rebundle the cluster with the Bundle by Name function. Setting the error "status" to false instructs the Simple Error Handler to ignore the error. Otherwise, pass the original error cluster to the Simple Error, so that you can see what the error is.
    Of course, if you're not interested in what the errors are, you could just remove the Simple Error, but then you wouldn't see any error messages.
    Best of Luck,
    Dieter Schweiss
    Applications Engineer
    National Instruments

  • How to read data from a file that was formatted by excel?

    Hi everyone, I'm familiar with and the ability to read from files, can anyone tell me how to read data from a file that was formatted by excel? Or at least give me some web references so that I can learn about it?
    HSSF stands for Horrible Spreadsheet Format, but it still works!

  • How to read data from a zipped MS Access file?

    How to read data from a zipped MS Access file?

    You do not need to use the Close Zip when you unzip a folder.  This VI is used when you are creating a zip folder.
    As for examples, I found a couple of ActiveX based MS Access examples.  These programs look to be pretty basic.  For more in depth example I would search Microsoft Developers Network
    Jon S.
    National Instruments
    LabVIEW R&D

  • Reading Data from a SQL table to a Logical file on R/3 appl. Server

    Hi All,
    We would like to create Master Data using LSMW (direct Input) with source files from R/3 Application Server.
    I have created files in the'/ tmp/' directory however I do not know how to read data from the SQL table and insert it into the logical file on the R/3 application server.
    I am new to ABAP , please let me know the steps to be done to acheive this .
    - Ajay

    You can find lot of information about Datasets in SCN just SEARCH once.
    You can check the code snippet for understanding
    BEGIN OF fs,
      carrid TYPE s_carr_id,
      connid TYPE s_conn_id,
    END OF fs.
      itab    LIKE
              TABLE OF fs,
      w_file  TYPE char255 VALUE 'FILE',
      w_file2 TYPE char255 VALUE 'FILE2'.
    SELECT carrid connid FROM spfli INTO TABLE itab.
    OPEN DATASET w_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
                                                            " Server to write data
    LOOP AT itab INTO fs.
      TRANSFER fs TO w_file. "" Writing the data into the Application server file
    CLOSE DATASET w_file.
    OPEN DATASET w_file FOR INPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
                                                          " server to read data
    FREE itab.
      READ DATASET w_file INTO fs.
      IF sy-subrc EQ 0.
        APPEND fs TO itab.
        OPEN DATASET w_file2 FOR APPENDING IN TEXT MODE ENCODING DEFAULT. "Appending more data to the file in the
                                                           " application server
        TRANSFER fs TO w_file2.
        CLOSE DATASET w_file2.

  • Reading data from an excel file

    I want to read data from the excel file and display it in
    jsp page. Iam getting the following error:
    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    Connection con =
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery("select * from [holidays$]");
    Here i have created the dsn with the name "mydsn". I have the
    following data in the mydsn.dsn file:
    DRIVER=Microsoft Excel Driver (*.xls)
    FIL=excel 8.0
    thanks in advance

    You might want to look at the POI project (an open source Jakarta sub-project) that allows you to create/modify/read excel files via Java code. That might be more flexible and easier than what you're currently trying to do.

  • GUI_UPLOAD to read data from an Excel File

    Hi Folks,
    I'm using FM GUI_UPLOAD to read data from an Excel File. But all I see in the table returned is 1 row with garbage values (special chacaters). Excel Workbook has proper data in the sheet, but its not getting uploaded properly. Sy-subrc is 0.
    What could be the reason?

    See the example program to get from XLS file to Internal table
    REPORT ZLWMI151_UPLOAD no standard page heading
                           line-size 100 line-count 60.
    *tables : zbatch_cross_ref.
    data : begin of t_text occurs 0,
           werks(4) type c,
           cmatnr(15) type c,
           srlno(12) type n,
           matnr(7) type n,
           charg(10) type n,
           end of t_text.
    data: begin of t_zbatch occurs 0,
          werks like zbatch_cross_ref-werks,
          cmatnr like zbatch_cross_ref-cmatnr,
          srlno like zbatch_cross_ref-srlno,
          matnr like zbatch_cross_ref-matnr,
          charg like zbatch_cross_ref-charg,
          end of t_zbatch.
    data : g_repid like sy-repid,
           g_line like sy-index,
           g_line1 like sy-index,
           $v_start_col         type i value '1',
           $v_start_row         type i value '2',
           $v_end_col           type i value '256',
           $v_end_row           type i value '65536',
           gd_currentrow type i.
    data: itab like alsmex_tabline occurs 0 with header line.
    data : t_final like zbatch_cross_ref occurs 0 with header line.
    selection-screen : begin of block blk with frame title text.
    parameters : p_file like rlgrap-filename obligatory.
    selection-screen : end of block blk.
      g_repid = sy-repid.
    at selection-screen on value-request for p_file.
                PROGRAM_NAME = g_repid
                FILE_NAME    = p_file.
    Uploading the data into Internal Table
      perform upload_data.
      perform modify_table.
        FLEX_TEXT1       =
        FLEX_TEXT2       =
        FLEX_TEXT3       =
    *&      Form  upload_data
    FORM upload_data.
                FILENAME                = p_file
                I_BEGIN_COL             = $v_start_col
                I_BEGIN_ROW             = $v_start_row
                I_END_COL               = $v_end_col
                I_END_ROW               = $v_end_row
                INTERN                  = itab
                UPLOAD_OLE              = 2
                OTHERS                  = 3.
      IF SY-SUBRC <> 0.
        write:/10 'File '.
      if sy-subrc eq 0.
        read table itab index 1.
        gd_currentrow = itab-row.
        loop at itab.
          if itab-row ne gd_currentrow.
            append t_text.
            clear t_text.
            gd_currentrow = itab-row.
          case itab-col.
            when '0001'.
              t_text-werks = itab-value.
            when '0002'.
              t_text-cmatnr = itab-value.
            when '0003'.
              t_text-srlno = itab-value.
            when '0004'.
              t_text-matnr = itab-value.
            when '0005'.
              t_text-charg = itab-value.
      append t_text.
    ENDFORM.                    " upload_data
    *&      Form  modify_table
          Modify the table ZBATCH_CROSS_REF
    FORM modify_table.
      loop at t_text.
        t_final-werks = t_text-werks.
        t_final-cmatnr = t_text-cmatnr.
        t_final-srlno = t_text-srlno.
        t_final-matnr = t_text-matnr.
        t_final-charg = t_text-charg.
        t_final-erdat = sy-datum.
        t_final-erzet = sy-uzeit.
        t_final-ernam = sy-uname.
        t_final-rstat = 'U'.
        append t_final.
        clear t_final.
      delete t_final where werks = ''.
      describe table t_final lines g_line.
      sort t_final by werks cmatnr srlno.
    Deleting the Duplicate Records
      perform select_data.
      describe table t_final lines g_line1.
      modify zbatch_cross_ref from table t_final.
      if sy-subrc ne 0.
        write:/ 'Updation failed'.
        Skip 1.
        Write:/12 'Updation has been Completed Sucessfully'.
        skip 1.
        Write:/12 'Records in file ',42 g_line .
        write:/12 'Updated records in Table',42 g_line1.
      delete from zbatch_cross_ref where werks = ''.
    ENDFORM.                    " modify_table
    *&      Form  select_data
          Deleting the duplicate records
    FORM select_data.
      select werks
             srlno from zbatch_cross_ref
             into table t_zbatch for all entries in t_final
             where werks = t_final-werks
             and  cmatnr = t_final-cmatnr
             and srlno = t_final-srlno.
      sort t_zbatch by werks cmatnr srlno.
      loop at t_zbatch.
        read table t_final with key werks = t_zbatch-werks
                                    cmatnr = t_zbatch-cmatnr
                                    srlno = t_zbatch-srlno.
        if sy-subrc eq 0.
          delete table t_final .
        clear: t_zbatch,
    ENDFORM.                    " select_data

  • Help! How to read data from an Excel file?

    I need to read data from an Excel file that may contain more then one table in a sheet. How can I read them?
    I would be eternally grateful to anyone who can give me any information.

    Did you try POI from Apache?

  • Static lookup lists:read data from a Java *.properties file

    i need to make static lookup lists i am using read data from a Java *.properties file
    i am using the Class "PropertyFileBasedLookupViewObjectImpl" that wrote by Steve Muench in ToyStore.
    but i need to use the default language for that i update the loadDataFromPropertiesFile()
    method to find the correct properties file
    String temp=Locale.getDefault().getLanguage();
    String propertyFile =
    getViewDef().getFullName().replace('.', '/')+"_"+temp+ ".properties";
    the problem:
    For English( it is good and working
    For Arabic( read from correct file
    but the dispaly character is wrong
    When Debug
    In the File 1=&#1583;&#1605;&#1588;&#1602;
    In debug 1=/u32423

    Depending on your use case you can either use a programmatic VO or directly expose the JV class as a data control.


    I have a file.I want to read the data from file and load it into a table using utl_file.
    how can I do it?
    Any reply apreciated...

    This is not your requirment but u can try this :
    GRANT READ ON DIRECTORY text_file TO fah;
    GRANT WRITE ON DIRECTORY text_file TO fah;
    DROP TABLE load_a;
    CREATE TABLE load_a
    (a1 varchar2(20),
    a2 varchar2(200))
    LOCATION ('data.txt')
    select * from load_a;
    CREATE TABLE A AS select * from load_a;
    Faheem Latif

  • How to read data from a file that is already open by another program

    I have made IV, where I'm trying to read data from a log file, that is being updated by another program while my IV runs.
    To be clear, this program writes data continuously to this file and I want to read from the file in LV at the same time.
    The problem is that LV reports an error when I'm trying to read the log file, even if I use to "read only" mode.
    I believe that the program that is producing the file, have some kind of lock on the file. I have tryed to copy the file and then reading from the copied file, but LV throws already an error when I try to copy the file.
    Has anyone tryed this, and found a solution.?
    Additional info: The program that produces the file is STM Studio 
    Best Regards

    Hi Alha,
    when that file is locked by the other program you can't do anything about that - apart from quitting that other program. Probably this isn't an option to you…
    Best regards,
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Read data from a log file to flex textarea while deploying

    I am new to flex. I am able to read data from a log file that placed in C drive and able to write that data into flex textarea, but I am unable to read the same file while it is deployed into weblogic sever.
    Could anyone please tell me how to solve this problem.

    Do you have it trying to read that same file on your C drive or is the file actually deployed somewhere on the server?

Maybe you are looking for

  • OS/X Lion 10.7.2 kernel panic - freezes & crashes continue

    Just using Safari (with a remote session in the background), I had a full kernel panic & crash - the one where it tells you that you have to reset the power. I've a 24" iMac ( early 2009 ) NVIDIA GeForce GT 130 512 MB Lion 10.7.2. So it's not just yo

  • JBO-33035: Row currency has changed; Using snapshots from another DB

    I receive this error due to a snapshot performing a complete refresh. It is not due to the user hitting the Back button in the browser. How can you get around this scenario. The page has been rendered, the user navigates somewhere else via some link,

  • Macbook keyboard left/right arrow keys don't work

    Hello everyone, First time here and first time to touch a Macbook - I'm in IT but on the other side of the fence. My partner's laptop is a Core2-Duo @ 2GHz which I've stuck 4GB of RAM and a newer SATA HDD into, I've also updated the firmware just in

  • What is a the definition for VPN setting?

    What is a VPN setting?

  • Error / sucess message in processes

    got kind of a 'stupid' question: I updated a page (which contains a list) and set error/sucess messages for an insert/delete process (after submit) which is called everytime the user enters data in the list or deletes a record from the list. But the