Help!

Discussions

General J2EE: Help!

  1. Help! (6 messages)

    I am trying to run a java program as a Java Application (with main() method) in WSAD. But it is unable to get the environmental variables like Log4j and other property files. And I am getting this error:

    log4j:WARN No appenders could be found for logger (log4j:WARN Please initialize the log4j system properly.

    Waiting for your replies!

    Thank You!

    Threaded Messages (6)

  2. Help![ Go to top ]

    What kind of variables are you looking for? Are then system variables like user.home?
  3. Help![ Go to top ]

    Yes you are right!
    I am trying to access the property files (to access DB2,LOG4J etc). when I run the application within the websphere server environment, i am able to access the property files, but when i try to run as a Java Application, I am unable to access the property files.

    Waiting for your reply.

    Thanks!
  4. Just make sure the log4j.properties file is on your classpath. When it's in Websphere, it's most likely in a location already loaded into your cp. When you're running the standalone app, you need to specify it.
  5. Just make sure the log4j.properties file is on your classpath. When it's in Websphere, it's most likely in a location already loaded into your cp. When you're running the standalone app, you need to specify it.

    Pat,

    Can you please tell me how to do that?

    Thanks
    Raj
  6. Standard classpath[ Go to top ]

    Just use the -cp or -classpath switch with the Java command. Or include the log4j.properties file in the compiled classes dir or jar file.

    java -classpath path/to/dir net.javaspot.MyApp

    path/to/dir is the dir containing the log4j.properties file.
  7. First of all, use a real subject. A message like "Help!" doesn't help me as i only see titles. It makes me and most other readers want to skip it.

    Secondly, you are not trying to access env variables. Read the log, it does not say: "log4j system property", it says: "log4j system properly" as in proper or correct. You simply need to configure log4j. Here is the doc:
    http://logging.apache.org/log4j/docs/manual.html#defaultInit

    The simplest way is to put a log4j.properties in your classpath (if it's a web app, it's under /WEB-INF/classes). Look at the manual to get a sample log4j.properties file.

    HTH,
    sv