JCMS 9 et datasources vers une BDD MySQL

Daniel WELTZ · le 16/06/15 à 11:31

Bonjour,

J'ai configuré une datasource dans le fichier context.xml de mon serveur tomcat comme suit :

<Context useHttpOnly="true" >

    <WatchedResource>WEB-INF/web.xml</WatchedResource>
	
	<Resource
		   name="jdbc/jcmsPool"
		   auth="Container"
		   type="javax.sql.DataSource"
		   driverClassName="com.mysql.jdbc.Driver"
		   url="jdbc:mysql://localhost:3306/jcmsdb?jdbcCompliantTruncation=false&useUnicode=true&characterEncoding=UTF-8"
		   username="jcms"
		   password="jcms"
		   maxActive="20"
		   maxIdle="10"
		   validationQuery="SELECT 1"
		/>

</Context>

Ma configuration dans l'espace d'administration est la suivante :

Intranet PRISME - Google Chrome 2015-06-16 11-23-57

Lorsque je clique sur : Vérifier la connexion, on un un message de succes de connexion, alors que  lorsque je relance le Tomcat, j'ai une erreur à la detection de la datasource.

Voici la trace dans le fichier log :

2015-06-15 17:03:16,241 INFO [localhost-startStop-1] [Intranet de compagnie] [jcmsplugin.ESNPlugin] - Register hibernate mapping: com/jalios/jcmsplugin/esn/analytics/ESNReportMetric.hbm.xml
2015-06-15 17:03:16,330 ERROR [localhost-startStop-1] [Intranet de compagnie] [connection.DatasourceConnectionProvider] - Could not find datasource: jdbc/jcmsPool
javax.naming.NameNotFoundException: Name [jdbc/jcmsPool] is not bound in this Context. Unable to find [jdbc].
at org.apache.naming.NamingContext.lookup(NamingContext.java:819)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:156)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:425)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2145)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2141)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1365)
at com.jalios.jcms.db.HibernateManager.buildSessionFactory(HibernateManager.java:309)
at com.jalios.jcms.Channel.initHibernate(Channel.java:1250)
at com.jalios.jcms.Channel.initAfterLoad(Channel.java:1337)
at com.jalios.jcms.ChannelInitServlet.init(ChannelInitServlet.java:130)
at com.jalios.jcms.ChannelInitServlet.init(ChannelInitServlet.java:81)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5229)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5516)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1898)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
2015-06-15 17:03:16,331 ERROR [localhost-startStop-1] [Intranet de compagnie] [db.HibernateManager] - Initial SessionFactory creation failed. org.hibernate.HibernateException: Could not find datasource
2015-06-15 17:03:16,332 FATAL [localhost-startStop-1] [Intranet de compagnie] [jcms.ChannelInitServlet] - An exception occured while initializing JCMS. The site is not available.
java.lang.ExceptionInInitializerError
at com.jalios.jcms.db.HibernateManager.buildSessionFactory(HibernateManager.java:315)
at com.jalios.jcms.Channel.initHibernate(Channel.java:1250)
at com.jalios.jcms.Channel.initAfterLoad(Channel.java:1337)
at com.jalios.jcms.ChannelInitServlet.init(ChannelInitServlet.java:130)
at com.jalios.jcms.ChannelInitServlet.init(ChannelInitServlet.java:81)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5229)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5516)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1247)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1898)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.hibernate.HibernateException: Could not find datasource
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:79)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:137)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:79)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:425)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:89)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2145)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2141)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1365)
at com.jalios.jcms.db.HibernateManager.buildSessionFactory(HibernateManager.java:309)
... 20 more
Caused by: javax.naming.NameNotFoundException: Name [jdbc/jcmsPool] is not bound in this Context. Unable to find [jdbc].
at org.apache.naming.NamingContext.lookup(NamingContext.java:819)
at org.apache.naming.NamingContext.lookup(NamingContext.java:167)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:156)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75)
... 28 more

 

Où se situe mon erreur de configuration ?

 

Daniel

12 pts
Frédéric Touitou - le 23/06/15 à 15:07
Meilleure réponse

Bonjour (à nouveau :-) ),

Suite à notre conversation téléphonique, je ne me souviens pas complètement des différentes configurations que vous avez testées.

Avez-vous essayé de configurer java:comp/env/jdbc/jcmsPool en tant que "Source de données JCMS" ?

Cf. la question et la réponse d'un autre client. :-)

Bien cordialement.

8 pts