Bonjour,
je viens poster ici car je n'ai pas trouvé d'explication à mon problème sur le net.
Je suis en train de mettre en place un projet multi-module (un war pour la partie présentation et un ear contenant EJB3 et la partie business). Le war et l'ear seront déployés sur deux serveurs distincts.
Mon soucis est que lorsque je package mon projet Web, celui-ci récupère toutes les dépendances du projet Business. Alors qu'il devrait en être indépendant, et n'avoir qu'une dépendance sur l'interface de mes EJBs (le jar ejb-client).
L'organisation de mon projet est la suivante :
POM Parent :->Projet Parent :
----> Business (c'est un jar qui contient uniquement la partie business et la persistance)
----> Common (c'est un jar contenant les DTOs utilisés par le web et le métier pour transférer les données)
----> EJB (c'est un jar)
----> EAR (contient le business, le common et l'EJB)
----> Web (war)
POM Common :
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 <?xml version="1.0"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.exemple</groupId> <artifactId>Parent</artifactId> <version>1.0-SNAPSHOT</version> <name>Parent</name> <packaging>pom</packaging> <modules> <module>Common</module> <module>EJB</module> <module>Web</module> <module>Business</module> <module>EAR</module> </modules> </project>
POM Business :
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 <?xml version="1.0"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <artifactId>Parent</artifactId> <groupId>com.exmple</groupId> <version>1.0-SNAPSHOT</version> </parent> <groupId>com.exmple</groupId> <artifactId>Common</artifactId> <version>1.0-SNAPSHOT</version> <name>Common</name> <properties> <commons-lang-version>2.5</commons-lang-version> </properties> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>${commons-lang-version}</version> </dependency> </dependencies> </project>
POM EJB :
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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209 <?xml version="1.0"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <artifactId>Parent</artifactId> <groupId>com.exemple</groupId> <version>1.0-SNAPSHOT</version> </parent> <groupId>com.exmple</groupId> <artifactId>Business</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>Business</name> <properties> <maven.test.failure.ignore>true</maven.test.failure.ignore> <mysql-version>5.1.9</mysql-version> <log4j-version>1.2.16</log4j-version> <slf4j-api-version>1.5.6</slf4j-api-version> <slf4j-log4j12-version>1.5.6</slf4j-log4j12-version> <junit-version>4.8.1</junit-version> <dbunit-version>2.2</dbunit-version> <aopalliance-version>1.0</aopalliance-version> <hibernate-version>3.2.7.ga</hibernate-version> <hibernate-annotations-version>3.4.0.GA</hibernate-annotations-version> <hibernate-entitymanager-version>3.4.0.GA</hibernate-entitymanager-version> <spring-version>3.0.4.RELEASE</spring-version> <spring-mock-version>2.0.8</spring-mock-version> <spring-jpa-version>2.0.8</spring-jpa-version> </properties> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <dependencies> <!-- Log4J --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j-version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j-api-version}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j-log4j12-version}</version> </dependency> <!-- JUnit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit-version}</version> <scope>test</scope> </dependency> <!-- DBUnit --> <dependency> <groupId>org.dbunit</groupId> <artifactId>dbunit</artifactId> <version>${dbunit-version}</version> <scope>test</scope> </dependency> <!-- MySQL --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql-version}</version> </dependency> <!-- Hibernate --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>${hibernate-version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>${hibernate-annotations-version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>${hibernate-entitymanager-version}</version> </dependency> <!-- Spring Framework --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>aopalliance</groupId> <artifactId>aopalliance</artifactId> <version>${aopalliance-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-asm</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jpa</artifactId> <version>${spring-jpa-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-mock</artifactId> <version>${spring-mock-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring-version}</version> <scope>test</scope> </dependency> <!-- Common --> <dependency> <groupId>com.exmple</groupId> <artifactId>Common</artifactId> <version>${project.version}</version> </dependency> </dependencies> </project>
POM War :
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <artifactId>Parent</artifactId> <groupId>com.exemple</groupId> <version>1.0-SNAPSHOT</version> </parent> <groupId>com.exmple</groupId> <artifactId>EJB</artifactId> <version>1.0-SNAPSHOT</version> <packaging>ejb</packaging> <name>EJB</name> <properties> <maven.test.failure.ignore>true</maven.test.failure.ignore> <javaee-version>6.0</javaee-version> <junit-version>4.8.1</junit-version> </properties> <dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>${javaee-version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit-version}</version> <scope>test</scope> </dependency> <dependency> <groupId>com.exmple</groupId> <artifactId>Business</artifactId> <version>${project-version}</version> <type>jar</type> </dependency> <dependency> <groupId>com.exemple</groupId> <artifactId>Common</artifactId> <version>${project-version}</version> <type>jar</type> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.1</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <configuration> <classpath>/src/main/java</classpath> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <version>2.2.1</version> <configuration> <ejbVersion>3.1</ejbVersion> <generateClient >true</generateClient> </configuration> </plugin> </plugins> <finalName>EJB</finalName> </build> </project>
POM EAR :
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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <artifactId>Parent</artifactId> <groupId>com.exmple</groupId> <version>1.0-SNAPSHOT</version> </parent> <groupId>com.exemple</groupId> <artifactId>Web</artifactId> <name>Web</name> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <properties> <maven.test.failure.ignore>true</maven.test.failure.ignore> <spring-version>3.0.4.RELEASE</spring-version> <spring-jpa-version>2.0.8</spring-jpa-version> <struts-version>2.0.6</struts-version> <servlet-version>2.4</servlet-version> <jsp-version>2.0</jsp-version> <junit-version>4.8.1</junit-version> <dbunit-version>2.2</dbunit-version> </properties> <dependencies> <!-- Log4J --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.14</version> </dependency> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jpa</artifactId> <version>${spring-jpa-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring-version}</version> </dependency> <!-- Struts --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>${struts-version}</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-spring-plugin</artifactId> <version>${struts-version}</version> </dependency> <!-- JUnit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit-version}</version> <scope>test</scope> </dependency> <!-- DBUnit --> <dependency> <groupId>org.dbunit</groupId> <artifactId>dbunit</artifactId> <version>${dbunit-version}</version> <scope>test</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>${servlet-version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jsp-api</artifactId> <version>${jsp-version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.exemple</groupId> <artifactId>Common</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.exmple</groupId> <artifactId>EJB</artifactId> <version>1.0-SNAPSHOT</version> <type>ejb-client</type> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> </project>
Donc au final mon WAR devrait embarquer les librairies des framework webs, utilaires, le jar de Common et le jar EJB client (cad juste une interface).
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 <?xml version="1.0"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <artifactId>Parent</artifactId> <groupId>com.exemple</groupId> <version>1.0-SNAPSHOT</version> </parent> <groupId>com.exemple</groupId> <artifactId>EAR</artifactId> <packaging>ear</packaging> <version>1.0-SNAPSHOT</version> <name>EAR</name> <properties> <maven.test.failure.ignore>true</maven.test.failure.ignore> </properties> <dependencies> <dependency> <groupId>com.exemple</groupId> <artifactId>EJB</artifactId> <version>${project.version}</version> <type>ejb</type> </dependency> </dependencies> <build> <finalName>EAR</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <configuration> <modules> <ejbModule> <groupId>com.exemple</groupId> <artifactId>EJB</artifactId> </ejbModule> </modules> </configuration> </plugin> </plugins> </build> </project>
Or quand je génère mon war, je retrouve avec toutes les librairies métiers, c'est à dire le jar du projet Business et toutes ses dépendances....
Je finis par tourner en rond et ne sais plus ou prospecter. Je me demande si il n'y aurait pas un soucis avec le plugin EJB, car le jar EJB complet a bien une dépendance sur le projet Business.
Est-ce que quelqu'un à une idée, ou mieux aurait déjà rencontré ce problème.
Merci de votre aide.
Partager