Announcement Announcement Module
Collapse
No announcement yet.
Caused by: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in contex Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Caused by: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in contex

    Hello,

    Can you any body please suggest my below problem...

    I am writing springDao to access data from data base and I created datasource in webspehere and its working fine(when click the test connection it was successfull).

    I configured my DAO in terminal-ws-servlet.xml file

    <bean id="terminalDao" class="com.fedex.terminal.dao.TerminalDAOImpl">
    <property name="dataSource" ref="db2DataSource" />
    </bean>


    <bean id="db2DataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="resourceRef" value="false" />
    <property name="jndiName" value="jdbc/db2DataSource" />
    </bean>
    (OR)[ I tried both ways]

    <bean id="terminalDao" class="com.fedex.terminal.dao.TerminalDAOImpl">
    <property name="dataSource" ref="db2DataSource" />
    </bean>


    <bean id="db2DataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="resourceRef" value="false" />
    <property name="jndiName" value="java:comp/env/jdbc/db2DataSource" />
    </bean>


    I built war file and deployed and when I try to invoke my application I am getting below problem

    [3/25/09 11:37:58:576 EDT] 00000025 SystemOut O 2009-03-25 11:37:58,482 ERROR (org.springframework.ws.transport.http.MessageDisp atcherServlet:290) - Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'terminalDao' defined in ServletContext resource [/WEB-INF/terminal-ws-servlet.xml]: Cannot resolve reference to bean 'db2DataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'db2DataSource' defined in ServletContext resource [/WEB-INF/terminal-ws-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:275)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:104)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1245)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1010)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:472)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Access Controller.java:214)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 64)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:261 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:164)
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'db2DataSource' defined in ServletContext resource [/WEB-INF/terminal-ws-servlet.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:473)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory$1.run(AbstractAutowireC apableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Access Controller.java:214)
    Caused by: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
    at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInt ernal(NameSpace.java:1767)
    at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal( NameSpace.java:1083)
    at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpac e.java:991)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(Ur lContextImpl.java:1263)
    at com.ibm.ws.naming.java.javaURLContextImpl.lookup(j avaURLContextImpl.java:384)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(j avaURLContextRoot.java:204)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(j avaURLContextRoot.java:144)
    at javax.naming.InitialContext.lookup(InitialContext. java:363)
    at org.springframework.jndi.JndiTemplate$1.doInContex t(JndiTemplate.java:155)
    at org.springframework.jndi.JndiTemplate.execute(Jndi Template.java:88)

  • #2
    jsut try to use like below
    <property name="jndiName" value="jdbc/db2DataSource" />

    Comment

    Working...
    X