Reading file in deployment enviroment

Hi,
I need to read the file "ftest" in the folder "D:\installable\tomcat\jakarta-tomcat-5.0.19\webapps\LocMod". Is it possible to give relative path in Filereader()? As per my examination, tomcat 5.0 is taking only the absolute path in the Filereader(), which won't be helpful in the production environment. If i have to read the file by giving the relative path, How can i achieve that?
I have given my code here:
Html content:
<form ACTION="http://localhost:8080/LocMod/LocServlet"
ENCTYPE="x-www-form-urlencoded">
java servlet:
public class LocServlet extends HttpServlet {
     protected void doGet(
          HttpServletRequest request,
          HttpServletResponse response)
          throws ServletException, IOException {
               PrintWriter out = response.getWriter();
               out.println("here servlet\n");
               System.out.println("path:>:" + getServletContext().getRealPath("/"));
               //BufferedReader in = new BufferedReader(new FileReader("D:\\ftest")); //OK
               //BufferedReader in = new BufferedReader(new FileReader("..\\webapps\\LocMod\\ftest")); // Not OK
               //BufferedReader in = new BufferedReader(new FileReader(getServletContext().getRealPath("/")+ "\\ftest")); //OK
               BufferedReader in = new BufferedReader(new FileReader("ftest")); //not OK
               String str;
               while((str = in.readLine()) != null)
                    out.println(str);
               in.close();
Thanks.
Best regards,
Lakshmi

I think the best thing to do is to put that file in the CLASSPATH (e.g., WEB-INF/classes) and use the ServletContext.getResourceAsStream() method to get an InputStream for reading. That'll work even if you package your app in a WAR file. I think it's the path-independent way to go.

Similar Messages

  • Where to get Reader 9 MSI-file for deployment?

    Hu all,
    where can I get the fitting MSI file for deploying Reader 9?
    There's only the EXE file from Adobe to get.
    Please help.
    Regards
    Davorin

    Well, Adobe support has answered that is an issue of free software and thus not supported.
    Great!
    But I think I found a solution by myself:
    After installation there's a directory:
    C:\Program Files\Adobe\Reader 9.0\Setup Files
    where a msi file is located.
    I will try to copy the whole dir and test, if this is enough for deployment.

  • Can the aTV read files from an iTunes library on my nas drive without my computer being on

    I have my itunes library on a My Book Live nas drive that contains all of my digital movies and TV shows. I want to be able to watch my movies from the library without a computer running. I understand that Apple has chosen to chain you to the computer and your itunes account through Home Sharing but I can not see why they couldn't allow you to access a nas drive without a computer running because your aTV is tied to your itunes account also so why do they force you to run a computer 24/7 365 in order to access the files you have bought and paid for.
    I have a love/hate for Apple because I love the quality of the products they make but I hate how they make all of the digital files you purchase only accessible through a computer running Home Sharing even though the files are not stored on the computer.
    I have tried several things to get this to work without a computer but no luck. The only way I have found to be able to do this is to Jailbreak your aTV and install 3rd party software (which I don't want to do) that will allow you to by pass the computer and Home Sharing (which is dumber than ****) because that is all I want to do is eliminate the need of a computer running wasting electricity (I thought Apple was supposed to be an enviro friendly company, guess not). I am not trying to steal or give someone else my purchased movies and using the aTV and an internet connection they could still be able to tie your media to your itunes account so I just don't get there thinking, or lack of thinking I should say.
    Is their a way to do this without Jailbreaking or modifying your aTV?
    If not is Apple ever going to wake up and allow there customers to actually USE the media they purchase from them without Home Sharing and a computer running?

    _Skull wrote:
    Can the aTV read files from an iTunes library on my nas drive without my computer being on
    no it can't. you need itunes open and running

  • Error while reading file entries from the database

    Hi there,
    We are running a instance of xmii 12 in a VM (VMware) and after somebody shutdown the host machine without shutting down the VM (great idea isn't it?) we keep getting this message when trying to access xMII:
    "Application cannot be started.
      Details:   com.sap.engine.services.deploy.container.ExceptionInfo: Error while reading file entries from the database."
    Any clue? Any suggestion on how we can recover from that?
    Thanks a whole lot,
    Dom
    Server log:
    #1.5 #000C29A3B1F20002000000C400000F2800044829A35270F8#1205243578005#/System/Server##com.sap.engine.services.dbpool.deploy.ContainerImpl####n/a##60152160ef7211dcb7a5000c29a3b1f2#SAPEngine_System_Thread[impl:5]_17##0#0#Info#1#com.sap.engine.services.dbpool.deploy.ContainerImpl#Plain###DataSources or DataSource aliases of 'sap.com/tcmonitoringsysteminfo' application started successfully.#
    #1.5 #000C29A3B1F20002000000C500000F2800044829A3527A6C#1205243578005#/System/Server##com.sap.engine.services.servlets_jsp.server.container.WebContainer####n/a##60152160ef7211dcb7a5000c29a3b1f2#SAPEngine_System_Thread[impl:5]_17##0#0#Info#1#com.sap.engine.services.servlets_jsp.server.container.WebContainer#Plain###application [] Start of application [sap.com/tcmonitoringsysteminfo] finished successfully on Web Container.#
    #1.5 #000C29A3B1F20002000000C600000F2800044829A3527DB5#1205243578005#/System/Server##com.sap.engine.services.deploy####n/a##60152160ef7211dcb7a5000c29a3b1f2#SAPEngine_System_Thread[impl:5]_17##0#0#Info#1#com.sap.engine.services.deploy#Plain###
    Operation startApp over application sap.com/tcmonitoringsysteminfo finished successfully on server 305221750#
    #1.5 #000C29A3B1F20002000000C700000F2800044829A3527E03#1205243578005#/System/Server##com.sap.engine.services.deploy####n/a##60152160ef7211dcb7a5000c29a3b1f2#SAPEngine_System_Thread[impl:5]_17##0#0#Info#1#com.sap.engine.services.deploy#Plain###
    Operation startApp on application sap.com/tcmonitoringsysteminfo finished on current cluster node for 221 ms.#
    #1.5 #000C29A3B1F20002000000C800000F2800044829A3528B49#1205243578005#/System/Server##com.sap.engine.services.deploy####n/a##60152160ef7211dcb7a5000c29a3b1f2#SAPEngine_System_Thread[impl:5]_17##0#0#Error#1#com.sap.engine.services.deploy#Plain###Error occurred while initially starting application sap.com/xappsxmiiear:Error while reading file entries from the database.#
    #1.5 #000C29A3B1F20002000000CA00000F2800044829A352922B#1205243578015#/System/Server##com.sap.engine.services.deploy####n/a##60152160ef7211dcb7a5000c29a3b1f2#SAPEngine_System_Thread[impl:5]_17##0#0#Info#1#com.sap.engine.services.deploy#Plain###The synchronization of applications with DB completed for 39304 ms.#
    #1.5 #000C29A3B1F200040000000200000F2800044829B290A4F8#1205243834341#/System/Server/SLDService##com.sap.sldserv.DataCollector####n/a##0da42150ef7311dcb908000c29a3b1f2#SAPEngine_System_Thread[impl:5]_7##0#0#Warning#1#com.sap.sldserv.DataCollector#Plain###Communication configuration is incomplete. No data transfer possible until corrected.#

    Well thanks for the hint. Actually, the DB was up but corrupted. I managed to solve the bug by re-deploying xMII (using the SDM tool) which kept all my data but redeployed both the config db of (x)mii and the class files.

  • Java.io.IOException: Too many open files while deploying in soa 11g

    hi all,
    I am getting a strange error while deploying any composite .. it's a hello world kinda composite but while i am trying to deploy it i am getting "java.io.IOException: Too many open files" while deployment.. i have tried to deploy it in 2-3 ways but all of them resulted in the same error..bouncing the soa server might be an option but can someone give an insight as why it is happening and can it be resolved without restarting the server..
    Thanks

    yes..so this problem is with unix only ..coz i previously worked in Windows ..never got this problem..

  • Reading files from Java embedding.

    Dear All,
    My BPEL process has a Java embedding node, and it invokes a Java class, in which an xsl file is being read for transformation.
    I deploy the xsl files directory together with BPEL package (the jar). In the package, I put the file dir at the root level, which means the jar structure looks like the following:
    /BPEL-INF
    /META-INF
    /xsd
    /xsl
    *.wsdl
    *.bpel
    bpel.xml
    The java class is package in /BPEL-INF dir, it's supposed to read files from /xsl dir.
    My question is, how should I put the file path?
    I tried "/xsl/***.xsl" and "../xsl/***.xsl", neither works. Although "/xsl/***.xsl" worked when testing in JDeveloper, but FileNotFound after deployment.
    Thanks,
    Haibo

    I solved this issue by putting the files dir in /BPEL-INF/classes/. and use ClassLoader to read in those files.

  • In your experience what are the most common errors in binding files when deploying?

    As the title suggest I'm interested in discussing the most common errors in binding files when deploying.
    Reason for this is that I'm currently working on a Powershell script that can parse a binding file and create a reader friendly report (rtf format) with various information.
    But the main purpose for this script is to find common errors in the binding file used. And so far these are the ones I've thought of:
    - Tracking enabled for either services or the pipelines they are using (if it's a binding meant for Prod).
    - Orchestrations logical ports not having any ports bound to them.
    - URI containing certain words that's not ok. For example if a binding meant for Prod contains the word "test" anywhere in the URI then that should be reported in the created rtf report. This also applies vice versa.
    So now I need your help with coming up with more ideas on common errors that need to be looked after and reported on if found! 
    Additional features the report should contain:
    - Listing the details of each orchestration, send port, receive port along with their associated receive location(s). To better understand and get a quick overview on exactly what settings are planned to be deployed. Especially the "TransportTypeData"
    section which otherwise can be quite tedious to read.
    - List each unique host instance, so that I can easier see directly which ones might need a restart after an import.
    I'd appreciate if you can come up with any more features that should be included in this script.
    /Christian @ IntegrationAdmin.com

    Filter on send port not on the same line as the Filter tag.
    This one is a nice one, I ran into it several times. Mostly after copy/paste of a port definition for a binding file, because Visual Studio is formatting after paste the XML in a way the filter will get invalid. This leads to a cryptic error
    during importing the binding.
    http://winterdom.com/2008/06/biztalkfiltersnotgettingimported
    Jean-Paul Smit | Didago IT Consultancy
    Blog |
    Twitter | LinkedIn
    MCTS BizTalk 2006/2010 + Certified SOA Architect
    Please indicate "Mark as Answer" if this post has answered the question.

  • How to read files in container

    I would like to read some settings from a file in my web application (deployed to to Tomcat-6.0.18). I can read files every where with this statemet: new FileReader("Settings.ini") but when I deploy my application to Tomcat It doesn't work.
    I use some JSF pages in my application when I try to read from this file in backing bean, I see this error message in console:
    java.io.FileNotFoundException: Settings.ini (The system cannot find the file specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(Unknown Source)
         at java.io.FileInputStream.<init>(Unknown Source)
         at java.io.FileReader.<init>(Unknown Source)
    I put Settings.ini in all folders but still I see the message above. please help me.

    Use an absolute path rather than a relative path. The working directory might differ per environment.
    Or just place the file in the classpath and use ClassLoader#getResource() or getResourceAsStream().

  • Reading file using File Adapter in BPEL

    Hi,
    I am using JDeveloper 11g.
    I am trying to Read XML file and write content to Text file.
    I created XML Schema, XML file.
    I created Asynchronous BPEL process (Auto Generated)
    I took one File adapter which will have Read operation and one more File Adapter which will have Write Operation.
    Then, added one Receive activity that will be connecting to partner link - Read.
    and one Invoke activity which is linked to Write Partner link .
    I am able to Deploy the process..
    While testing 1st receive (Auto generated) will work but Receive for Read is not getting started.
    I am getting " Waiting for "Read" from "ReadFile". Asynchronous callback.Waiting for "Read" from "ReadFile". Asynchronous callback "
    How to read file in BPEL process. ?
    Thanks

    So,You have two receive activity(One for soap client and one for Read activity) and two invoke(1 for write file and 1 for reply to client).
    I think the 1st receive activity for soap client not required as you want to initiate the process while read the file.You can delete the default soap client and corresponding receive activity and check the create instance chekbox in the 2nd receive activity linked with read partnerlink.
    There is some issue with 2nd receive activity in bpel ..
    BPEL 11g -- Issue with second Receive activity
    Edited by: blue bell on 10-Sep-2011 22:33

  • Error while reading files through FTP Adapter

    Hi,
    I am using FTP Adpater to read files and archive in local folders.
    But i got the following errors when i deployed the process:
    <2008-12-18 13:48:31,140> <INFO> <default.collaxa.cube.activation> <File Adapter
    ::Inbound> Connection Created
    <2008-12-18 13:48:31,390> <ERROR> <default.collaxa.cube.activation> <File Adapte
    r::Inbound> Unable to get Binary file '/MySharedFolders/abc/AAAA_TT_
    Trrrrplan Bireeee Baaaa? ??ketmmllri Ltd.?ti._4673651.pdf'; FTP command RETR returned unexpe
    cted reply code : 550
    <2008-12-18 13:48:44,156> <INFO> <default.collaxa.cube.activation> <File Adapter
    ::Inbound> Managed Connection Created
    <2008-12-18 13:48:44,156> <INFO> <default.collaxa.cube.activation> <File Adapter
    ::Inbound> Processer thread calling onFatalError with exception Error getting bi
    nary file from FTP Server.
    Unable to get binary file from server.
    Check the error stack and fix the cause of the error. Contact oracle support if
    error is not fixable.
    <2008-12-18 13:48:44,156> <FATAL> <default.collaxa.cube.activation> <AdapterFram
    ework::Inbound> [Get_ptt::Get(opaque)]Resource Adapter requested Process shutdow
    n!
    Please help me out on this issue.
    Thanks,
    Synthia

    Hi James,
    We have upgraded to 10.1.3.4. but still we could not read the file. the problem is, it could not read the file names contains with UTF-8 characters.
    error is below:
    <2009-12-01 15:43:33,109> <INFO> <default.collaxa.cube.activation> <FTP Adapter:
    :Inbound> Managed Connection Created
    <2009-12-01 15:43:33,109> <INFO> <default.collaxa.cube.activation> <FTP Adapter:
    :Inbound> Connection Created
    <2009-12-01 15:43:38,406> <ERROR> <default.collaxa.cube.activation> <FTP Adapter
    ::Inbound> Unable to get Binary file '/MySharedFolders/Invoice History/EMEA_TR_B
    imta?-Bo?aziτi Peysaz ?n?aat Mⁿ?avirlik Teknik Hizmetler A?aτ Sanayi ve Ticaret
    Anonim ?irketi_44596501.pdf'; FTP command RETR returned unexpected reply code :
    *550*
    <2009-12-01 15:43:51,156> <INFO> <default.collaxa.cube.activation> <FTP Adapter:
    :Inbound> Processer thread calling onFatalError with exception Error getting bin
    ary file from FTP Server.
    Unable to get binary file from server.
    Check the error stack and fix the cause of the error. Contact oracle support if
    error is not fixable.
    <2009-12-01 15:43:51,156> <FATAL> <default.collaxa.cube.activation> <AdapterFram
    ework::Inbound> [Get_ptt::Get(opaque)]*Resource Adapter requested Process shutdow*
    n!
    Thanks you.

  • Unable to find/read file META-INF/ra.xml

    When using the oc4j_admin_client to deploy an ear to a oas cluster I get this error, but only sometimes. I cannot find anything on the web that explains what might be causing this to occur. I'm guessing it might be with the configuration of OAS but even so I have no idea where to look. If anyone out there can give some advice it would help. Thanks,
    [Summary] There are total 1 instances in the operation.
    [Summary] Operation failed on applicationServerName/instanceName
    [Summary] Operation on cluster FAILED since 1 instanced failed!
    FINE: CoreRemoteMBeanServer.release call release on CoreRemoteMBeanServer: oracle.oc4j.admin.management.mejb.MEjb@5c1ae90c
    FINE: CoreRemoteMBeanServer.release Call remove on MBeanServer EJB
    FINE: CoreRemoteMBeanServer.release Call close on RMI Context: javax.naming.InitialContext@1629ce8c
    SEVERE: J2EEDeploymentManager.deploy Deploy error: Operation failed with error:
    Unable to find/read file META-INF/ra.xml in D:\oracle\u01\oas\10.1.3\j2ee\instanceName\connectors\AppName\AppName archive (IO Error: D:\oracle\u01\oas\10.1.3\j2ee\instanceName\connectors\AppName\AppName (The system cannot find the pat
    h specified))
    oracle.oc4j.admin.deploy.api.J2EEDeploymentException: Operation failed with error:

    Hi forum-hog,
    I think this is due to a known product defect. The patch is available and can be downloaded and installed.
    Please try the following:
    1) Download and apply patch 9073284
    2) Perform the deployment again
    Hope this helps.
    Thanks,
    Cris

  • Dreamweaver cs4 or mx2004 may built .war or .jar files for deployment in a jsp server (Tomcat) ? If no, and use Dreamweaver  how do these files ?

    Dreamweaver cs4 or mx2004 may built .war or .jar files for deployment in a jsp server (Tomcat) ? If no, and use Dreamweaver  how do these files ?

    if I use Eclipse IDE for compilation[make *.war & *.jar files from *.java like claimBeans.java], I must use also Eclipse for upload/deploy ? Or for upload ONLY I may use and dreamweaver ? The jsp section of dreamweaver, is for app not require compilation, like from Code from:JSP STANDARD TAG LIBRARY , only ?
    Basically whatever I may do with "JavaBeans", "Servlets" etc (*.java files) needed to get compiled, I may also do it with JSP STANDARD TAG LIBRARY etc NOT NEEDED Compilation, so if I do not understand how to compile&deploy *.war & *.jar files , I may use instead the latter way ?

  • Writing applets that read files hosted on a webserver.

    I have a java applet that I need to be able to read files on the webserver. IE open and render images. I know ultimately the user will end up downloading these images that are hosted on the websserver, but the java applet is set to read from it's local directory, for example, when I open up a text files, I use the path someFolder\someFile.txt. If the applet was placed in the same folder as someFolder on the webserver, how would I set it up to read from there opposed to on the machine executing the java code? Would I have to force the user to download all the resources, in thus case, wouldn't I need to to have the applet signed?

    ++++ to everything by malcolmmc (use class.getResource())
    Jeremy.W wrote:
    ...I could perform a CRC check and compare the archives with the ones on the server, but it still means I'd need to compress the archives manually every time an update is made to the files on the server.I am not sure whether you are concerned with the effort of doing this from your side. If so, use Ant to make your ..war file or whatever and just upload it (and restart the server?).
    If it is the archives (Jar or Zip) updating on the client that is your major concern, then I would definitely recommend the JNLP based option, which gives the client not only automatic update (the JWS client manages the time checks with the server), but if you want to go that far, direct programmatic access to the download API. I made a crude example (never properly finished) of downloading resources using the JNLP APIs DownloadService. (Though the standard 'auto-update' is known to be quite effective).
    Oh, and.. Of course, if you have a Java enabled server, the download servlet is known to be best for updates, incremental or otherwise.
    Does this applet really need to be embedded in a web page at all? JWS has offered these things to free-floating applets since Java 1.2, it is only recently an embedded applet could hook into the JNLP API.
    As to the 'Zip' archives of resources. Some points:
    1) It pays to split them up, especially if resources are likely to change frequently in one, but rarely for others. If you do that, webstart ensures the user only downloads the updated Jars. The only way to achieve a class/resource refresh in a conventional embedded applet ('plugin1') was to flush the class cache which would force refresh of all classes/resources.
    2) Splitting the archives according to type of resource can provide benefits in that the Jars can have different compression levels appropriate to the format.
    3) I would recommend deploying all resources, whether classes or other resources, in Jar and not Zip files. Sun has decided that no Zip will be checked to see if it is digitally signed, so Zip archives can cause problems for apps. which might need extended permissions (if it ever comes to that).

