Bonjour ,
Il y'as quelques jours mon application marché bien avec la configuration de la Connexion BoneCP , mais plus maintenant , Ça m'affiche cette erreur (et je ne sais pas vraiment d'ou viens le problème) :
Mon code d'inisialisation du DaoFactory :
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 SEVERE: Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) com.tomo.config.InisiatlisationDAOFactory java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at com.jolbox.bonecp.BoneCPConfig.<clinit>(BoneCPConfig.java:60) at com.tomo.dao.DAOFactory.getInstance(DAOFactory.java:66) at com.tomo.config.InisiatlisationDAOFactory.contextInitialized(InisiatlisationDAOFactory.java:20) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 13 more
Code DaoFactory :
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 @WebListener public class InisiatlisationDAOFactory implements ServletContextListener { private DAOFactory daoFactory; public static final String InisialDaoFactory = "daoFactory"; @Override public void contextInitialized( ServletContextEvent config ) { ServletContext context = config.getServletContext(); this.daoFactory = DAOFactory.getInstance(); context.setAttribute( InisialDaoFactory, this.daoFactory ); } @Override public void contextDestroyed( ServletContextEvent config ) { // TODO Auto-generated method stub } }
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 public class DAOFactory { private static String fichier_proprieter = "/com/tomo/dao/dao.properties"; private static String prop_url = "url"; private static String prop_driver = "driver"; private static String prop_nomUtilisateur = "nomutilisateur"; private static String prop_motdepasse = "motdepasse"; private static BoneCP boneCP; public DAOFactory( BoneCP boneCP ) { super(); this.boneCP = boneCP; } public static DAOFactory getInstance() throws DAOConfigurationException { Properties properties = new Properties(); String url; String driver; String nomUtilisateur; String motDePasse; ClassLoader classe = Thread.currentThread().getContextClassLoader(); InputStream fichier = classe.getResourceAsStream( fichier_proprieter ); if ( fichier == null ) { throw new DAOConfigurationException( "Le fichier " + fichier_proprieter + " introuvable" ); } try { properties.load( fichier ); url = properties.getProperty( prop_url ); driver = properties.getProperty( prop_driver ); nomUtilisateur = properties.getProperty( prop_nomUtilisateur ); motDePasse = properties.getProperty( prop_motdepasse ); } catch ( IOException e ) { throw new DAOConfigurationException( "Le fichier " + fichier_proprieter + " n'as pas étais charger " + e ); } try { Class.forName( driver ); } catch ( ClassNotFoundException e ) { throw new DAOConfigurationException( "Chargement du driver echoue " + e ); } try { BoneCPConfig boneConfig = new BoneCPConfig(); boneConfig.setJdbcUrl( url ); boneConfig.setUsername( nomUtilisateur ); boneConfig.setPassword( motDePasse ); boneConfig.setMinConnectionsPerPartition( 5 ); boneConfig.setMaxConnectionsPerPartition( 10 ); boneConfig.setPartitionCount( 2 ); boneCP = new BoneCP( boneConfig ); } catch ( SQLException e ) { e.printStackTrace(); throw new DAOConfigurationException( "Erreur de configuration du pool de connexions " + e ); } DAOFactory instance = new DAOFactory( boneCP ); return instance; } Connection getConnection() throws SQLException { return boneCP.getConnection(); } public TomodachiDAO getTomodachiDAO() { return new TomodachiDAOimplement( this ); } }
Partager