Bonjour,
Je vous expose mon problème:
Je configure ma datasource comme d'ordinaire pour un projet (spring, hibernate) :
Dans component-context.xml j'ai :
Je définis donc mon datasource.
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 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan" value="com.altitude.bcweb.model" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">net.sf.hibernate.dialect.SQLServerDialect</prop> <prop key="hibernate.bytecode.provider">javassist</prop> <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</prop> <prop key="hibernate.cache.use_second_level_cache">true</prop> <!-- Query cache exclusivement utilisé pour le rescan de matériel --> <prop key="hibernate.cache.use_query_cache">true</prop> <!-- <prop key="hibernate.show_sql">true</prop> --> </props> </property> </bean> <!-- Transactions configurées via les annotations --> <tx:annotation-driven /> <!-- Transaction Manager --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- Configuration du PlaceHolder pour l'accès aux variables issues du fichier donneesTechniques-config.properties. --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>classpath:bcweb-config.properties</value> </property> </bean> </beans>
Ensuite dans dataSource-context.xml :
Enfin, lorsque je déplois mon appli, dans le deploy je place mon fichier :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 <jee:jndi-lookup id="dataSource" cache="false" jndi-name="java:/BcWebDataSource" />
bcweb-ds.xml comportant :
Ce système fonctionne pour plein d'autres projets que j'ai pu développer, la seule différence est que la datasource cette fois est du MSSQL à la place de mysql, mais j'ai fait tout pareil.... Aurais-je oublié quelque chose ?
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 <local-tx-datasource> <!-- The jndi name of the DataSource, it is prefixed with java:/ --> <!-- Datasources are not available outside the virtual machine --> <jndi-name>BcWebDataSource</jndi-name> <!-- Chaine de connexion vers la BD --> <connection-url>jdbc:sqlserver://XX-XXXXX-DEV:1433;DatabaseName=BCWEB</connection-url> <!-- The driver class --> <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class> <!-- The login and password --> <user-name>sa</user-name> <password>altitude</password> <!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use --> <min-pool-size>5</min-pool-size> <!-- The maximum connections in a pool/sub-pool --> <max-pool-size>51</max-pool-size> <!-- The time before an unused connection is destroyed --> <!-- NOTE: This is the check period. It will be destroyed somewhere between 1x and 2x this timeout after last use --> <idle-timeout-minutes>3</idle-timeout-minutes> <metadata> <type-mapping>MSSQL</type-mapping> </metadata> </local-tx-datasource>
Je précise que j'ai essayé de taper une autre base qui fonctionne pour etre sur que le souci ne vient pas de la connexion à la base, et j'ai le même comportement au démarrage; à savoir :
Help please
Code : Sélectionner tout - Visualiser dans une fenêtre à part Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring/component-context.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined
Merci d'avance
Partager