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

  • JUnit testing

    I'm trying to run a series of junit tests , and in order to avoid the loading of my applicationContext.xml in each test class , I've setup an AllTests class that looks as shown below

    public class AllTests extends TestCase{
    public AllTests(String name){
    super(name);
    }

    public static Test suite(){

    TestSuite tsuite = new TestSuite("All Webservices calls tests");
    tsuite.addTestSuite(TestWebServices.class);
    TestSetup wrapper= new TestSetup(tsuite)
    {
    public void setUp(){
    System.out.println("Loading the root context....");
    ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext .xml");
    System.out.println("Done....");
    }
    };

    TestSuite realSuite = new TestSuite();
    realSuite.addTest(wrapper);
    return realSuite;
    }
    }

    My applicationContext.xml imports other config xml files as shown below :

    <beans>

    <import resource="ldapContext.xml"/>
    <import resource="emailContext.xml"/>
    <import resource="databaseContext.xml"/>
    -----
    -----
    </beans>
    When I run AllTests as a junit test(from eclipse) , the loading of the xml files seem to get stuck at loading ldapContext.xml ,as shown in my output:
    Loading the root context....
    2006/09/14 02:37:59 org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
    2006/09/14 02:37:59 org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [ldapContext.xml]
    The folder containing the xml files is in my classpath , and it looks like applicationContext.xml is loaded successfully , but everything gets stuck when trying to load ldapContext.xml

    What am doing wrong?

  • #2
    Turn on logging at debug level - probably something network connection in your ldapContext is blocking the startup - it should time out after a couple of minutes.
    Try to isolate your problem by using less contexts and after discovering the one that causes you problem, looking at the bean definitions.

    Comment


    • #3
      Problem sorted. However , with the approach in my first post I can't seem to be able to get any beans injected in my tests, even though I do have getters and setters for the beans.Any suggestion?

      Comment


      • #4
        You may want to look at AbstractDependencyInjectionSpringContextTests that does the context caching and injection out of the box.

        Comment


        • #5
          There is a slight problem with using AbstractDependencyInjectionSpringContextTests.

          Two ways:
          1. use it in every test case, the bean is injected. As long as only one test is carried out, it works. (context, jdbc library is loaded) For the second bean test case it tries loading the context and jdbc library again, which produces an error ( [junit] java.lang.UnsatisfiedLinkError: Native Library /.../instantclient_10_2/libocijdbc10.so already loaded in another classloader)

          2. I couldnt yet manage to set up context in a TestSuite and inject beans to TestCase-es.

          Any suggestions?

          Comment


          • #6
            Strange, can you post the source of the test (edited)?

            Comment


            • #7
              Originally posted by Rod Johnson View Post
              Strange, can you post the source of the test (edited)?
              Rod , why doesn't the code in my original post work?(I got the strategy from the Turbine website)

              Comment


              • #8
                Here is all you need to understand the situation, i guess.
                The error log is in the next post.

                ----------------------------------------------------
                package xxx.dao.jdbc;

                import org.springframework.dao.DataAccessException;
                import org.springframework.jdbc.core.support.JdbcDaoSuppo rt;

                import xxx.dao.DictionaryDAO;
                import xxx.helpers.oracle.ClobExtractor;

                public class DictionaryDAOJdbc extends JdbcDaoSupport implements DictionaryDAO {
                ...
                }


                ------------------------------------------------------------------


                package xxx.tests;

                import org.springframework.test.AbstractDependencyInjecti onSpringContextTests;

                import xxx.dao.DictionaryDAO;

                public class DictionaryDAOJdbcTest extends AbstractDependencyInjectionSpringContextTests {

                DictionaryDAO dictionaryDAO;

                /*
                * Test method for 'xxx.dao.jdbc.DictionaryDAOJdbc.getDictionary(Stri ng)'
                */
                public void testGetDictionary() {
                assertNull(getDictionaryDAO().getDictionary("not existing dictionary"));
                assertNotNull(getDictionaryDAO().getDictionary("YE SNO"));
                }

                public DictionaryDAO getDictionaryDAO() {
                return dictionaryDAO;
                }

                public void setDictionaryDAO(DictionaryDAO dictionaryDAO) {
                this.dictionaryDAO = dictionaryDAO;
                }

                @Override
                protected String[] getConfigLocations() {
                return new String[] {
                "classpath:WEB-INF/applicationContext.xml",
                "classpath:WEB-INF/applicationContext-jdbc.xml"
                };
                }

                }

                ----------------------------------------------------

                package xxx.tests;

                import org.springframework.test.AbstractDependencyInjecti onSpringContextTests;

                import xxx.dao.MedicalTestDAO;

                public class MedicalTestDAOJdbcTest extends AbstractDependencyInjectionSpringContextTests {

                MedicalTestDAO medicalTestDAO;

                /*
                * Test method for 'xxx.dao.jdbc.MedicalTestDAOJdbc.getCCDForMedicalT est(int)'
                */
                public void testGetCCDForMedicalTest() throws Exception {
                assertNotNull(getMedicalTestDAO().getCCDForMedical Test(200));
                }
                ...

                public MedicalTestDAO getMedicalTestDAO() {
                return medicalTestDAO;
                }

                public void setMedicalTestDAO(MedicalTestDAO medicalTestDAO) {
                this.medicalTestDAO = medicalTestDAO;
                }

                @Override
                protected String[] getConfigLocations() {
                return new String[] {
                "classpath:WEB-INF/applicationContext.xml",
                "classpath:WEB-INF/applicationContext-jdbc.xml"
                };
                }

                }

                ----------------------------------------------------
                allicationContext.xml:
                ----------------------------------------------------
                <?xml version="1.0" encoding="UTF-8"?>
                <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

                <beans>

                <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
                <property name="location">
                <value>/WEB-INF/jdbc.properties</value>
                </property>
                </bean>

                ...
                </beans>

                -----------------------------------------------
                applicationContext-jdbc.xml:
                -----------------------------------------------
                <?xml version="1.0" encoding="UTF-8"?>
                <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

                <beans>

                <!-- Local DataSource that works in any environment -->
                <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
                <property name="driverClassName"><value>${jdbc.driverClassNa me}</value></property>
                <property name="url"><value>${jdbc.url}</value></property>
                <property name="username"><value>${jdbc.username}</value></property>
                <property name="password"><value>${jdbc.password}</value></property>
                </bean>

                <!-- Transaction manager for Spring JDBC -->
                <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
                <property name="dataSource"><ref bean="dataSource"/></property>
                </bean>

                <bean id="dictionaryDAO" class="xxx.dao.jdbc.DictionaryDAOJdbc">
                <property name="dataSource"><ref bean="dataSource"/></property>
                </bean>

                <bean id="medicalTestDAO" class="xxx.dao.jdbc.MedicalTestDAOJdbc">
                <property name="dataSource"><ref bean="dataSource"/></property>
                <property name="transactionManager"><ref bean="transactionManager"/></property>
                </bean>
                ...
                </beans>

                Comment


                • #9
                  ---------------------------------------------------
                  JUnit test ANT task output:
                  ---------------------------------------------------

                  junit:
                  [junit] Running xxx.tests.CardioControllerTest
                  [junit] Sep 23, 2006 12:15:26 PM org.springframework.core.CollectionFactory <clinit>
                  [junit] INFO: JDK 1.4+ collections available
                  [junit] Sep 23, 2006 12:15:26 PM xxx.controller.CardioController handleRequest
                  [junit] INFO: returning hello view
                  [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.192 sec
                  [junit] Testsuite: xxx.tests.CardioControllerTest
                  [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.192 sec

                  [junit] ------------- Standard Error -----------------
                  [junit] Sep 23, 2006 12:15:26 PM org.springframework.core.CollectionFactory <clinit>
                  [junit] INFO: JDK 1.4+ collections available
                  [junit] Sep 23, 2006 12:15:26 PM xxx.controller.CardioController handleRequest
                  [junit] INFO: returning hello view
                  [junit] ------------- ---------------- ---------------
                  [junit] Running xxx.tests.DictionaryDAOJdbcTest
                  [junit] Sep 23, 2006 12:15:26 PM org.springframework.test.AbstractSpringContextTest s loadContextLocations
                  [junit] INFO: Loading config for: classpath:WEB-INF/applicationContext.xml,classpath:WEB-INF/applicationContext-jdbc.xml
                  [junit] Sep 23, 2006 12:15:26 PM org.springframework.core.CollectionFactory <clinit>
                  [junit] INFO: JDK 1.4+ collections available
                  [junit] Sep 23, 2006 12:15:26 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
                  [junit] INFO: Loading XML bean definitions from class path resource [WEB-INF/applicationContext.xml]
                  [junit] Sep 23, 2006 12:15:27 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
                  [junit] INFO: Loading XML bean definitions from class path resource [WEB-INF/applicationContext-jdbc.xml]
                  [junit] Sep 23, 2006 12:15:27 PM org.springframework.context.support.AbstractRefres hableApplicationContext refreshBeanFactory
                  [junit] INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=13086732]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [propertyConfigurer,patientMan,medicalTestMan,userM an,dictionaryMan,medicalTestSignalMan,medicalTestI ncrementalSignalMan,medicalTestAnnotationsMan,medi calTestGraphMan,CCDMan,medicalTestDataMan,dataSour ce,transactionManager,patientDAO,userDAO,dictionar yDAO,medicalTestDAO]; root of BeanFactory hierarchy
                  [junit] Sep 23, 2006 12:15:27 PM org.springframework.context.support.AbstractApplic ationContext refresh
                  [junit] INFO: 17 beans defined in application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=13086732]
                  [junit] Sep 23, 2006 12:15:27 PM org.springframework.core.io.support.PropertiesLoad erSupport loadProperties
                  [junit] INFO: Loading properties file from class path resource [WEB-INF/jdbc.properties]
                  [junit] Sep 23, 2006 12:15:27 PM org.springframework.context.support.AbstractApplic ationContext initMessageSource
                  [junit] INFO: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMess ageSource@15253d5]
                  [junit] Sep 23, 2006 12:15:27 PM org.springframework.context.support.AbstractApplic ationContext initApplicationEventMulticaster
                  [junit] INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicatio nEventMulticaster@9df354]
                  [junit] Sep 23, 2006 12:15:28 PM org.springframework.beans.factory.support.DefaultL istableBeanFactory preInstantiateSingletons
                  [junit] INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [propertyConfigurer,patientMan,medicalTestMan,userM an,dictionaryMan,medicalTestSignalMan,medicalTestI ncrementalSignalMan,medicalTestAnnotationsMan,medi calTestGraphMan,CCDMan,medicalTestDataMan,dataSour ce,transactionManager,patientDAO,userDAO,dictionar yDAO,medicalTestDAO]; root of BeanFactory hierarchy]
                  [junit] Sep 23, 2006 12:15:28 PM org.springframework.jdbc.datasource.DriverManagerD ataSource setDriverClassName
                  [junit] INFO: Loaded JDBC driver: oracle.jdbc.driver.OracleDriver
                  [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 4.907 sec
                  [junit] Testsuite: xxx.tests.DictionaryDAOJdbcTest
                  [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 4.907 sec

                  [junit] ------------- Standard Error -----------------
                  [junit] Sep 23, 2006 12:15:26 PM org.springframework.test.AbstractSpringContextTest s loadContextLocations
                  [junit] INFO: Loading config for: classpath:WEB-INF/applicationContext.xml,classpath:WEB-INF/applicationContext-jdbc.xml
                  [junit] Sep 23, 2006 12:15:26 PM org.springframework.core.CollectionFactory <clinit>
                  [junit] INFO: JDK 1.4+ collections available
                  [junit] Sep 23, 2006 12:15:26 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
                  [junit] INFO: Loading XML bean definitions from class path resource [WEB-INF/applicationContext.xml]
                  [junit] Sep 23, 2006 12:15:27 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
                  [junit] INFO: Loading XML bean definitions from class path resource [WEB-INF/applicationContext-jdbc.xml]
                  [junit] Sep 23, 2006 12:15:27 PM org.springframework.context.support.AbstractRefres hableApplicationContext refreshBeanFactory
                  [junit] INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=13086732]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [propertyConfigurer,patientMan,medicalTestMan,userM an,dictionaryMan,medicalTestSignalMan,medicalTestI ncrementalSignalMan,medicalTestAnnotationsMan,medi calTestGraphMan,CCDMan,medicalTestDataMan,dataSour ce,transactionManager,patientDAO,userDAO,dictionar yDAO,medicalTestDAO]; root of BeanFactory hierarchy
                  [junit] Sep 23, 2006 12:15:27 PM org.springframework.context.support.AbstractApplic ationContext refresh
                  [junit] INFO: 17 beans defined in application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=13086732]
                  [junit] Sep 23, 2006 12:15:27 PM org.springframework.core.io.support.PropertiesLoad erSupport loadProperties
                  [junit] INFO: Loading properties file from class path resource [WEB-INF/jdbc.properties]
                  [junit] Sep 23, 2006 12:15:27 PM org.springframework.context.support.AbstractApplic ationContext initMessageSource
                  [junit] INFO: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMess ageSource@15253d5]
                  [junit] Sep 23, 2006 12:15:27 PM org.springframework.context.support.AbstractApplic ationContext initApplicationEventMulticaster
                  [junit] INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicatio nEventMulticaster@9df354]
                  [junit] Sep 23, 2006 12:15:28 PM org.springframework.beans.factory.support.DefaultL istableBeanFactory preInstantiateSingletons
                  [junit] INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [propertyConfigurer,patientMan,medicalTestMan,userM an,dictionaryMan,medicalTestSignalMan,medicalTestI ncrementalSignalMan,medicalTestAnnotationsMan,medi calTestGraphMan,CCDMan,medicalTestDataMan,dataSour ce,transactionManager,patientDAO,userDAO,dictionar yDAO,medicalTestDAO]; root of BeanFactory hierarchy]
                  [junit] Sep 23, 2006 12:15:28 PM org.springframework.jdbc.datasource.DriverManagerD ataSource setDriverClassName
                  [junit] INFO: Loaded JDBC driver: oracle.jdbc.driver.OracleDriver

                  Comment


                  • #10
                    [junit] ------------- ---------------- ---------------
                    [junit] Running xxx.tests.MedicalTestDAOJdbcTest
                    [junit] Sep 23, 2006 12:15:31 PM org.springframework.test.AbstractSpringContextTest s loadContextLocations
                    [junit] INFO: Loading config for: classpath:WEB-INF/applicationContext.xml,classpath:WEB-INF/applicationContext-jdbc.xml
                    [junit] Sep 23, 2006 12:15:31 PM org.springframework.core.CollectionFactory <clinit>
                    [junit] INFO: JDK 1.4+ collections available
                    [junit] Sep 23, 2006 12:15:31 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
                    [junit] INFO: Loading XML bean definitions from class path resource [WEB-INF/applicationContext.xml]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
                    [junit] INFO: Loading XML bean definitions from class path resource [WEB-INF/applicationContext-jdbc.xml]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.context.support.AbstractRefres hableApplicationContext refreshBeanFactory
                    [junit] INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=29056009]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [propertyConfigurer,patientMan,medicalTestMan,userM an,dictionaryMan,medicalTestSignalMan,medicalTestI ncrementalSignalMan,medicalTestAnnotationsMan,medi calTestGraphMan,CCDMan,medicalTestDataMan,dataSour ce,transactionManager,patientDAO,userDAO,dictionar yDAO,medicalTestDAO]; root of BeanFactory hierarchy
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.context.support.AbstractApplic ationContext refresh
                    [junit] INFO: 17 beans defined in application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=29056009]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.core.io.support.PropertiesLoad erSupport loadProperties
                    [junit] INFO: Loading properties file from class path resource [WEB-INF/jdbc.properties]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.context.support.AbstractApplic ationContext initMessageSource
                    [junit] INFO: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMess ageSource@facf0b]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.context.support.AbstractApplic ationContext initApplicationEventMulticaster
                    [junit] INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicatio nEventMulticaster@2f0df1]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.beans.factory.support.DefaultL istableBeanFactory preInstantiateSingletons
                    [junit] INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [propertyConfigurer,patientMan,medicalTestMan,userM an,dictionaryMan,medicalTestSignalMan,medicalTestI ncrementalSignalMan,medicalTestAnnotationsMan,medi calTestGraphMan,CCDMan,medicalTestDataMan,dataSour ce,transactionManager,patientDAO,userDAO,dictionar yDAO,medicalTestDAO]; root of BeanFactory hierarchy]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.jdbc.datasource.DriverManagerD ataSource setDriverClassName
                    [junit] INFO: Loaded JDBC driver: oracle.jdbc.driver.OracleDriver
                    [junit] Sep 23, 2006 12:15:32 PM xxx.dao.jdbc.MedicalTestDAOJdbc getCCDForMedicalTest
                    [junit] INFO: Getting CCD data for MedicalTest with ID: 200
                    [junit] Sep 23, 2006 12:15:33 PM xxx.dao.jdbc.MedicalTestDAOJdbc getTestUidForId
                    [junit] INFO: Getting UID for MedicalTest with ID: 240
                    [junit] Tests run: 21, Failures: 0, Errors: 2, Time elapsed: 1.922 sec
                    [junit] Testsuite: xxx.tests.MedicalTestDAOJdbcTest
                    [junit] Tests run: 21, Failures: 0, Errors: 2, Time elapsed: 1.922 sec

                    [junit] ------------- Standard Error -----------------
                    [junit] Sep 23, 2006 12:15:31 PM org.springframework.test.AbstractSpringContextTest s loadContextLocations
                    [junit] INFO: Loading config for: classpath:WEB-INF/applicationContext.xml,classpath:WEB-INF/applicationContext-jdbc.xml
                    [junit] Sep 23, 2006 12:15:31 PM org.springframework.core.CollectionFactory <clinit>
                    [junit] INFO: JDK 1.4+ collections available
                    [junit] Sep 23, 2006 12:15:31 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
                    [junit] INFO: Loading XML bean definitions from class path resource [WEB-INF/applicationContext.xml]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
                    [junit] INFO: Loading XML bean definitions from class path resource [WEB-INF/applicationContext-jdbc.xml]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.context.support.AbstractRefres hableApplicationContext refreshBeanFactory
                    [junit] INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=29056009]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [propertyConfigurer,patientMan,medicalTestMan,userM an,dictionaryMan,medicalTestSignalMan,medicalTestI ncrementalSignalMan,medicalTestAnnotationsMan,medi calTestGraphMan,CCDMan,medicalTestDataMan,dataSour ce,transactionManager,patientDAO,userDAO,dictionar yDAO,medicalTestDAO]; root of BeanFactory hierarchy
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.context.support.AbstractApplic ationContext refresh
                    [junit] INFO: 17 beans defined in application context [org.springframework.context.support.ClassPathXmlAp plicationContext;hashCode=29056009]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.core.io.support.PropertiesLoad erSupport loadProperties
                    [junit] INFO: Loading properties file from class path resource [WEB-INF/jdbc.properties]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.context.support.AbstractApplic ationContext initMessageSource
                    [junit] INFO: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMess ageSource@facf0b]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.context.support.AbstractApplic ationContext initApplicationEventMulticaster
                    [junit] INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicatio nEventMulticaster@2f0df1]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.beans.factory.support.DefaultL istableBeanFactory preInstantiateSingletons
                    [junit] INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [propertyConfigurer,patientMan,medicalTestMan,userM an,dictionaryMan,medicalTestSignalMan,medicalTestI ncrementalSignalMan,medicalTestAnnotationsMan,medi calTestGraphMan,CCDMan,medicalTestDataMan,dataSour ce,transactionManager,patientDAO,userDAO,dictionar yDAO,medicalTestDAO]; root of BeanFactory hierarchy]
                    [junit] Sep 23, 2006 12:15:32 PM org.springframework.jdbc.datasource.DriverManagerD ataSource setDriverClassName
                    [junit] INFO: Loaded JDBC driver: oracle.jdbc.driver.OracleDriver
                    [junit] Sep 23, 2006 12:15:32 PM xxx.dao.jdbc.MedicalTestDAOJdbc getCCDForMedicalTest
                    [junit] INFO: Getting CCD data for MedicalTest with ID: 200
                    [junit] Sep 23, 2006 12:15:33 PM xxx.dao.jdbc.MedicalTestDAOJdbc getTestUidForId
                    [junit] INFO: Getting UID for MedicalTest with ID: 240
                    [junit] ------------- ---------------- ---------------

                    Comment


                    • #11
                      [junit] Testcase: testGetCCDForMedicalTest(xxx.tests.MedicalTestDAOJ dbcTest): Caused an ERROR
                      [junit] Native Library /opt/oracle/instantclient_10_2/libocijdbc10.so already loaded in another classloader
                      [junit] java.lang.UnsatisfiedLinkError: Native Library /opt/oracle/instantclient_10_2/libocijdbc10.so already loaded in another classloader
                      [junit] at java.lang.ClassLoader.loadLibrary0(ClassLoader.jav a:1716)
                      [junit] at java.lang.ClassLoader.loadLibrary(ClassLoader.java :1676)
                      [junit] at java.lang.Runtime.loadLibrary0(Runtime.java:822)
                      [junit] at java.lang.System.loadLibrary(System.java:992)
                      [junit] at oracle.jdbc.driver.T2CConnection$1.run(T2CConnecti on.java:3135)
                      [junit] at java.security.AccessController.doPrivileged(Native Method)
                      [junit] at oracle.jdbc.driver.T2CConnection.loadNativeLibrary (T2CConnection.java:3131)
                      [junit] at oracle.jdbc.driver.T2CConnection.logon(T2CConnecti on.java:221)
                      [junit] at oracle.jdbc.driver.PhysicalConnection.<init>(Physi calConnection.java:414)
                      [junit] at oracle.jdbc.driver.T2CConnection.<init>(T2CConnect ion.java:132)
                      [junit] at oracle.jdbc.driver.T2CDriverExtension.getConnectio n(T2CDriverExtension.java:78)
                      [junit] at oracle.jdbc.driver.OracleDriver.connect(OracleDriv er.java:801)
                      [junit] at java.sql.DriverManager.getConnection(DriverManager .java:525)
                      [junit] at java.sql.DriverManager.getConnection(DriverManager .java:140)
                      [junit] at org.springframework.jdbc.datasource.DriverManagerD ataSource.getConnectionFromDriverManager(DriverMan agerDataSource.java:291)
                      [junit] at org.springframework.jdbc.datasource.DriverManagerD ataSource.getConnectionFromDriverManager(DriverMan agerDataSource.java:277)
                      [junit] at org.springframework.jdbc.datasource.DriverManagerD ataSource.getConnectionFromDriverManager(DriverMan agerDataSource.java:259)
                      [junit] at org.springframework.jdbc.datasource.DriverManagerD ataSource.getConnection(DriverManagerDataSource.ja va:241)
                      [junit] at org.springframework.jdbc.datasource.DataSourceUtil s.doGetConnection(DataSourceUtils.java:112)
                      [junit] at org.springframework.jdbc.datasource.DataSourceUtil s.getConnection(DataSourceUtils.java:77)
                      [junit] at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:462)
                      [junit] at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:528)
                      [junit] at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:561)
                      [junit] at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:570)
                      [junit] at xxx.dao.jdbc.MedicalTestDAOJdbc.getCCDForMedicalTe st(MedicalTestDAOJdbc.java:169)
                      [junit] at xxx.tests.MedicalTestDAOJdbcTest.testGetCCDForMedi calTest(MedicalTestDAOJdbcTest.java:15)


                      [junit] Testcase: testGetTestUidForId(xxx.tests.MedicalTestDAOJdbcTe st): Caused an ERROR
                      [junit] Native Library /opt/oracle/instantclient_10_2/libocijdbc10.so already loaded in another classloader
                      [junit] java.lang.UnsatisfiedLinkError: Native Library /opt/oracle/instantclient_10_2/libocijdbc10.so already loaded in another classloader
                      [junit] at java.lang.ClassLoader.loadLibrary0(ClassLoader.jav a:1716)
                      [junit] at java.lang.ClassLoader.loadLibrary(ClassLoader.java :1676)
                      [junit] at java.lang.Runtime.loadLibrary0(Runtime.java:822)
                      [junit] at java.lang.System.loadLibrary(System.java:992)
                      [junit] at oracle.jdbc.driver.T2CConnection$1.run(T2CConnecti on.java:3135)
                      [junit] at java.security.AccessController.doPrivileged(Native Method)
                      [junit] at oracle.jdbc.driver.T2CConnection.loadNativeLibrary (T2CConnection.java:3131)
                      [junit] at oracle.jdbc.driver.T2CConnection.logon(T2CConnecti on.java:221)
                      [junit] at oracle.jdbc.driver.PhysicalConnection.<init>(Physi calConnection.java:414)
                      [junit] at oracle.jdbc.driver.T2CConnection.<init>(T2CConnect ion.java:132)
                      [junit] at oracle.jdbc.driver.T2CDriverExtension.getConnectio n(T2CDriverExtension.java:78)
                      [junit] at oracle.jdbc.driver.OracleDriver.connect(OracleDriv er.java:801)
                      [junit] at java.sql.DriverManager.getConnection(DriverManager .java:525)
                      [junit] at java.sql.DriverManager.getConnection(DriverManager .java:140)
                      [junit] at org.springframework.jdbc.datasource.DriverManagerD ataSource.getConnectionFromDriverManager(DriverMan agerDataSource.java:291)
                      [junit] at org.springframework.jdbc.datasource.DriverManagerD ataSource.getConnectionFromDriverManager(DriverMan agerDataSource.java:277)
                      [junit] at org.springframework.jdbc.datasource.DriverManagerD ataSource.getConnectionFromDriverManager(DriverMan agerDataSource.java:259)
                      [junit] at org.springframework.jdbc.datasource.DriverManagerD ataSource.getConnection(DriverManagerDataSource.ja va:241)
                      [junit] at org.springframework.jdbc.datasource.DataSourceUtil s.doGetConnection(DataSourceUtils.java:112)
                      [junit] at org.springframework.jdbc.datasource.DataSourceUtil s.getConnection(DataSourceUtils.java:77)
                      [junit] at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:462)
                      [junit] at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:528)
                      [junit] at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:561)
                      [junit] at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:579)
                      [junit] at org.springframework.jdbc.core.JdbcTemplate.query(J dbcTemplate.java:589)
                      [junit] at org.springframework.jdbc.core.JdbcTemplate.queryFo rObject(JdbcTemplate.java:619)
                      [junit] at org.springframework.jdbc.core.JdbcTemplate.queryFo rObject(JdbcTemplate.java:629)
                      [junit] at xxx.dao.jdbc.MedicalTestDAOJdbc.getTestUidForId(Me dicalTestDAOJdbc.java:260)
                      [junit] at xxx.tests.MedicalTestDAOJdbcTest.testGetTestUidFor Id(MedicalTestDAOJdbcTest.java:36)


                      [junit] Test xxx.tests.MedicalTestDAOJdbcTest FAILED
                      [junit] Running xxx.tests.PatientManagerTest
                      [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.003 sec
                      [junit] Testsuite: xxx.tests.PatientManagerTest
                      [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.003 sec

                      Comment


                      • #12
                        You may want to try to use SingleConnectionDataSource instead of DriverManagerDataSource.

                        Comment


                        • #13
                          thanks for the reply, but unfortunately it produces the same error message. is there no setting to include in applicationcontext.xml or the datasource descriptor that makes spring load oracle drivers only once?

                          Comment


                          • #14
                            I believe the problem is not driver loading but something else. If you take a look at the stack trace the exception is thrown at the moment when connection is open and not when the datasource is created.

                            Comment


                            • #15
                              well as far as i see, the last error trace element is this:
                              [junit] at java.lang.ClassLoader.loadLibrary0(ClassLoader.jav a:1716)

                              which is for loading the oracle driver. i see that for the first time it has no problem loading it, but for the second time it finds it already loaded, so spring complains. maybe if i could tell it not try to load it twice, that would be nice.

                              Comment

                              Working...
                              X