Bonjour,
J'ai un p'tit souci avec Velocity. Lorsque je lance mon application et que je choisi un fichier pour la premiere fois , pas de probleme le traitement se fait parfaitement. Si jamais je ne change pas de répertoire source pour le second toujours pas de probleme.
Des lors que je modifie le répertoire source afin de selectionner un fichier à traiter, l'application plante et affiche l'erreur ci dessous. Je ne comprend pas tres bien quelle est la cause du probleme.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 String fichierUri= listFichier[i].getAbsolutePath().substring(0,listFichier[i].getAbsolutePath().indexOf('.')); String propertiesFileLocation =System.getProperty("user.dir"); String propertiesFileLocation2=propertiesFileLocation.replace('\\' , '/')+"/"+"parametre.properties"; Properties repertoire=FichierProperties.loadProperties(propertiesFileLocation2); System.out.println("chemin de création : "+fichierUri+".vm"); File oFic = new File(fichierUri+".vm"); FileOutputStream fos = new FileOutputStream(oFic); try { if (fos != null) { Result sortie = new StreamResult(fos); transformeur.transform(sourceXML, sortie); } } finally { if (fos != null) { fos.flush(); fos.close(); } } System.out.println("XSL transf done"); Properties p = new Properties(); String cheminParent=listFichier[i].getParent().replace('\\' , '/')+"/"; p.setProperty("file.resource.loader.path",cheminParent); Velocity.init(p); System.out.println(cheminParent); System.out.println(nomCourt); System.out.println(Velocity.getTemplate(nomCourt+".vm").getName()); VelocityContext context = new VelocityContext(); context.put( "date", new DateHelper()); Template template = Velocity.getTemplate(nomCourt+".vm"); FileWriter fw = new FileWriter(repertoire.getProperty("Uri")+nomCourt+".xls"); template.merge( context, fw ); fw.close(); oFic.delete(); System.out.println("Velocity transf done");
Erreur obtenu :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 GRAVE: ResourceManager : unable to find resource 'DEFI.vm' in any resource loader. org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'DEFI.vm'
Partager