Results 1 to 5 of 5

Thread: NoInitialContextException

  1. #1
    Join Date
    Feb 2006
    Location
    Paris
    Posts
    35

    Default NoInitialContextException

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

    Code:
        [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. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    You JNDI context is not initialized - you can either use a jndi.properties 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.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Feb 2006
    Location
    Paris
    Posts
    35

    Exclamation

    ok thanks you're right
    i have directly modified my datasource in my applicationContext-resources.xml:
    Code:
    <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/xxxx@xxxxxxx:xxx"/>
            <property name="username" value="xxxx"/>
            <property name="password" value="xxxx"/>
    </bean>
    But now when i try to launch my test-DAO, i get
    Code:
    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. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  5. #5
    Join Date
    Feb 2006
    Location
    Paris
    Posts
    35

    Default

    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 at 09:53 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •