Problem with reading config file

Hello,
I have problem with reading config file from the same dir as class is. Situation is:
I have servlet which working with DB, and in confing file (config.pirms) are all info about connection (drivers, users, passw, etc.). Everything work fine if I hardcoded like:
configFileName = "C:\\config.pirms";I need to avoid such hardcoding, I tryied to use:
configFileName = Pirms.class.getClassLoader().getResourceAsStream ("/prj/config.pirms").toString();but it isn't work.
My config file is in the same directory as Pirms.class (C:\apache-tomcat-5.5.17\webapps\ROOT\WEB-INF\classes\prj)
Also I tryied BundledResources, it isn't work fo me also.
Can anybody help me to solve this problem? with any examples or other stuff?
Thanks in advance.
Andrew

Thanks, but I am getting error that "non-static method getServletConfig() cannot be referenced from a static context"
Maybe is it possibility to use <init-param> into web.xml file like:
<init-param>
  <param-name>configFile</param-name>
  <param-value>/prj/config.pirms</param-value>
</init-param>If yes can anybody explain how to do that?
I need to have that file for:
FileReader readFile = new FileReader(configFile);Thanks in advance.

Similar Messages

  • Problems with reading XML files with ISO-8859-1 encoding

    Hi!
    I try to read a RSS file. The script below works with XML files with UTF-8 encoding but not ISO-8859-1. How to fix so it work with booth?
    Here's the code:
    import java.io.File;
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import java.net.*;
    * @author gustav
    public class RSSDocument {
        /** Creates a new instance of RSSDocument */
        public RSSDocument(String inurl) {
            String url = new String(inurl);
            try{
                DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                Document doc = builder.parse(url);
                NodeList nodes = doc.getElementsByTagName("item");
                for (int i = 0; i < nodes.getLength(); i++) {
                    Element element = (Element) nodes.item(i);
                    NodeList title = element.getElementsByTagName("title");
                    Element line = (Element) title.item(0);
                    System.out.println("Title: " + getCharacterDataFromElement(line));
                    NodeList des = element.getElementsByTagName("description");
                    line = (Element) des.item(0);
                    System.out.println("Des: " + getCharacterDataFromElement(line));
            } catch (Exception e) {
                e.printStackTrace();
        public String getCharacterDataFromElement(Element e) {
            Node child = e.getFirstChild();
            if (child instanceof CharacterData) {
                CharacterData cd = (CharacterData) child;
                return cd.getData();
            return "?";
    }And here's the error message:
    org.xml.sax.SAXParseException: Teckenkonverteringsfel: "Malformed UTF-8 char -- is an XML encoding declaration missing?" (radnumret kan vara f�r l�gt).
        at org.apache.crimson.parser.InputEntity.fatal(InputEntity.java:1100)
        at org.apache.crimson.parser.InputEntity.fillbuf(InputEntity.java:1072)
        at org.apache.crimson.parser.InputEntity.isXmlDeclOrTextDeclPrefix(InputEntity.java:914)
        at org.apache.crimson.parser.Parser2.maybeXmlDecl(Parser2.java:1183)
        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:653)
        at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
        at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
        at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:185)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)
        at getrss.RSSDocument.<init>(RSSDocument.java:25)
        at getrss.Main.main(Main.java:25)

    I read files from the web, but there is a XML tag
    with the encoding attribute in the RSS file.If you are quite sure that you have an encoding attribute set to ISO-8859-1 then I expect that your RSS file has non-ISO-8859-1 character though I thought all bytes -128 to 127 were valid ISO-8859-1 characters!
    Many years ago I had a problem with an XML file with invalid characters. I wrote a simple filter (using FilterInputStream) that made sure that all the byes it processed were ASCII. My problem turned out to be characters with value zero which the Microsoft XML parser failed to process. It put the parser in an infinite loop!
    In the filter, as each byte is read you could write out the Hex value. That way you should be able to find the offending character(s).

  • Odd problem with strusts config file

    This morning when I started up J Developer I am unable to open my struts-config file. Last evening when I closed my application everything was working fine, I compiled and ran the app for the last time just before closing J Developer. Now I am unable to compile, open this file (it is the same with other applications, as well). I have gone back to a previous version of my app, uninstalled Jdeveloper and reinstalled. Nothing seems to solve my problem. I am working on a Windows machine. Any thoughts on what might have changed or happened would be greatly appreciated.

    I think that I found the problem. Somewhere along the line I messed with the shortcut(I don't remember doing it or what I did but....) with the shortcut that I created and I got an odd path looking something like .... ...\c$\JDev\jdev\bin\jdevw.exe
    I fixed that and have not had a problem since.
    Thank you for your help.

  • Problem with reading mp4 files with QT 7.4.1 or mpeg Streamclip

    Hi,
    I used to convert some .flv files into .mp4 files with iSquint and then into .dv files with mpeg Streamclip in order to re-work and compile these files on a DVD using iMovie and iDVD.
    However I cannot do it anymore since I upgraded to QT 7.4.1. iSquint uses the mpeg-4 video codec to convert the file. Therefore I cannot open them with QT 7.4.1 anymore and I cannot convert them into .dv files with mpeg Streamclip anymore since Streamclip is uses a QT plug-in.
    I have tried to solve the problem using Perian but this plug-in does not work with my version of Mac (Panther 10.3.9). I also tried to downgrade to an older QT using Pacifist but it nearly crashed my whole computer (fortunately I could fix that by reinstalling QT 7.4.1).
    Has someone a solution to my problem?
    Thank you in advance.
    Steve

    Not all the following will apply to Panther (10.3.x) so look carefully on the sites mentioned for the correct versions:
    These are the downloads and the settings you need in order to view/hear pretty much everything that the net can throw at you: The setup described below has proved repeatedly successful on both PPC and Intel macs, but nothing in life carries a guarantee!
    It is known to work in the great majority of cases with Safari 3.0.4, QT 7.3 or 7.4 and OS 10.4.11. (If you are running Leopard, ensure that all plug-ins have been updated for OS 10.5)
    Assuming you already run Tiger versions OS 10.4.9 or above (this has not yet been verified with Leopard) and have Quicktime 7.2 or above, and are using Safari 2 or 3, download and install (or re-install even if you already had them) the latest versions, suitable for your flavor of Mac, of:
    RealPlayer 10 for Mac from http://forms.real.com/real/player/blackjack.html?platform2=Mac%20OS%20X&product= RealPlayer%2010&proc=g3&lang=&show_list=0&src=macjack
    Flip4Mac WMV Player from http://www.microsoft.com/windows/windowsmedia/player/wmcomponents.mspx (Windows Media Player for the Mac is no longer supported, even by Microsoft)
    Perian from http://perian.org/
    You should read this support page http://perian.org/#support in case you need to delete older codecs.
    Adobe FlashPlayer should first be uninstalled using the appropriate uninstaller available here: http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14157&sliceId=2 and then the latest version obtained from here: http://www.adobe.com/shockwave/download/download.cgi?P1ProdVersion=ShockwaveFlash and installed.
    (You can check here: http://www.adobe.com/products/flash/about/ to see which version you should install for your Mac and OS.)
    In earlier versions than QT 7.1.3 in Quicktime Preferences, under advanced, UNcheck Enable Flash, and under Mime settings/Miscellananeous only check Quicktime HTML (QHTM).
    You should also ensure, if you are running Tiger 10.4.11 or Leopard, that you have downloaded and installed the correct version for your Mac of Security Update 2007-009.1.1, which also deals with the Quicktime/Flash issues you may have experienced, such as the '?'. What happened was that both Quicktime as well as Adobe FlashPlayer tried to play the Flash video at the same time. This no longer happens. (N.B. Security Update 2007-009 1.1 requires both a restart and a permission repair.)
    If you get problems with viewing video on a website try moving this file to your Desktop:
    Hard drive/Library/Internet Plug-Ins/QuickTime Plugin.webplugin
    and then restarting Safari. If all now works, you can trash that file.
    In Macintosh HD/Library/Quicktime/ delete any files relating to DivX (Perian already has them). However it should be noted that Perian is not an internet plugin and will not play DivX files imbedded on a website. For that you will need the DivX Player browser plugin available from http://www.divx.com/divx/mac/
    Now go to Safari Preferences/Security, and tick the boxes under Web Content (all 4 of them) to enable Java.
    Lastly open Audio Midi Setup (which you will find in the Utilities Folder of your Applications Folder) and click on Audio Devices. Make sure that both Audio Input and Audio Output, under Format, are set to 44100 Hz, and that you have selected 'Built in Audio'.
    Important: Now repair permissions and restart.
    You should also consider having the free VLC Player from http://www.videolan.org/ in your armory, as this plays almost anything that DVD Player might not.

  • Problems with reading raw files in lightroom 5

    Ich kann weder dng Dateien von Leica x1 noch von fuji xt1 importieren! Was könnte der Grund sein, im Handbuch gibt es keine Hinweise auf Probleme?@ Kurze Antwort erwünscht

    Check the destination you have specified in the Import panel.  It needs to point to a location that Lightroom can read and more important write files to.  Usually the error message (in English) says “files cannot be read” and this really means that LR was unable to copy the files to the destination so then when it tried to import from that destination not file were found to read.

  • Problem with reading mpeg files from Sony DCR-SR100 30GB Handycam

    I just purchased a new Sony DCR-SR100 Handycam.
    I can upload successfully to my desktop (PowerBook G4)via a USB cable.
    I have all the latest updates for iLife, iMovie, Final Cut Pro and Quicktime. None of those applications will open the imported mpeg.
    When trying to import the file to the iMovie application I get the following error message:
    "The file could not be imported. The file M2UOOOO4.MPG can't be imported; Quicktime couldn't parse it: -2048"
    Any help would be greatly appreciated.
    igor4443

    Hi Igor,
    welcome to the  board
    ... hm, sorry to say, but:
    iMovie is a video edit app meant to work with firewire connected miniDV camcorders
    you try to teach the old dog new tricks... just one kind of mpegs can be handled with iM, that is mp4, imported via iPhoto6 (some stillcams can record a kind of "movin' images"...)
    sooo, you need to convert your stuff...
    mpegs are meant for playback only, they are a delivery format (thanks, Lennart, for this phrase).. editing/processing such files, needs to demuxx them => 3rd party tools...
    there's a very good and free solution:
    Streamclip (free)
    not using a miniDV camcorder, you miss the convenience of the iApps...

  • Problems with reading in files

    I have a compalation problem which throws back the following error:
    Echo.java:11: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
    Scanner scanFile = new Scanner(new File("file"));
    ^
    1 error
    Thanks in advanced.

    Here's Sun's exception tutorial: http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html
    Here's a quick overview of exceptions:
    The base class for all exceptions is Throwable. Java provides Exception and Error that extend Throwable. RuntimeException (and many others) extend Exception.
    RuntimeException and its descendants, and Error and its descendants, are called unchecked exceptions. Everything else is a checked exception.
    If your method, or any method it calls, can throw a checked exception, then your method must either catch that exception, or declare that your method throws that exception. This way, when I call your method, I know at compile time what can possibly go wrong and I can decide whether to handle it or just bubble it up to my caller. Catching a given exception also catches all that exception's descendants. Declaring that you throw a given exception means that you might throw that exception or any of its descendants.
    Unchecked exceptions (RuntimeException, Error, and their descendants) are not subject to those restrictions. Any method can throw any unchecked exception at any time without declaring it. This is because unchecked exceptions are either the sign of a coding error (RuntimeException), which is totally preventable and should be fixed rather than handled by the code that encounters it, or a problem in the VM, which in general can not be predicted or handled.
    So you have to either catch that exception, or announce to any caller (via the throws clause in the method declaration) that your method can throw that exception.

  • Problem to read  config file when tomcat used as service

    hi,
    I have an advanced installer developed for an application and the application is working fine when
    my tomcat is used in "manual" mode.But when tomcat is used in "Automatic" mode(as a service)
    I'm unable to login into my application, may be unable to read the config.xml....
    can any one please help me out with a solution.
    Regards,
    Vardhan

    hi,
    I got a solution.Jst change the mode of tomcat and restart the system.
    It's working and pls provide with any other solution if you have..
    thanx,
    Vardhan

  • Problem While reading a file in text mode from Unix in ECC 5.0

    Hi Experts,
    I am working on Unicode Upgrade project of ECC5.0.
    Here i got a problem with reading a file format which it does successfully in 4.6 and not in ECC5.0
    My file format was as follows:
    *4 000001862004060300000010###/#######L##########G/##########G/########
    It was successfully converting corresponding field values in 4.6:
    *4
    00000186
    2004
    06
    03
    00000010
    25
    0
    4
    0
    54.75
    0
    54.75
    0.00
    While i am getting some problem in ECC5.0 during conversion of the above line:
    *4 000001862004060300000010###/#######L##########G/##########G/########
    it was consider in the same # values.
    I have used the following statement to open and read dataset.
    OPEN DATASET i_dsn IN LEGACY TEXT MODE FOR INPUT.
    READ DATASET i_dsn INTO pos_rec.
    Thanks for your help.
    Regards,
    Gopinath Addepalli.

    Hi
          You might be facing this problem because of uni code. So while opening or reading the file, there is a statement call ENCODING. Use that option and keep the code page which you want. Then the problem may be solved.
    Thanks & Regards.
    Harish.

  • Problem with preview PDF files on Windows 7 32bit

    Hello,
    in my office I have a problem with preview PDF files on my computers. The files are allright, but if I select a file and click on preview mode after ~ 10sec operation system write something "Preview this file is corrupt for PDF Preview Handler wrong". On other 64bit computers with same programs the preview is work. I try uninstall all Adobe soft (Reader, Flash), clean all Adobe data from folders in root and in register, but it is not solve this problem. On Microsoft forums wrote me, that the problem is probably with AR plugin.
    So, can someone help me?
    Config PC:
    Windows 7 32/64bit Pro
    Intel i3, 4GB
    Adobe Reader 11.0.5
    Adobe Flash Player 15 ActiveX
    Adobe Flash Player 15 plugin
    Preview Handler Surrogate Host ver.: 6.1.7601.17514
    Thank you for help.

    I think I figured it out after reading other forums. Thanks!

  • Tempo problems with imported wav files

    Hey everyone, sorry if there's a quick fix for this in the forums that I couldn't find, but I've been having some tempo problems with imported .wav files.
    Long story short, my system couldn't handle playing all the tracks for a song while recording drums, so I bounced out an mp3 of the song and put it in a new Logic file so my drummer could just play along to that as I recorded him. Unfortunately, the original song is at 167 bpm, but I forgot to change the bpm in the new Logic file with the .mp3 file of the song to 167 bpm, so it was left at the default 120 bpm.
    So, the drums were recorded at the correct 167 bpm, but Logic thinks that those new drum .wav files should be played at 120 bpm, so when I import my drum tracks back into the original file, they do not play correctly at all.
    I could get record it all again, but I wanted to check if there was a way I could salvage what I already have, since my drummer lives about an hour away right now and can't just come over whenever he wants.
    Thanks for the help! I really appreciate it.

    Hi,
    First, do not use MP3 in Logic, the sound quality is less than AIFF, WAV or CAF, and Logic has to decode it for playback, making it a heavier burden on the CPU than an uncoded audiofile, such as AIFF, WAV or CAF.
    Secondly, audio files are independent of Logic's tempo. If you bounce down an audio file in any format (other than Apple Loop), it will play back at the same speed, +regardless of Logics' tempo setting+, either at recording or playback. Logic doesn't 'think' anything. The BPM is only important to MIDI tracks, or to the spacing between audio files. The audio files themselves *are not affected* by the tempo setting. If you import an audio file of tempo 167 into a 120 BPM project, the file will still play at 167, only Logic will indicate the wrong bar positions.
    regards, Erik.

  • Problem with printing pdf file

    hello,
    lately i have problem with printing pdf file:
    i click on the print button and the respod is very slow
    it takes more than a minute till the print window apears.
    i tryied to install version X but it's the same, the problem exist only when printing via adobe reader,
    other programs i'd working much faster.
    please advice,
    thank you

    No, it is not set to overprint. Also, I have to add that the printing results were not consistent. Sometimes it covered and sometimes it did not.

  • Problem  while reading XML file from Aplication server(Al11)

    Hi Experts
    I am facing a problem while  reading XML file from Aplication server  using open data set.
    OPEN DATASET v_dsn IN BINARY MODE FOR INPUT.
    IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      READ DATASET v_dsn INTO v_rec.
    WHILE sy-subrc <> 0.
      ENDWHILE.
      CLOSE DATASET v_dsn.
    The XML file contains the details from an IDOC number  ,  the expected output  is XML file giving  all the segments details in a single page and send the user in lotus note as an attachment, But in the  present  output  after opening the attachment  i am getting a single XML file  which contains most of the segments ,but in the bottom part it is giving  the below error .
    - <E1EDT13 SEGMENT="1">
      <QUALF>001</QUALF>
      <NTANF>20110803</NTANF>
      <NTANZ>080000</NTANZ>
      <NTEND>20110803<The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource 'file:///C:/TEMP/notesD52F4D/SHPORD_0080005842.xml'.
    /SPAN></NTEND>
      <NTENZ>000000</NTENZ>
    for all the xml  its giving the error in bottom part ,  but once we open the source code and  if we saved  in system without changing anything the file giving the xml file without any error in that .
    could any one can help to solve this issue .

    Hi Oliver
    Thanx for your reply.
    see the latest output
    - <E1EDT13 SEGMENT="1">
      <QUALF>003</QUALF>
      <NTANF>20110803</NTANF>
      <NTANZ>080000</NTANZ>
      <NTEND>20110803</NTEND>
      <NTENZ>000000</NTENZ>
      <ISDD>00000000</ISDD>
      <ISDZ>000000</ISDZ>
      <IEDD>00000000</IEDD>
      <IEDZ>000000</IEDZ>
      </E1EDT13>
    - <E1EDT13 SEGMENT="1">
      <QUALF>001</QUALF>
      <NTANF>20110803</NTANF>
      <NTANZ>080000</NTANZ>
      <NTEND>20110803<The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource 'file:///C:/TEMP/notesD52F4D/~1922011.xml'.
    /SPAN></NTEND>
      <NTENZ>000000</NTENZ>
    E1EDT13 with QUALF>003 and  <E1EDT13 SEGMENT="1">
    with   <QUALF>001 having almost same segment data . but  E1EDT13 with QUALF>003  is populating all segment data
    properly ,but E1EDT13 with QUALF>001  is giving in between.

  • Problem with uploading a file in Clustered Environment

    Hi,
    I have a problem with uploading a file in a clustered environment. I have an iview component which facilitates an upload action of an xml config file. The problem is that the upload of the modified XML file is reflected only in the central instance of the cluster and not in the dialog instances. The dialog instances hold the old config file.
    Is there any solution to upload the file to all the nodes in the cluster.
    Thanks
    Kiran

    Hi,
    This is a known problem with clustered environment. Remember that your portal component runs on just on dialog instance and it doesn't automatically have access to the other nodes.  However, there are some ways to get around this
    1. Use KM to store files. KM is a common repository for all application servers and therefore you needn't worry more
    2. Use an external batch oriented product (suresync/robocopy) to synch folders on the different DIs. You basically use your existing portal component, but there is a batch job which makes sure the upload folder is identical on all DIs (however, there is a slight delay depending on how often you run the batch job)
    3. Store the files on a shared disk directly from the portal component.
    Cheers
    Dagfinn

  • Hi! I´m having problems with showing video files in Qlab on my Macbook Air. A sound/video technician told me to "blow out" my Mac. Was told to use  cmd+ r  when restarting. Is this the right way?

    Hi! I´m having problems with showing video files in Qlab on my Macbook Air. It started suddenly. Consulted a sound/video technician who told me to "blow out" my Mac. Was told to use cmd+r  when restarting. Is this the right way to clean up my Mac? And is it likely that some kind of bug is causing problems for Qlab to show video files? I´ve already tried with a bunch of different video files and sometimes Qlab plays them and sometimes not. I need the Qlab playlist for a theatre show and only have a week until showtime so starting to really worry. Is there anyone out there who can help?

    Your Mac runs maintenance in the background for you.
    Command + R gives you access to restore, repair, or reformat the drive using OS X Recovery
    No idea why that was suggested.
    You may have a third party video player installed that's causing an incompatibility issue.
    Check these folders:
    /Library/Internet Plug-Ins/
    /Library/Input Methods/
    /Library/InputManagers/
    /Library/ScriptingAdditions
    ~/Library/Internet Plug-Ins/
    ~/Library/Input Methods/
    ~/Library/InputManagers/
    ~/Library/ScriptingAdditions
    The first four locations listed are in the root-level Library on your hard disk, not the user-level Library in your Home folder.The tilde (~) represents your Home folder.
    To access the Home folder in OS X Lion or Mountain Lion, open the Finder, hold the Option key, and chooseGo > Library.

Maybe you are looking for

  • Control pannel not showing some installed programs

    my os is win 7 and my control pannel is only showing google chrome and microsoft . net framework 4 client and ms office enterprise.but i have installed many programs such as mozila,adobe reader,avast antivirus and so many others but they are not show

  • Issue with Photo App

    I can't open up Camera Roll (the album with all my photos.) The problem is that on the list of albums, Camera Roll is at the top...and under the label "Albums." When I pull the list down, it comes down, but i can't open up the album. Any ideas?

  • Menu bar

    Why is there so much wasted space at the top of my screen when I open the Menu Bar (File Edit View History Bookmarks Tools Help) I find it rather annoying being able to see the top of my desktop wall paper...can it be relocated?

  • Runtime error while creating variables? ( ple solve me asap)

    hi friends, whilw working with 3.x reporting, i created variable, now i am moving that variable from left to right paneli am getting run time error. how can i solve ? regards suneel.

  • Datapump & max roles exceeded

    So, I was trying to export a schema out of a newly installed 10.1.0.4 instance, something I've done repeatedly in a 10.1.0.3 instance, using the following parmfile [oracle@linux-test transport]$ more expdp_audits.par SCHEMAS=audits LOGFILE=expdpdvlp_