If JNDI name is "java:comp/env/jdbc/SutkiDB" then @Resource.name should be "jdbc/SutkiDB". Jarek On Wed, Jun 4, 2008 at 10:01 AM, timo.ratilainen wrote: > > Hello > > I'm trying to inject a datasource with the @Resource annotation: > > @Repository > public class UserDao { > > @Resource(name = "SutkiDB") > private DataSource SutkiDB; > > ... > } > > When I try to deploy the application following trace is shown: > > Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: > No bean named 'SutkiDB' is defined > at > org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:388) > at > org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:976) > at > org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:245) > at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:184) > at > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:167) > at > org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:422) > at > org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:497) > at > org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:182) > at > org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:104) > at > org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessAfterInstantiation(CommonAnnotationBeanPostProcessor.java:288) > > > Why? Isn't the datasource object found from the JNDI tree or what is the > problem? > > > > > The datasource is defined in the Global Context JNDI: > > jca:/console.dbpool/SutkiDB/JCAManagedConnectionFactory/SutkiDB > > and in the ResourceAdapterModule (what is this by the way?) JNDI: > > console.dbpool/SutkiDB/1.0/rar > > > > geronimo-web.xml > > > > > > > fi.company.sutki > SutkiAdminGui > 1.0 > car > > > > console.dbpool > SutkiDB > > > > org.springframework > org.apache.commons. > org.apache.log4j > > > > > /SutkiAdminTool > > > > > jdbc/SutkiDB > SutkiDB > > > > > and in web.xml > > > jdbc/SutkiDB > javax.sql.DataSource > Container > Shareable > > > > and spring's applicationContext.xml: > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:context="http://www.springframework.org/schema/context" > xsi:schemaLocation="http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd > http://www.springframework.org/schema/context > > http://www.springframework.org/schema/context/spring-context-2.5.xsd"> > > > > > > > > > > I'm using Apache Geronimo v2.1 and Spring 2.5.2. > Datasource connection was working fine with good old initialContext lookup: > > DataSource datasource = (DataSource) > initialContext.lookup("java:comp/env/jdbc/SutkiDB"); > > > > > Regards > Timo Ratilainen > > > > -- > View this message in context: http://www.nabble.com/Injecting-datasource-with-the-%40Resource-annotation-tp17647494s134p17647494.html > Sent from the Apache Geronimo - Users mailing list archive at Nabble.com. > >