Bonjour,
j'essaye depuis un moment de fait fonctionner du logging depuis des EJB, mais j'ai toujours droit à un ClassNotFoundException... (java.lang.ClassNotFoundException: org.slf4j.LoggerFactory dans mon cas).
Le module war par contre fonctionne correctement et je parviens à logger depuis ce module (quit prend ses lib dans WEB-INF/lib).
Architecture du projet:
le pom.xml principal:
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 |-- nnWeb-ear | |-- pom.xml | `-- src | `-- main | |-- application | | `-- META-INF | | `-- MANIFEST.MF | `-- java |-- nnWeb-ejb | |-- pom.xml | `-- src | |-- main | | |-- java | | | `-- com | | | `-- test | | | `-- packaging | | | `-- SimpleStateLess.java | | `-- resources | | |-- logback.xml | | `-- META-INF | | `-- MANIFEST.MF | `-- test | `-- java | `-- com | `-- test | `-- packaging |-- nnWeb-web | |-- pom.xml | `-- src | |-- main | | |-- java | | | `-- com | | | `-- test | | | `-- packaging | | | |-- SimpleEJB.java | | | `-- SimpleServlet.java | | |-- resources | | | `-- logback.xml | | `-- webapp | | |-- index.jsp | | `-- WEB-INF | | `-- sun-web.xml | `-- test | `-- java `-- pom.xml
le pom.xml des 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 <?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> <groupId>com.test.packaging</groupId> <artifactId>nnWeb</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <name>nnWeb</name> <url>http://maven.apache.org</url> <modules> <module>nnWeb-ear</module> <module>nnWeb-web</module> <module>nnWeb-ejb</module> </modules> </project>
et de l'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 <?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>nnWeb</artifactId> <groupId>com.test.packaging</groupId> <version>1.0-SNAPSHOT</version> </parent> <groupId>com.test.packaging</groupId> <artifactId>nnWeb-ejb</artifactId> <packaging>ejb</packaging> <version>1.0-SNAPSHOT</version> <name>nnWebEjb</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>0.9.18</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.5.11</version> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> </dependencies> <repositories> <repository> <id>java.net2</id> <name>Java.Net Maven2 Repository, hosts the javaee-api dependency</name> <url>http://download.java.net/maven/2</url> </repository> </repositories> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <version>2.1</version> <configuration> <ejbVersion>3.1</ejbVersion> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>APP-INF/lib</classpathPrefix> </manifest> <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> </archive> </configuration> </plugin> </plugins> <finalName>nnWeb-ejb</finalName> </build> <profiles> <profile> <id>endorsed</id> <activation> <property> <name>sun.boot.class.path</name> </property> </activation> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <!-- javaee6 contains upgrades of APIs contained within the JDK itself. As such these need to be placed on the bootclasspath, rather than classpath of the compiler. If you don't make use of these new updated API, you can delete the profile. On non-SUN jdk, you will need to create a similar profile for your jdk, with the similar property as sun.boot.class.path in Sun's JDK.--> <compilerArguments> <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar${path.separator}${sun.boot.class.path}</bootclasspath> </compilerArguments> </configuration> <dependencies> <dependency> <groupId>javax</groupId> <artifactId>javaee-endorsed-api</artifactId> <version>6.0</version> </dependency> </dependencies> </plugin> </plugins> </build> </profile> </profiles> <properties> <netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server> </properties> </project>
et la bean de test, SimpleStateless.java:
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 <?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>nnWeb</artifactId> <groupId>com.test.packaging</groupId> <version>1.0-SNAPSHOT</version> </parent> <groupId>com.test.packaging</groupId> <artifactId>nnWeb-ear</artifactId> <packaging>ear</packaging> <version>1.0-SNAPSHOT</version> <name>nnWebEar</name> <url>http://maven.apache.org</url> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <version>2.4</version> <configuration> <version>6</version> <!-- <archive> <manifest> <addClasspath>true</addClasspath> </manifest> </archive>--> <defaultJavaBundleDir>APP-INF/lib</defaultJavaBundleDir> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>process-classes</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> <finalName>nnWeb-ear</finalName> </build> <dependencies> <dependency> <groupId>com.test.packaging</groupId> <artifactId>nnWeb-ejb</artifactId> <version>1.0-SNAPSHOT</version> <type>ejb</type> </dependency> <dependency> <groupId>com.test.packaging</groupId> <artifactId>nnWeb-web</artifactId> <version>1.0-SNAPSHOT</version> <type>war</type> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>0.9.18</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.5.11</version> </dependency> <dependency> <groupId>com.googlecode.sli4j</groupId> <artifactId>sli4j-slf4j-jdk14</artifactId> <version>2.0</version> </dependency> </dependencies> <properties> <netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server> </properties> </project>
une fois packagé, le ear ressemble à ça:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 package com.test.packaging; import javax.ejb.Stateless; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Stateless public class SimpleStateLess { private static Logger logger = LoggerFactory.getLogger(SimpleStateLess.class); public void constructLog(){ logger.debug("Finally got logging working in ejb module :)"); } }
et le Manifest des EJB, qui me semble en ordre:
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 |-- APP-INF | `-- lib | |-- aopalliance-1.0.jar | |-- guice-2.0.jar | |-- logback-classic-0.9.18.jar | |-- logback-core-0.9.18.jar | |-- slf4j-api-1.5.11.jar | |-- slf4j-jdk14-1.5.10.jar | |-- sli4j-core-2.0.jar | `-- sli4j-slf4j-jdk14-2.0.jar |-- META-INF | |-- application.xml | |-- MANIFEST.MF | `-- maven | `-- com.test.packaging | `-- nnWeb-ear | |-- pom.properties | `-- pom.xml |-- ngWeb-web.war `-- nnWeb-ejb.jar
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: dev
Build-Jdk: 1.6.0_21
Class-Path: APP-INF/lib/logback-classic-0.9.18.jar APP-INF/lib/logback
-core-0.9.18.jar APP-INF/lib/slf4j-api-1.5.11.jar
J'avoue que je suis un peu perdu (je débute avec Maven d'ailleurs).
Au besoin, un projet (allégé) qui reprend mon problème: [ame]http://rapidshare.com/files/425732230/EJBLogging.tar.gz[/ame]
Partager