Could not read Log4j configuration file when I run jar file

Hi,
I'm using Log4J in my application..
I configure the log4j, as follows;
PropertyConfigurator.configure("properties/logging.properties");and then go on to use it.
The .properties is in the root when I jar my source. I use Ant to Jar the file. It all works good when I run the jar file from ant.
The problem is when I run the jar file by double clicking on it, I get an error
" Could not read configuration file [properties/logging.properties]."
I tried the following options;
PropertyConfigurator.configure("/logging.properties");
PropertyConfigurator.configure("./logging.properties");
PropertyConfigurator.configure("../logging.properties");But in all cases, I get corresponding errors on running the jar file through Ant:
log4j:ERROR Could not read configuration file [logging.properties].
log4j:ERROR Could not read configuration file [./logging.properties].
log4j:ERROR Could not read configuration file [../logging.properties].
I want to be able to run the Jar by double clicking on it or through Ant.. Would any one know how to fix this issue so that I can use both methods..

Keep your properties file inside the root folder of your application.It is working fine

Similar Messages

  • Read a txt file when I run jar file

    Hi all,
    I have a jar file. In ir there are:
    /file.jar
       |----/pack
       |        |----MyClass.class
       |        |----file.txt
       |
       |----/META-INF
       |        |----MANIFEST.MFI want: when I execute the jar file java -jar file.jar from the java class MyClass to read the file.txt
    When I run this the error is:
    C:\Documents and Settings\pc\Escritorio>java -jar file.jar
    java.io.FileNotFoundException: file:\C:\Documents%20and%20Settings\pc\Escritorio\file.jar!\pack\file.txt (El nombre de archivo, directo
    rio o etiqueta del volumen no es valido)
            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)
            at pack.MyClass.main(MyClass.java:20)
    Exception in thread "main" java.lang.NullPointerException
            at pack.MyClass.main(MyClass.java:31)the code into the java class is:
    package pack;
    import java.io.BufferedReader;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.InputStream;
    public class MyClass {
         private static String version = null;
         static String fich = "file.txt";
         public static void main(String[] args) {
              BufferedReader br = null;
              File file = new File(fich);
              try {
                   br = new BufferedReader(new FileReader(MyClass.class.getClass().getResource("/pack/file.txt").getPath()));
                   String j= null;
                   while ((j = br.readLine())!=null){
                        version = j;
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (IOException io){
                   io.printStackTrace();
              } finally{
                   try {
                        br.close();
                   } catch (IOException e) {
                        e.printStackTrace();
              if (version != null)
                   System.out.println("I have read : "+version);
    }in MANIFEST.MF file:
    Manifest-Version: 1.0
    Main-Class: pack.MYClassthanks very much

    thanks you!!
    I have read the file, but I have put the package when I write the file.txt, beacuse If I don't put this, givas me NullPointerException
    Now I have
    InputStream in = Main.class.getResourceAsStream("/pack/file.txt");
    InputStreamReader isr = null;
    BufferedReader reader = null;
    try {
              isr = new InputStreamReader(in, "ISO-8859-1");
              reader = new BufferedReader(isr);
              while ((j = reader.readLine())!=null){
                   version = j;
              reader.close();
    } catch ...Thanks very much

  • TS1192 'Could not read the iPhoto Library. The library at [file path] has a corrupted AlbumData.xml file.'

    Got this msh from Piasa...any ideas?  'Could not read the iPhoto Library. The library at [file path] has a corrupted AlbumData.xml file.'

    Contact Adobe support - that is not an iPhoto message - in general Piasa has no ability to access the iPhoto library - there have been hacks but often they do not worka nd can cause problems
    You need to user either Picasa or iPHoto - using both on the same photos is problematic
    LN

  • HELP: Flash Drive accepts files when I run them files corrupted

    So I have my flash drive partitioned in the Master Boot Record because in all other forms it will not appear on my computer. However, when it is partitioned like this, it will appear to accept files when I transfer them, but when I run them I receive a files corrupted message or error-43.
    I understand the Master Boot record is intended for windows, but when I partition the drive in GPT or Apple Partition Map the drive is inaccessible on my computer completely. I do not care about being able to transfer files to a PC, I just want to use my flash drive back-up and save files too. If anyone knows how I could do this I would really appreciate it.
    I searched the forums and could not find anything that has worked for me so if someone knows where it is I would appreciate a link, or if you know how to do it, I would appreciate the advice!
    Thanks

    thebigwillyp wrote:
    I know my flash drive worked on a mac because it worked months ago, it just will not now for some reason.
    Nearly everything that stops working used to work at some point. If you cannot format the drive on either a Mac (why not go back to that Mac it worked on "months ago?") or a PC, then for all practical purposes it's dead. Return if under warranty, or get a new one.

  • Why my self-signed applet could not read local disk but could write?

    I used a self-signed certificate for the applet yesterday and it worked
    fine at the beginning time, that is, it could write/read file to/from
    local disk, and it could connect to other MDS servers. But later, a
    problem happens. It could write file to local disk(I tested it and created
    files to C:/ under windows) but when it try to read that file, it got a
    io acessing exception. It could connect to other servers. I am puzzled
    about this problem, and I wonder why I could write but could not
    read. Need I deal with any policy file issue here?

    hi,
    i 'am doing something which is similar to the stuff ur doing .I wanted to write into file on the local disk on which the applet is running.for this i have signed the applet .do i need to make it self signed wat is difference between the self signed and signed applet .The problem which i facing is that it still gives me the security exception even if i define the policy file for that applet............Can u help me reagrding this
    Thanks in advance
    your great help would be apprecriated
    rao_lavs

  • I am getting system tray icon when i execute jar file.

    Hi.,
    I am not getting system tray icon when i execute jar file. But a process is created and its running at background... When i execute the same program in net beans, i got system tray icon as well. why i didn't get system tray icon outside the net beans.? Can anyone help me on this..?????

    Karthik_Java wrote:
    Hi.,
    I am not getting system tray icon when i execute jar file. But a process is created and its running at background... When i execute the same program in net beans, i got system tray icon as well. why i didn't get system tray icon outside the net beans.? Can anyone help me on this..?????What version of the JRE is set as the default on your machine, as far as I'm aware the ability to crap up the notification area was only added in JSE6.

  • Error messege when run jar file

    when i run jar file of my project give me that error(Fatel exception occured.program will exist)
    what is the reason of that error

    "can't get that path". Sounds like requisite classes aren't on the classpath.
    Please paste the ENTIRE error message that it's producing into your next reply. You have probably forgotten to include necessary classes - perhaps a JDBC driver - in your JAR file.

  • JAR file which needs other JAR files

    Hi,
    I try to run a jar file, which imports some external classes. These classes are in the library "reader.jar", which is added to the classpath. But if I start it with ...
         D:\TestProject>java -cp ./reader.jar -jar viewer.jar
    ... I get an error: java.lang.NoClassDefFoundError: de/readers/TestReader
    If I copy the file "reader.jar" to "... j2sdk1.4.2/jre/lib/ext", I can start
    "viewer.jar" successfull with ...
         D:\TestProject>java -jar viewer.jar
    Why can't I add "reader.jar" to the classpath or why is it not used by Java?

    When you run JAR's, you can not use the classpath defined at the command prompt (well, you can use it, it is just ignored). The JAR has its own class path defined in its manifest file. Add:
    CLASS-PATH: reader.jar
    to the manifest file of the viewer.jar and it should work.

  • "Could not write to configuration file" when config Publisher in admin tab

    Hi guys,
    I have install OBIEE 10.3.3.4 on an RH linux box (with OS user obiee) and Oracle Application Server 10.1.3.1 on the same box (with OS user oraias).
    When I want to change some parameter in the admin tab of BI publisher (Administrator/Administrator as the login name/pass) and click "Apply",
    I get the error "Could not write to configuration file". After I change the configuration properties to 777 the error is sitll there. And I also try to change the SECURITY MODEL to XDO, but still no use.
    I made a test, for example, when I change something in admin--JDBC--Oracle BIEE and then apply, I got the error. If I update xmlp/DataSource/datasources.xml manually, the change can be seen after I reopen the page admin--JDBC--Oracle BIEE. That means I find the correct file and the file access properties is ok.
    For other parameters such as Scheduler Configuration, I got the same error when apply. But the "Test connection" and "Install schema" work.
    Can somebody give me some advise on this ? Thanks
    Scott
    Edited by: Typhoon on Mar 20, 2009 12:59 AM

    I have install the same version(basic install) on another windows box, everything seems good...
    And below is the error log I find in application.log
    09/03/19 13:31:53.956 xmlpserver: Servlet error
    java.lang.NullPointerException
         at java.util.Hashtable.put(Hashtable.java:396)
         at oracle.apps.xdo.servlet.ui.admin.SchedulerConfigPage.handleSubmit(SchedulerConfigPage.java:248)
         at oracle.apps.xdo.servlet.ui.admin.SchedulerConfigPage.doPost(SchedulerConfigPage.java:166)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
         at oracle.apps.xdo.servlet.security.SecurityFilter.doFilter(SecurityFilter.java:86)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:302)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:190)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)

  • I purchased an audio book from I tunes but when I sync with my I phone it respond with error saying could not read or write the file. It only sync parts 2

    I purchased an audio book from I tunes but when I sync with my I phone it respond with error saying could not read or write the file. It only sync parts 2

    Those videos are probably not in an iPod-friendly format. It’s picky about that. You can try converting them, if possible.
    As for the audiobooks, are you sure they haven’t synced? You’ve enabled it to sync books and checked the “Audiobooks” section of your iPod?

  • Problem: 'Could not read from source' when exporting project.

    Hi everybody
    I am using Adobe Premiere CS4 on my MacBook Pro 15'' (i5 processor, 4 GB RAM, 500 GB Harddisc, 256 MB video memory (high-clockspeed))
    Everything works well except of one big thing, every time when i try to export my finished project the Media Encoder tells me always the same thing directly after pushing the start button. 'Could not read from the sorce. Please check if it has been removed or deleted'.
    I tried removing any offending plugins, i fixed the disk permissions.. But it all doesnt matter anything.
    No matter what i try to export, no matter in what file format. It just doesnt work. I even tried exporting a project which only contains a video file of 5 seconds without anything more but it just doesnt work. Its impossible that i have touched or modified or replaced any source files...
    Some help would be very very appreciated!!
    Martijn

    Welcome to the forum.
    Perhaps this Adobe KB Article will be able to help you.
    Good luck,
    Hunt

  • File Import error: Could not read from source (OS X 10.8.2)

    I am having this time-wasting problem on a new Creative Cloud CS6 installation. I queue my Premiere exports normally on AME (CS6 updated versions), and they work fine if I start them right away. If the Mac is restarted however, they will fail giving this error. The log shows "Could not read from the source. Please check if it has moved or been deleted". It looks for the source file at /Users/Username/Library/Caches/Temporary/projectname.prproj. Isn't AME supposed to hold the queue even after a shutdown/restart? Premiere has been uninstalled and reinstalled once, so maybe that's the cause of it? Thanks.

    Unfortunately, it looks like you've found a bug, an unplanned interaction between Premiere Pro's choice of temp directory and automatic OS behaviors.
    Jeff is correct, AME will hold the Queue between reboots. The problem is with the temporary project that Premiere creates.
    When you queue a sequence to AME from within Premiere (File > Export > Media, click the Queue button), Premiere creates a copy of the project in that temp directory. That is the file reference it sends to AME.
    The problem is that Mac OS appears to flush that directory on reboot. Thus, when you reopen AME, it can't find the file anymore.
    The bug is therefore that Premiere Pro is putting the file in a place where it can be deleted before being used. Sorry about that. I'll file the bug.
    You can work around the problem using a different method to add your sequence to the AME queue. Inside AME, use the File > Add command. You can also drag and drop the sequence icon from the Project panel in Premiere to the Queue panel in AME. Or you can just not reboot until you've rendered what's in the queue.
    I suppose it's possible that you could make Mac OS not flush the temp directory on reboot. There's a lot of fun things you can do in Terminal if you know the right commands. That's beyond my personal skillset.

  • "could not read the file because the plug-in could not understand the file."

    "could not read the file because the plug-in could not understand the file."
    I keep getting this error when trying to open some of my illustrator files. Usually after trying 5 or 6 time it will mysteriously open without a problem. I've reinstalled Illustrator and that didn't work. I've uninstalled and reinstalled CS3 and that didn't work.
    Why does it sometimes open and sometimes not???
    I've lost I don't know how many hours screwing around with this and REALLY pissing me off!!!
    AURGH!

    I think this has something to do with the PNG plugin.

  • I purchased i phone 3GS from San francisco thro my brother, when i brought to oman, i want to update ios 5 to ios 6 for that from itunes to start update , finally failed and i could not able to configure in oman wifi network, i dont have backup..help me..

    i purchased i phone 3GS from San francisco thro my brother, when i brought to oman, i want to update ios 5 to ios 6 for that from itunes to start update , finally failed and i could not able to configure in oman wifi network, i dont have backup..help me..

    Has your phone ever been hacked or jailbroken. This error message is what usually shows up for that. Are you using a supported carrier for the iPhone, or did someone hack the phone to unlock it to be used on another carrier. If that is the case, then there is no help you can get here as discussing hacked/jailbroken devices is not allowed.

  • Contribute could not read the shared settings file.....

    We are using Contribute 4 via FTP connection. Suddenly, I
    have one user today that is getting the following error when trying
    to connect to things she should have access to.
    The error: "Contribute could not read the shared settings
    file for this Website because the file has been corrupted. To
    re-create the shared settings file, an administrator must
    administrate the website again."
    As a sidenote, this user had recently been sent approximately
    41 files for review, I have no idea if there is a connection or
    not. This feature has worked fine for them before.
    Anyone see this problem before? I did check and I have other
    users that can access and edit the Website just fine. It seems
    specific to this one user.
    Thanks - Lainie

    I think this has something to do with the PNG plugin.

Maybe you are looking for

  • RefreshReport() doesn't work right

    Hi I use CrystalReports for Eclipse and I have a Java-program to show the reports. In this program I used the method refreshReport() for an instance of the class reportViewer after showing the report to get the window to set the Parameters at StartUp

  • How i insert the values in JTable

    Hi, Iam new to the swings i have a problem placing the values in JTable while retriving the values from DataBase .Anybody please suggest me.. i can retriving the values but how i place the vlaues.. This is My code package com.teamone.healthcare; impo

  • JMS Health State

    At the following URL it states that the JMSRuntimeMBean and           JMSServerRuntimeMBeans expose a HealthState via a getHealthState() method           call:           http://e-docs.bea.com/wls/docs70/admin_domain/monitoring.html           From the

  • Change name on Apple Concierge profile

    Hello, I have just booked a Genius appoinment to realise that my name on my Concierge profile is incorrect, whilst on my main Apple ID account, it is correct. When I press the 'edit' button on my Concierge profile, where my details are incorrect, it

  • Tempo independent fps

    Hi there, I'm looking for a bit of code that can ensure a precise frame rate on any computer. Something where I can set the tempo to 999 then adjust the frames per second through lingo. I've seen something on delta timing but that's applied to each s