Posts Tagged ‘Java’
Unable to validate using XSD: Your JAXP provider does not support XML Schema
Here is the stacktrace that happened this morning:
Unable to validate using XSD: Your JAXP provider org.apache.crimson.jaxp.DocumentBuilderFactoryImpl@e6a73d does not support XML Schema. Are you running on Java 1.4 or below with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
To solve it, I had to remove the j2ee-X.X.jar from my project.xml Maven config file.
HashMap.put(null, toto)
Question: does Java’s HashMap accept null as a key?
Read the rest of this entry »
List the content of a jar
Case: you have a jar foo.jar, and you need list the names of the files in it.
Solution: use the following command:
jar -tf foo.jar
Display the list of certificates trusted by Java
Case: under Windows, you need the list of the certificates that your local Java installation trusts.
Solution: open a DOS console, and write:
C:\>keytool -list [-v] -keystore "C:\Program Files\j2sdk1.4.2_07\jre\lib\security\cacerts"
java.util.ConcurrentModificationException
Probleme rencontre ce matin en Java 5 (Tiger):
[java]
Vector toto = new Vector();
// ...remplissage du vecteur...
for (Object o : toto){
toto.remove(o);
}
Cela leve une exception de type:
java.util.ConcurrentModificationException
Au debut j’ai pense a un probleme de synchronisation, et donc j’ai ajoute un bloc synchronized(mutex){...}, mais cela n’a pas fonctionne.
Mais en fait le probleme est different: apparemment cela vient de la facon dont le “foreach” a la Java gere le parcours des elements d’un vecteur (ou de tout autre objet iterable).
La solution que j’ai trouvee consiste a utiliser un “for” classique, qui fonctionne:
[java]
for (int i=0; i<toto.size(); i++){
Object o = toto.elementAt(i);
remove(o);
}
(je n’ai meme pas tente un remove(i), pour eviter les effets de bord sur les indices)
Neanmoins ce n’est pas ce qu’il y a de mieux, il aurait fallu utiliser un vrai Iterator, mais pour etre franc j’avais legerement la flemme…