maheshwarirohit87 / typica

Automatically exported from code.google.com/p/typica
Apache License 2.0
0 stars 0 forks source link

Typica distributed in a jar throws error on initialization #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Include typica and log4j.xml in a jar.

What is the expected output? What do you see instead?

Expect no error, but see:
I get the following:

ROOT CAUSE:
java.lang.IllegalArgumentException: URI is not hierarchical
        at java.io.File.<init>(File.java:363)
        at
com.xerox.amazonws.tools.LoggingConfigurator.configureLogging(Logging
Configurator.java:47)
        at
com.xerox.amazonws.sqs.QueueService.<clinit>(QueueService.java:52)
        at
com.xerox.amazonws.sqs.SQSUtils.getQueueService(SQSUtils.java:81)
        at
com.xerox.amazonws.sqs.SQSUtils.connectToQueue(SQSUtils.java:60)

Please provide any additional information below.

The fix is to comment out the file stuff:

If you don't use File in LoggingConfigurator this will go away, eg:

public class LoggingConfigurator {
    private static boolean loggingConfigured = false;
    private static final String LOGGER_CONFIG = "Log4j.xml";

    public static Logger configureLogging(Class callingClass) {
        if (!loggingConfigured) {
            URL configFileURL =
callingClass.getClassLoader().getResource(LOGGER_CONFIG);
            if (configFileURL == null){
                System.err.println("The log4j configuration file
\""+LOGGER_CONFIG+
                    "\" was not found on the classpath.");
            }
            /*File configFile = null;
            try {   
                configFile = new File(configFileURL.toURI());
            }catch (URISyntaxException e) {
                System.err.println("Log4J config file URL "+configFileURL+
                        " couldn't be converted to a URI.");
                e.printStackTrace(System.err);
            }*/
            DOMConfigurator.configureAndWatch(configFileURL.toString());
            loggingConfigured = true;
            System.out.println("\n\nLogging initial configuration complete
according to file "+configFileURL);
        }
        System.out.println("Log4j logger created.");
        return Logger.getLogger(callingClass.getName());
    }
}

Original issue reported on code.google.com by treeder on 31 May 2007 at 9:22

GoogleCodeExporter commented 9 years ago
I've tested this this with my use case and it works, so I've committed the 
change.
Thanks!

Original comment by dkavan...@gmail.com on 1 Jun 2007 at 1:48