  • Empty JAR File : After deployment of PAR file.

    Hi friends,
    I Migrated the EP Database to different machine and made neccessary changes in the portal to make it point to the new  database.
    Then i tried to change the custom deployed applications to make it point to new database. so Got the somecomp.par.bak from /<Portal_installation_path>/cluster/server/services/
    servlet_jsp/work/jspTemp/irj/root/WEB-INF/deployment/pcd. Imported it into Eclipse, changed connection properties code, built it and coverted to par file. Deployed that file into portal using java developement tab. Even after uploading a new par, application is still pointing to old database.
    While deploying, it wrote some log into error_log file as follows:
    Jan 13, 2006 9:43:38 AM  ...rtal.prt.service.config.ConfigDeploymentService [Client_Thread_14] Warning": An upload sequence w
    ill start now. Please do not stop the server or serious deployment issues may arise.
    Jan 13, 2006 9:43:39 AM  ...rtal.prt.service.config.ConfigDeploymentService [Client_Thread_14] Warning": The upload sequence
    is now complete, all the upgrades have been performed.
    warning: Jar is empty: /usr/sap/AAA/j2ee/j2ee_00/cluster/server/services/servlet_jsp/work/jspTemp/irj/root/WEB-INF/portal/po
    rtalapps/SOMECOMP/private/lib/SOMECOMPcore.jar
    What may be the cause of this error?
    Portal Version:
    EP6 SP2 Patch 29
    SAPJ2EE 6.20 Patch 29
    Regards,
    Nilz
    Message was edited by: nilz

