tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Endre StĂžlsvik <En...@Stolsvik.com>
Subject [tc4 vs. tc3.x] Cannot read file, java.io.FileNotFoundException
Date Sun, 25 Mar 2001 18:15:41 GMT
I have a problem reading a file that I've put in the WEB-INF/classes dir.
It works on tc3.2 and tc3.3, but doesn't work in tc4.0. Could someone shed
some light on why, and how I could manage to read it on all servlet
servers, and whether I should put it somewhere else.

The file is called "logconfig.xml", and the Settings.getLOG_CONFIG_FILE()
is just a String with that content.

This code:

	private static boolean logConfig() throws ConfigException {
		URL dtdURL = DOMConfigurator.class.getResource("log4j.dtd");
		if(dtdURL == null)
			throw new IllegalArgumentException("CT: Couldn't find log4j.dtd. Bad stuff.");

		FileInputStream configFileIS;
		try {
			URL configURL = DOMConfigurator.class.getClassLoader().getResource(Settings.getLOG_CONFIG_FILE());
			System.out.println("This is the config URL: "+configURL);
			System.out.println("This is the config URL.getFile(): "+configURL.getFile());
			File configFile = new File(configURL.getFile());
			System.out.println("This is the config file: "+configFile);
			configFileIS = new FileInputStream(configFile);
		}
		catch (FileNotFoundException e) {
			throw new ConfigException("CT: Configfile not found: "+e);
		}

	[ -- cut -- ]

	}

produces different results of tc4 vs tc3.2 and tc3.3

On tc3.3m2:
This is the config URL: file:/devel/endre/active/SERVER/webapps/CAF/WEB-INF/classes/logconfig.xml
This is the config URL.getFile(): /devel/endre/active/SERVER/webapps/CAF/WEB-INF/classes/logconfig.xml
This is the config file: /devel/endre/active/SERVER/webapps/CAF/WEB-INF/classes/logconfig.xml
- and it works fine.

Excat the same with tc3.2.2b2:
This is the config URL: file:/devel/endre/active/SERVER/webapps/CAF/WEB-INF/classes/logconfig.xml
This is the config URL.getFile(): /devel/endre/active/SERVER/webapps/CAF/WEB-INF/classes/logconfig.xml
This is the config file: /devel/endre/active/SERVER/webapps/CAF/WEB-INF/classes/logconfig.xml
- still fine

But On tc4.0b1:
This is the config URL: jndi:/WEB-INF/classes/logconfig.xml
This is the config URL.getFile(): /WEB-INF/classes/logconfig.xml
This is the config file: /WEB-INF/classes/logconfig.xml
com.corelets.settings.ConfigException: CT: Configfile not found: java.io.FileNotFoundException:
/WEB-INF/classes/logconfig.xml (No such
file or directory)
        at com.corelets.server.Startup.logConfig(Startup.java:234)
        at com.corelets.server.Startup.init(Startup.java:46)
        at javax.servlet.GenericServlet.init(GenericServlet.java:258)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:779)
 ...
- and here it breaks, of course.

What's that "jndi:" stuff instead of "file:" ??

-- 
Mvh,
Endre


Mime
View raw message