Re: 500 error, loading properties for language files

Hi all,

after having checked the source 
http://dev.w3.org/cvsweb/2002/css-validator/org/w3c/css/util/Messages.java
it seems that a patch I sent some months ago would fix that problem. 
Here is the patch :
Index: Messages.java
===================================================================
RCS file: 
/sources/public/2002/css-validator/org/w3c/css/util/Messages.java,v
retrieving revision 1.21
diff -u -r1.21 Messages.java
--- Messages.java	7 Jul 2008 19:05:28 -0000	1.21
+++ Messages.java	14 Nov 2008 18:51:31 -0000
@@ -163,8 +163,7 @@
  	static {
  		Utf8Properties tmp;
  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.de"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.de");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -184,8 +183,7 @@
  		// ------------------------------------------------

  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.en"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.en");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -202,8 +200,7 @@
  		// ------------------------------------------------

  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.es"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.es");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -221,8 +218,7 @@
  		// -----------------------

  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.fr"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.fr");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -240,8 +236,7 @@
  		// -----------------------

  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.ko"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.ko");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -258,8 +253,7 @@
  		// -----------------------
  		
  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.it"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.it");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -276,8 +270,7 @@
  		// -----------------------

  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.nl"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.nl");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -294,8 +287,7 @@
  		// -----------------------

  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.ja"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.ja");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -312,8 +304,7 @@
  		// -----------------------
  		
  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.pl-PL"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.pl-PL");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -332,8 +323,7 @@
  		// -----------------------
  		
  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.pt-BR"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.pt-BR");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -348,11 +338,10 @@
  		} catch (Exception e) {
  			System.err.println("org.w3c.css.util.Messages: " + "couldn't load 
properties pt-br");
  			System.err.println("  " + e.toString());
-		}
+		}	
  		// -----------------------
  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.ru"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.ru");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -366,10 +355,9 @@
  			System.err.println("  " + e.toString());
  		}

-		// -----------------------
+		// -----------------------		
  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.sv"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.sv");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -383,11 +371,8 @@
  			System.err.println("  " + e.toString());
  		}

-		// -----------------------
-
  		try {
-			URL url = 
adjustURL(Messages.class.getResource("Messages.properties.zh-cn"));
-			java.io.InputStream f = url.openStream();
+			java.io.InputStream f = 
Messages.class.getResourceAsStream("Messages.properties.zh-cn");
  			try {
  				tmp = new Utf8Properties();
  				tmp.load(f);
@@ -404,21 +389,4 @@
  		}

  	}
-
-	/**
-	 * This method is called to clean the URL
-	 * /path/to/file will , file://localhost/path/to/file, 
file://C:\path\to\file, ...
-	 * will become file:///path/to/file
-	 * @param resource, the URL to "clean"
-	 * @return the clean URL
-	 * @throws MalformedURLException
-	 */
-	public static URL adjustURL(URL resource) throws MalformedURLException {
-		String urlStr = resource.getFile();
-		if (urlStr.startsWith("file://"))
-			urlStr.replaceFirst("file://localhost", "file://");
-		else
-			urlStr = "file:///" + urlStr;
-		return new URL(urlStr);
-	}
  }


Damien

Andrei Doicin wrote:
> Hi,
> 
> I've been talking to Damien about this 500 error when using an
> apparently perfectly well built css-validator, and he says the problem
> arises because the language files aren't loaded. I can confirm this in
> catalina.out, as you can see below. BTW I installed another
> css-validator on a Debian box earlier to do a kind of comparative study,
> and that works fine. I'm speculating if the problem on this Centos 4.7
> is a result of some dodgy symbolic linking I was doing a while back on
> libcgj.jar to get something completely unrelated to install nicely ...
> 
> [root@io-dev23 java]# pwd
> /usr/share/java
> [root@io-dev23 java]# ls -l libgcj-3.4.*
> -rw-r--r--  1 root root 6236968 Jul 24 22:41 libgcj-3.4.3.jar
> lrwxrwxrwx  1 root root      16 Oct 23 16:32 libgcj-3.4.6.jar ->
> libgcj-3.4.3.jar
> 
> ... or if it's just something to do with Centos.
> 
> The last time the problem was mentioned on this list was 6 years ago,
> but I didn't see any comeback:
> 
> http://lists.w3.org/Archives/Public/www-validator-css/2002Jul/0007.html
> 
> =======================================================
> 
> org.w3c.css.util.Messages: couldn't load properties de
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.de
> (No such file or directory)
> org.w3c.css.util.Messages: couldn't load properties en
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.en
> (No such file or directory)
> org.w3c.css.util.Messages: couldn't load properties es
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.es
> (No such file or directory)
> org.w3c.css.util.Messages: couldn't load properties fr
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.fr
> (No such file or directory)
> org.w3c.css.util.Messages: couldn't load properties ko
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.ko
> (No such file or directory)
> org.w3c.css.util.Messages: couldn't load properties it
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.it
> (No such file or directory)
> org.w3c.css.util.Messages: couldn't load properties nl
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.nl
> (No such file or directory)
> org.w3c.css.util.Messages: couldn't load properties ja
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.ja
> (No such file or directory)
> org.w3c.css.util.Messages: couldn't load properties pl
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.pl-
> PL (No such file or directory)
> org.w3c.css.util.Messages: couldn't load properties pt-br
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.pt-
> BR (No such file or directory)
> org.w3c.css.util.Messages: couldn't load properties ru
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.ru
> (No such file or directory)
> org.w3c.css.util.Messages: couldn't load properties sv
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.sv
> (No such file or directory)
> org.w3c.css.util.Messages: couldn't load properties cn
>   java.io.FileNotFoundException:
> /file:/opt/apache-tomcat-5.5.27/webapps/css-validator/WEB-INF/lib/css-va
> lidator.jar!/org/w3c/css/util/Messages.properties.zh-
> cn (No such file or directory)
> 
> ______________________________________________________________________
> This email may contain confidential information. If you receive it in error please immediately advise the sender and delete it from your system without copying, distributing or taking any action in reliance upon it. Red Bee Media Limited has taken precautions in respect of its email communications to preserve confidentiality and to ensure that any attachment has been checked for viruses. However, we cannot accept liability for any damage sustained as a result of interceptions and software viruses and you should take your own precautions before responding to us by email and carry out your own virus checks before opening any attachment.
> 
> Red Bee Media Limited 
> Registered No: 04257461 England 
> Registered Office: BC2 A1 Broadcast Centre, 201 Wood Lane, London W12 7TP
> 
> ____________________________________________________________________
> 

Received on Friday, 14 November 2008 18:53:44 UTC