Announcement Announcement Module
No announcement yet.
NoInitialContextException Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • NoInitialContextException

    when i test junit testDAO i obtain this error message
    and i don't know why

        [junit] Testcase: testGetCartes(fr.seb.dao.CarteDAOTest):  Caused an ERROR
        [junit] Error creating bean with name 'dataSource' defined in file [C:\sebFuse\build\test\dao\classes\fr\ratp\dao\applicationContext-resources.xml]
    : Initialization of bean 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

  • #2
    You JNDI context is not initialized - you can either use a inside your classpath or create it adhoc in your application. You can do that programatically or through Spring.
    You can find more information inside the official JNDI manual, on this forum and inside the javadocs from the org.springramework.jndi package.


    • #3
      ok thanks you're right
      i have directly modified my datasource in my applicationContext-resources.xml:
      <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
              <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
              <property name="url" value="jdbc:oracle:thin:xxxx/[email protected]:xxx"/>
              <property name="username" value="xxxx"/>
              <property name="password" value="xxxx"/>
      But now when i try to launch my test-DAO, i get
      GetJdbcConnectionException: Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]; nested exception is java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
      It doesn't find my driver Oracle which i put on my classpath, web-inf/lib etc... instead of it's work with my mysql-connector.jar...
      Where can i put my driver ?


      • #4
        make sure the driverClassName is correct. By default libraries should be in web-inf/lib - if your jar is there and readable it will be read.
        Make sure you don't have another oracle jar which might create classpath clashes.


        • #5
          I am sure, i have the lib

          i'm running ant test-dao with the raibble's framework
          Last edited by seb_fou; Feb 13th, 2006, 10:53 AM.