facebook

Classpath Issue In remote debugging.

  1. MyEclipse Archived
  2.  > 
  3. Application Servers and Deployment
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #248748 Reply

    Hi,

    I have the properties file under the WEB-INF folder. When I do the Remote Debuging from Myeclipse I am getting Property File not found in Classpath error. I have installed the application as packaged war file.

    I am getting the home page also is recognize the realm from the server.

    But when I try to connect to the Database through code its not recognizing the property file under the WEB-INF folder.

    Here is my code to read the property file.

    propsFileStream = java.lang.Thread.currentThread()
    .getContextClassLoader()
    .getResourceAsStream(“DB.properties”);

    Where should I put the properties file to be picked by the class files ?

    Thanks for the help.

    #248757 Reply

    Riyad Kalla
    Member

    The properties file should go into your source tree, preferablly in the same package as your DB classes so you can simply have your DB class do a getResourceAsStream to load the file.

    You could also place it in the root of your source tree and load it with “/DB.properties” as the path, but I usually prefer putting it with the class that needs it.

    #248763 Reply

    Riyad Thanks for the prompt reply.

    I treied the Property Files in the source Tree and mentioned them as /DB.Properties. Still its not working.

    Also copied the properties in the package folder , still I am getting the same error.

    Do I miss anything ?

    Thanks for the propmt help.

    #248777 Reply

    Riyad Kalla
    Member

    Paste your code you are using to load the properties file, maybe you are doing something wrong there.

    #248789 Reply

    Now I am getting the property file loaded properly. But I had to install the application as exploded archive. If I install the application as Packaged Archive its not getting loaded.

    Here is the code.

    try {
    props = new Properties();

    //System.err.print(“loadProperties getResourceAsStream stg.properties…”);
    // find stg.properties from the classpath
    java.io.InputStream propsFileStream = lock.getClass()
    .getResourceAsStream(“/DB.properties”);
    System.out.println(“stg.properties=”+propsFileStream);
    //System.err.println(“done”);
    // here’s an ugly hack to get it working in WebLogic
    if (propsFileStream == null) {
    //System.err.print(“loadProperties trying getContextClassLoader.getResourceAsStream( stg.properties)…”);
    propsFileStream = java.lang.Thread.currentThread()
    .getContextClassLoader()
    .getResourceAsStream(“/DB.properties”);
    System.out.println(“stg.properties=”+propsFileStream);
    }

    //System.err.println(“done”);
    // if we haven’t found it now, report failure
    if (propsFileStream != null) {
    //System.err.print(“loadProperties props.load…”);
    props.load(propsFileStream);

    //System.err.println(“done”);
    } else {
    props = null;
    throw new PropertiesException(
    “Properties file stg.properties not found in classpath”);
    }
    } catch (java.io.IOException e) {
    e.printStackTrace();
    }

    #248790 Reply

    Riyad Kalla
    Member

    Good for “loading resource from JAR”. IIRC getResourceAsStream should work but it seems to be not working when the resource is inside of a JAR, so google for some code snippets that do that.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Classpath Issue In remote debugging.

You must be logged in to post in the forum log in