Hi to all members,
I have a simple (but not for me) question
I'm trying to set a connection pool for Jetty and Tomcat, in my Web Application, however I'm really confused hot to configure the spring applicationContext. I tried in many ways but with no succes
This is part of my Spring appContext:
and the jetty-env.xml file:Code:<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>java:comp/env/jdbc/cs</value> </property> </bean>
Finally in my web.xml I inserted :Code:<Configure class="org.mortbay.jetty.webapp.WebAppContext"> <Set name="contextPath">/dev</Set> <New id="cs" class="org.mortbay.jetty.plus.naming.Resource"> <Arg>jdbc/cs</Arg> <Arg> <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"> <Set name="Url">jdbc:mysql://localhost/spring3</Set> <Set name="DriverClassName">com.mysql.jdbc.Driver</Set> <Set name="Username">root</Set> <Set name="Password">root</Set> <Set name="MaxActive">30</Set> <Set name="MaxIdle">10</Set> <Set name="MinIdle">2</Set> <Set name="MaxWait">5000</Set> <Set name="MinEvictableIdleTimeMillis">25000</Set> <Set name="TimeBetweenEvictionRunsMillis">30000</Set> </New> </Arg> </New>
Unfortunately I receive this error:Code:<resource-ref> <res-ref-name>jdbc/cs</res-ref-name> <res-type> javax.sql.DataSource </res-type> <res-auth>Container</res-auth> </resource-ref>
And I don't know where is the problem!! I'm trying to avoid to put password and username in the applicationContext, even using a properties file, I would like to have all configuration files outside the WAR, so I can change DB or application server easier.Code:2009-06-11 14:35:57,687 [main] ERROR in [org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:215)] - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'GenericDAO' defined in class path resource [spring-bsi-core.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring-bsi-collab-war-applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [spring-bsi-collab-war-applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method)
Please help meI'm really stuck on this problems since days...
Thanks in advance!
Mystique




Reply With Quote

