Salut tout le monde,
Dans le carde d'une application n-tier dont la partie service est exposée sur httpinvoker, j'ai développé une classe java pour générer des rapports dans un répertoire avec JasperReport.

le Problème que j'ai c'est que j'arrive pas a avoir le bon chemin pour acceder au répertoire ou se trouve mes jasper, aussi j'arrive pas a avoir le chemin pour accéder au chemin du rép destination là ou je stockerais mes pdf
voici ma classe :

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
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
 
package com.hps.reporting.jasper;
 
import java.util.HashMap;
import java.util.Map;
 
import javax.servlet.ServletContext;
 
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperRunManager;
 
import com.hps.reporting.JRGenerator;
 
public class JRGeneratorImpl implements JRGenerator {
 
	private String reportsLocation;
	private String genLocation;
 
	public JRGeneratorImpl() {
 
	}
 
	public void generate(String report, String format, Map<String, Object> map) {
		System.out.println("generate the report [" + report
				+ "], with the format [" + format + "]");
		doPdf(report, map);
		System.out.println("END OF PRINTING ...");
	}
 
	private void doPdf(String report, Map<String, Object> map) {
 
 
		map = new HashMap<String, Object>();
 
		//String classpath = JRGeneratorImpl.class.getResource("/").getPath();
		//System.out.println("GET PATH : " + classpath);
 
 
		try {
 
			ServletContext context;
 
			JasperRunManager.runReportToPdfFile(
					//c'est là ou je plente, j'arrive pas a définir le bon chemin de mon fichier jasper
						reportsLocation + "/" + "myReport.jasper", 
						genLocation + "/myReport.pdf", 
						map,
						new JREmptyDataSource()
					);
 
 
 
		} catch (JRException e) {
			System.out.println(e.getMessage());
			e.getStackTrace();
 
 
		} 
	}
 
 
	public void setReportsLocation(String reportsLocation) {
		this.reportsLocation = reportsLocation;
	}
 
	public void setGenLocation(String genLocation) {
		this.genLocation = genLocation;
	}
}

et voici mon xml du context spring :

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
 
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
	<bean id="defaultHandlerMapping"
		class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
 
 
	<bean name="/JRGenerator"
		class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
		<property name="service">
			<ref bean="jrGenerator" />
		</property>
		<property name="serviceInterface">
			<value>
				com.hps.reporting.JRGenerator
			</value>
		</property>
	</bean>
 
 
	<bean id="jrGenerator" class="com.hps.reporting.jasper.JRGeneratorImpl" >
		<property name="reportsLocation" value="/reportsLocation"/>
		<property name="genLocation" value="/genLocation"/>
	</bean>
 
</beans>