Bonjour,
la meilleure facon de vous exposer mon probléme c'est de vous montrer mon code :
mon fichier applicationContext.xml
voici ma classe ParamGroupDAOImpl qui implémente l'interface ParamDAO :Code:
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 <?xml version="1.0" encoding="ISO_8859-1"?> <!DOCTYPE beans SYSTEM "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <!-- bean datasource --> <bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>com.sybase.jdbc2.jdbc.SybDriver</value> </property> <property name="url"> <value>jdbc:sybase:Tds:xxx.xxx.xxx.xxx:xxxx/dbParameter</value> </property> <property name="username"> <value>xxxx</value> </property> <property name="password"> <value>xxxx</value> </property> </bean> <!-- L'implémentation de la couche d'access aux données de type Groupe --> <bean id="paramGroupDaoImpl" class="monPackage.ParamGroupDAOImpl" > <property name="ds"> <ref local="ds"/> </property> </bean> <!-- L'implémentation de la couche métier de type Groupe --> <bean id="paramGroupManagerImpl" class="monPackage.ParamGroupManagerImpl"> <property name="dao"> <ref local="paramGroupDaoImpl" /> </property> </bean> </beans>
et voici ma classe service ParamGroupManagerImpl :Code:
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 public class ParamGroupDAOImpl implements ParamDAO { private DriverManagerDataSource ds; JdbcTemplate jdbcTemplate = new JdbcTemplate(ds); // Getter public DriverManagerDataSource getDs() { return ds; } // Setter public void setDs(DriverManagerDataSource ds) { this.ds = ds; } public ArrayList<ParamGroupBean> selectAll() { ArrayList<ParamGroupBean> listGroupBean = new ArrayList<ParamGroupBean>(); String sql = "SELECT * FROM PARAM_GROUPS"; try{ RowMapper mapper = new RowMapper() { public ParamGroupBean mapRow(ResultSet rs, int rowNum) throws SQLException { ParamGroupBean groupBean = new ParamGroupBean(); groupBean.setId(rs.getLong(1)); groupBean.setName(rs.getString(2)); groupBean.setGroupParentId(rs.getLong(3)); groupBean.setStatus(rs.getInt(4)); return groupBean; } }; listGroupBean.add((ParamGroupBean) jdbcTemplate.queryForObject(sql, mapper)); }catch(Exception e){ new LunamanagerException( "Une exception s'est produite dans la classe "+this.getClass().getName()+" : + "+e.getMessage(),1); } return listGroupBean; } }
et voici l'erreur comme quoi il trouve pas le dataSource :Code:
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 public class ParamGroupManagerImpl implements ParamGroupManager{ private ParamDAO dao; // mon interface // constructeur par defaut public ParamGroupManagerImpl() { } // setter public void setDao(ParamDAO dao) { this.dao = dao; } // getter public ParamDAO getDao() { return dao; } // synchronized pour empecher les acces multiples aux données, vu que la classe service est un singleton // retourne une liste contenant tous les groupes public synchronized ArrayList<ParamGroupBean> getAll() { ArrayList<ParamGroupBean> _groups = new ArrayList<ParamGroupBean>(); _groups = (ArrayList<ParamGroupBean>) dao.selectAll(); return _groups; } } // mon interface ParamDAO public interface ParamDAO { public Object selectAll(); }
[13:17:35.280] Server[] starting
[13:17:35.280]
[13:17:35.280] Windows XP 5.1 x86
[13:17:35.280] Java 1.5.0_08-b03, 32, mixed mode, sharing, Cp1252, fr, Sun Microsystems Inc.
[13:17:35.280] resin.home = C:\resin-pro-3.0.18
[13:17:35.280] server.root = C:\resin-pro-3.0.18
[13:17:35.280]
[13:17:35.374] Socket JNI library requires a valid Resin Professional License.
[13:17:35.374] See http://www.caucho.com/sales for information.
[13:17:35.374] http listening to *:8080
[13:17:35.437] hmux listening to localhost:6802
[13:17:35.530] Host[] starting
[13:17:35.812] In-place class redefinition (HotSwap) is not available. In-place class reloading during development requires a compatible JDK and -Xdebug.
[13:17:35.984] WebApp[http://localhost:8080] starting
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
[13:17:36.124] Loading Spring root WebApplicationContext
[13:17:37.077] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'paramGroupDaoImpl' defined in ServletContext resource [/WEB-INF/applicationC
ntext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [fr.framework.manager.paramete
.sybase.dao.ParamGroupDAOImpl]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: dataSource is required
[13:17:37.077] Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [fr.framework.manager.parameter.sybase.dao.ParamGroupDAOImpl]: Con
tructor threw exception; nested exception is java.lang.IllegalArgumentException: dataSource is required
[13:17:37.077] Caused by: java.lang.IllegalArgumentException: dataSource is required
[13:17:37.077] at org.springframework.jdbc.support.JdbcAccessor.afterPropertiesSet(JdbcAccessor.java:130)
[13:17:37.077] at org.springframework.jdbc.core.JdbcTemplate.<init>(JdbcTemplate.java:141)
[13:17:37.077] at fr.framework.manager.parameter.sybase.dao.ParamGroupDAOImpl.<init>(ParamGroupDAOImpl.java:24)
[13:17:37.077] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[13:17:37.077] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
[13:17:37.077] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
[13:17:37.077] at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
[13:17:37.077] at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:84)
[13:17:37.077] at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:60)
[13:17:37.077] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:52)
[13:17:37.077] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:640)
[13:17:37.077] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:626)
[13:17:37.077] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:381)
[13:17:37.077] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
[13:17:37.077] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:140)
[13:17:37.077] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
[13:17:37.077] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
[13:17:37.077] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:273)
[13:17:37.077] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
[13:17:37.077] at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
[13:17:37.077] at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
[13:17:37.077] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
[13:17:37.077] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
[13:17:37.077] at com.caucho.server.webapp.Application.start(Application.java:1592)
[13:17:37.077] at com.caucho.server.deploy.DeployController.startImpl(DeployController.java:587)
[13:17:37.077] at com.caucho.server.deploy.StartAutoRedeployAutoStrategy.startOnInit(StartAutoRedeployAutoStrategy.java:72)
[13:17:37.077] at com.caucho.server.deploy.DeployController.startOnInit(DeployController.java:475)
[13:17:37.077] at com.caucho.server.deploy.DeployContainer.start(DeployContainer.java:158)
[13:17:37.077] at com.caucho.server.webapp.ApplicationContainer.start(ApplicationContainer.java:651)
[13:17:37.077] at com.caucho.server.host.Host.start(Host.java:385)
[13:17:37.077] at com.caucho.server.deploy.DeployController.startImpl(DeployController.java:587)
[13:17:37.077] at com.caucho.server.deploy.StartAutoRedeployAutoStrategy.startOnInit(StartAutoRedeployAutoStrategy.java:72)
[13:17:37.077] at com.caucho.server.deploy.DeployController.startOnInit(DeployController.java:475)
[13:17:37.077] at com.caucho.server.deploy.DeployContainer.start(DeployContainer.java:158)
[13:17:37.077] at com.caucho.server.host.HostContainer.start(HostContainer.java:467)
[13:17:37.077] at com.caucho.server.resin.ServletServer.start(ServletServer.java:945)
[13:17:37.077] at com.caucho.server.deploy.DeployController.startImpl(DeployController.java:587)
[13:17:37.077] at com.caucho.server.deploy.AbstractDeployControllerStrategy.start(AbstractDeployControllerStrategy.java:56)
[13:17:37.077] at com.caucho.server.deploy.DeployController.start(DeployController.java:483)
[13:17:37.077] at com.caucho.server.resin.ResinServer.start(ResinServer.java:478)
[13:17:37.077] at com.caucho.server.resin.Resin.init(Resin.java)
[13:17:37.077] at com.caucho.server.resin.Resin.main(Resin.java:623)
Merci de m'aider.