    Hi Nilz,
    > I got confused here
    Don't!
    In NWDS, if you import a PAR, no JARs which are inside the PAR get imported. That's all (it's enough ).
    > The one using which i compiled my code
    > like htmlb.jar etc
    NO! These are (hopefully) not inside your own PAR but only referenced!!!
    > When i imported a PAR file, the source code was there.
    Then even with NWDS you shouldn't have any problems as the classes / JARs are compiled/created at PAR creation.
    > i am using Eclipse with SP2 plugins
    Alltogether in your situation you are not confronted with an error but with a warnung. Obviously you don't have any code in the src.core section.
    Hope it helps
    Detlev
    PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance!

  • HOW TO DELETE ADOBE READER FILE FROM ADOBE READER

    HOW TO DELETE ADOBE READER FILE FROM ADOBE READER@ !@

    Your question make no sense. What exactly are you trying to do?

Maybe you are looking for

  • Best storage solution for central itunes library?

    I'd like to create a 4 Gb central library, running itunes permantenly on a headless Mac Mini. The library will contain all music and videos and should be available to an Apple TV, PC and Iphones (remote). I am not sure about what kind of storage solu

  • How can I get these devices to work together like this?

    What we have now: New iPad 2, currently blank My iPhone 4s with my itunes id which is also used for icloud Wifes iPhone 4s with her itunes id, also used for her icloud (phones are not linked in any way, other than some music synced from same pc) What

  • Fed up with lack of support & continuing authorization problems!  Help please!

    I apologize that this is so long but this activations issue has been a long difficult process, and I welcome any and all help you care to offer. On December 30, I opened a support case with Adobe Digital Editions because I got an error message saying

  • Enet100 GPIB controller on 64 bit OS

    After having to upgrade to the new LabView because of a bug and seeing how poor its performance is, I decided to give it the benifit of the doubt and got a brand new Core 2 3GHz PC w/ 8G of RAM.   I figured the time I am wasting trying to use the new

  • Edit template in Dreamweaver

    I have always put <head> part of page in my template, this than makes this part the same on all pages using that template. But I've now been told that the Meta keywords should be match to keywords on individual pages, so how do I now make this part o