0 Replies Latest reply on Oct 4, 2017 10:01 AM by arnoldbenda

    javax.naming.NamingNotFoundException:jdbc/fc

    arnoldbenda

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cpDataSource': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: jdbc/fc

       

      I am using wildfly 10 and Here is web.xml .

      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" 
      xsi
      :schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      id
      ="WebApp_ID" version="3.0">
      <context-param id="ParamValue_1395228155626">
           <param-name>contextConfigLocation</param-name>
           <param-value>WEB-INF/applicationContext.xml</param-value>
      </context-param> 
      <resource-ref>
           <description>Oracle example</description>
           <res-ref-name>jdbc/fc</res-ref-name>
           <res-type>javax.sql.DataSource</res-type>
           <res-auth>Container</res-auth>
      </resource-ref>
      <servlet id="Init">
           <servlet-name>Init Servlet</servlet-name>
           <servlet-class>com.cedar.cp.utc.common.InitServlet</servlet-class>
           <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet>
           <servlet-name>reviewbudget</servlet-name>
           <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
           <load-on-startup>9</load-on-startup>
      </servlet>
      <listener>
           <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      <listener>
           <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
      </listener>
      </web-app>

      This is context.xml

       

      <?xml version='1.0' encoding='utf-8'?> 
      <Context crossContext="true" reloadable="true">
      <WatchedResource>WEB-INF/web.xml</WatchedResource> 
      <Resource name="java:jboss/jdbc/fc"
      auth="Container" type="javax.sql.DataSource"
      driverClassName="oracle.jdbc.driver.OracleDriver"
      url="jdbc:oracle:thin:@127.0.0.1:1521:orcl"
      username="C##user" password="windows7password"
      maxActive="20" maxIdle="10" maxWait="-1"/>
      </Context>

      Here is applicationContext.xml

       

      <?xml version="1.0" encoding="UTF-8"?> 
      <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns
      :p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
      xmlns
      :aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee"
      xmlns
      :tx="http://www.springframework.org/schema/tx"
      xsi
      :schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd"> 
      <jee:jndi-lookup id="cpDataSource" jndi-name="java:jboss/jdbc/fc" expected-type="javax.sql.DataSource" />
      <jee:jndi-lookup id="oaDataSource" jndi-name="java:jboss/jdbc/fc" expected-type="javax.sql.DataSource" /> 
      <tx:annotation-driven transaction-manager="transactionManager" /> 
      <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
           <property name="dataSource" ref="cpDataSource" /> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
           <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl"/>
           <property name="username" value="C##user1"/> <property name="password" value="windows7password"/>
      </bean>  
      </beans>

      How can I fix this issue? Thanks.