exception wt.util.WTException is never thrown ...
Bonjour,
Aprés une génération d' un fichier TIFF je dois l'importer dans le PDM, je ne sais pas comment faire, est ce que quelqu'un pourrais m'aidé svp!!(s'il il sais comment faire l'importation des fichier)
j ai eu le message d'erreur suivany=t lors de la compilation du programme , j ai beau chercher la cause du pkoi mais j ai rien trouvé, voilà le message d erreur :
Code:
1 2 3
| sgGenPrintBatch.java:236: exception wt.util.WTException is never thrown in body of corresponding try statement
catch(WTException wte){
^ |
et voilà mon programme que j ai ecris en java :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| private Vector toTiffFile(WTPart part, String pathwintif, String Number) throws WTException{
String doc = null;
Vector vParts = null;
try {
Object[] tabObject = new Object[]{doc, vParts};
doc = (String)tabObject[0];
vParts = (Vector)tabObject[1];
}
catch(WTException wte){
doc = "\nErreur en générant la nomenclature : " + wte.getMessage();
}
String adresse_fichier = pathwintif + pathdelim + Number;
try {
File fi = new File(adresse_fichier+".tif");
FileWriter fiw = new FileWriter(adresse_fichier+".tif");
fiw.write(doc); // Ecriture de la variable doc
fiw.close(); // Fermeture du fichier
System.err.println("-- Enregistrement du fichier tiff dans : " + adresse_fichier + " --");
File fi2 = new File(adresse_fic hier+".xml");
boolean success=fi.renameTo(fi2);
if(success==false){
System.err.println("toTiffFile : on retourne false car on n'a pas réussi à renommer le fichier.");
return null;
} // On renomme en .xml
}
catch(IOException ioe){
System.err.println("erreur : " + ioe );
return null;
} |
probleme d erreur lors de la compilation
et comment je pourrais lever cette exception dans cet exemple??
probleme d erreur lors de la compilation
ah désolée c est pas la bonne méthode la voilà la class Thread :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
class UnThread extends Thread{
public void run(){
//creation de l'instance du Thread
UnThread Thread = new UnThread();
//activation du Thread
Thread.start();
//tant que le Thread est en vie
while(Thread.isAlive()){
//faire un traitement
//vérifier si de nouveaux fichiers TIFF générés sont apparus
//si ce ne sont pas des fichiers TIFF qui sont générés:
if(!sgGenPrintBatch){
log = "ECHEC" + Number + ":Probleme survenu lors de la génération du fichier TIFF";
logError(log, Number);
throw new WTException(log);
}
//si c est un fichier TIFF qui est généré:
//on l'integre dans le PDM
else{
}
try{
//faire une pause de 100 pour simuler un traitement
Thread.sleep(100);
}
catch(InterruptedException ex){}
}
}
} |
probleme d erreur lors de la compilation
je fais appel à une fonction qui est bien defini dans le programme (la fonction loadXML) et j ai l erreur suivante :
Code:
1 2 3 4 5
| sgGenPrintBatch.java:486: cannot resolve symbol
symbol : method loadXLM (wt.part.WTPart,java.lang.String,java.lang.String)
location: class ext.sogerma.genprintbatch.UnThread
boolean load = loadXLM(part, path, fileName);
^ |
et mon programme est le suivant :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
class UnThread extends Thread{
private static final String pathwintif = getProperty("sogerma.tiffiles.pathwin","\\\\Aldebaran\\pdmlinkshare");
private String pathdelimwin = "\\";
private String pathdelim = java.io.File.separator;
private static String getProperty( String propName, String valeurDefaut ) {
String valeur = valeurDefaut;
try
{
valeur = SogermaHelper.manager.getProperty( propName, valeurDefaut );
}
catch ( WTException e )
{
System.out.println("Impossible de récupérer la propriété [" + propName + "]");
e.printStackTrace();
}
return valeur;
}
//Cette méthode lance le chargement du fichier -LOAD.XML pour créer le document
private boolean loadXML(WTPart part, String path, String fileName){
Hashtable nv = new Hashtable();
String product = sgUtils.getAttrib(part,"ContainerName");
if(path==null){
path = System.getProperty("user.dir");
}
try {
String sgOrganizationName=null;
sgOrganizationName = WTProperties.getLocalProperties().getProperty("sogerma.organization.name");
nv.put("CONT_PATH", "/wt.inf.container.OrgContainer=" + sgOrganizationName + "/wt.pdmlink.PDMLinkProduct=" + product);
LoadFromFile.doFileImport(path + pathdelim + fileName , null, null, null, null, null, nv);
}
catch (WTException e) {
e.printStackTrace();
return false;
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
public void run(EPMDocument epmdoc, WTPart part, String fileName){
String Number = epmdoc.getNumber();
String Version = epmdoc.getVersionDisplayIdentifier().toString();
String DRAWING = Number + Version;
//creation de l'instance du Thread
UnThread Thread = new UnThread();
//activation du Thread
Thread.start();
//tant que le Thread est en vie
while(Thread.isAlive()){
//faire un traitement
//vérifier si de nouveaux fichiers TIFF générés sont apparus dans le répertoire de génération des fichiers tif
String file_tif = pathwintif + pathdelimwin + DRAWING + ".tif";
File f = new File("file_tif");
String[] listefichiers = f.list();
for (int i = 0; listefichiers != null && i < listefichiers.length; i++) {
if(listefichiers[i].endsWith(".tif")==true){
System.out.println(listefichiers[i]);
//récupéré les fichiers TIFF et les integrer dans le PDM
}
}
//load du fichier tif à partir du fichier xml
String path = System.getProperty("user.dir");
boolean load = loadXLM(part, path, fileName);
//vérifier si il existe le fichier XML pour loader le fichier tif dans PDMLink
for (int i = 0; listefichiers!= null && i < listefichiers.length; i++) {
if(listefichiers[i].endsWith(".xml")==true){
//rechercher dans le fichier XML la valeur de <xmlpartNumber>
//rechercher le WTPart pour cet article
String number = part.getNumber();
String partNumber = number ;
WTPart article = sgUtils.getPart(partNumber);
}
}
// test ok
try{
//faire une pause de 100 pour simuler un traitement
Thread.sleep(100);
}
catch(InterruptedException ex){}
}
}
} |
je ne comprend pas pkoi il y a cette erreur alors que je ne fais appel qu' à la fonction "loadXML"???
probleme d erreur lors de la compilation
bonjour
je veux utiliser assertEquals pour comparer le contenu de deux fichiers (le premier est un fichier TIFF et le second est un fichier XML).
normalement dans javadoc la formule est la suivante :
Code:
1 2 3
| assertEquals
public static void assertEquals(java.lang.String expected,
java.lang.String actual)Asserts that two Strings are equal. |
et mon code est le suivant (j ai fais la même chose pour faire la comparaison):
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| public void run(EPMDocument epmdoc, WTPart part){
String Number = epmdoc.getNumber();
String Version = epmdoc.getVersionDisplayIdentifier().toString();
String DRAWING = Number + Version;
//creation de l'instance du Thread
UnThread Thread = new UnThread();
//activation du Thread
Thread.start();
//tant que le Thread est en vie
while(Thread.isAlive()){
//faire un traitement
//vérifier si de nouveaux fichiers TIFF générés sont apparus dans le répertoire de génération des fichiers tif
String file_xml = pathxml + pathdelim + DRAWING + ".xml";
String file_tif = pathwintif + pathdelimwin + DRAWING + ".tif";
File f1 = new File("file_tif");
File f2 = new File("file_xml");
String[] listefichiers1 = f1.list();
String[] listefichiers2 = f2.list();
boolean resultat;
//récupéré les fichiers TIFF et les integrer dans le PDM
for (int i = 0; listefichiers1 != null && i < listefichiers1.length; i++) {
if(listefichiers1[i].endsWith(".tif")==true){
String file_Name1 = listefichiers1[i];
}
//vérifier si il existe le fichier XML pour loader le fichier tif dans PDMLink
for (int j = 0; listefichiers2!= null && j < listefichiers2.length; j++) {
if(listefichiers2[i].endsWith(".xml")==true){
String file_Name2 = listefichiers2[j];
if(assertEquals(listefichiers1[i],listefichiers2[j]) == true){
//load du fichier tif à partir du fichier xml
String path = System.getProperty("user.dir");
boolean load = loadXML(part, path, file_Name2);
}
}
}
//rechercher dans le fichier XML la valeur de <xmlpartNumber>
//rechercher le WTPart pour cet article
String number = part.getNumber();
String partNumber = number ;
WTPart article = sgUtils.getPart(partNumber);
// }
//}
// test ok
try{
//faire une pause de 100 pour simuler un traitement
Thread.sleep(100);
}
catch(InterruptedException ex){}
}
} |
mais j ai comme mêm l erreur suivante :
Code:
1 2 3 4 5 6 7
| javac -classpath $WT_HOME/codebase:$WT_HOME/srclib/ie.jar sgGenPrintBatch.j>
sgGenPrintBatch.java:495: cannot resolve symbol
symbol : method assertEquals (java.lang.String,java.lang.String)
location: class ext.sogerma.genprintbatch.UnThread
if(assertEquals(listefichiers1[i],listefichiers2[j]) == true){
^
1 error |
je ne sais pas d'oû vient le probleme ?? peut etre c est tout bête est je ne le vois pas!!
merci de m aider SVP
probleme d erreur lors de la compilation
je viens de changer assertEquals par equals et la compilation à bien marché :D
mais je voudrais comme même savoir si elle compare le contenu des 2 fichiers ou pas ??
probleme d erreur lors de la compilation
pour assertEquals c est resolu merci bcp