the app context below, when run in my unit test (belower), generates the message:
"Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [placesDaoTest.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.apache.derby.jdbc.InternalDriver.embeddedDrive rAcceptsURL(Ljava/lang/String
Z"
(full stack trace at bottom).
i am at a loss why derby is getting involved (does it's driver accept anything no one else will take?), much less why something is calling a non-existent method within derby...
appcontext:
HTML Code:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans [url]http://www.springframework.org/schema/beans/spring-beans-2.0.xsd[/url] [url]http://www.springframework.org/schema/aop[/url] [url]http://www.springframework.org/schema/aop/spring-aop-2.0.xsd[/url] [url]http://www.springframework.org/schema/lang[/url] http://www.springframework.org/schema/lang/spring-lang-2.5.xsd">
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@localhost:1521:XE" />
<property name="username" value="zasupitts" />
<property name="password" value="password" />
</bean>
<bean id="sessionFactory" destroy-method="close"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>Place.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">Oracle9Dialect</prop>
<prop key="hibernate.show_sql">yes</prop>
<prop key="hibernate.max_fetch_depth">2</prop>
<prop key="hibernate.connection.release_mode">after_statement</prop>
</props>
</property>
</bean>
<bean id="daoUtil" class="my.HibernateUtil">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="dbPlaceDao" class="my.utilimpl.PlaceDAOImpl">
<property name="daoUtil" ref="daoUtil"/>
</bean>
<bean id="cachePlaceDao" class="my.cacheimpl.PlaceDAOImpl">
<property name="realPlaceDao" ref="dbPlaceDao"/>
</bean>
</beans>
crappity unit test:
Code:
package my.test.dao;
import my.dao.PlaceDAO;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:placesDaoTest.xml")
public class PlaceDAOImplTest {
@Autowired
@Qualifier("cachePlaceDao")
private PlaceDAO cachePlaceDao;
@Autowired
@Qualifier("dbPlaceDao")
private PlaceDAO dbPlaceDao;
@Test
public void getAllPlaces() {
Assert.assertNotNull(cachePlaceDao.getAllPlaces());
}
}
chopped-up stack trace:
Buildfile: build-test.xml
test:
[junit] Testsuite: my.test.dao.PlaceDAOImplTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 2.143 sec
[junit] ------------- Standard Error -----------------
[junit] ERROR [main] (TestContextManager.java:258) - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener@29ce8c] to prepare test instance [my.test.dao.PlaceDAOImplTest@b754b2]
[junit] java.lang.IllegalStateException: Failed to load ApplicationContext
[junit] at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:203)
...(trimmed)...
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnit TestRunner.main(JUnitTestRunner.java:766)
[junit] Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [placesDaoTest.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.apache.derby.jdbc.InternalDriver.embeddedDrive rAcceptsURL(Ljava/lang/String;)Z
[junit] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1337)
...(trimmed)...
[junit] at org.springframework.test.context.TestContext.getAp plicationContext(TestContext.java:199)
[junit] ... 14 more
[junit] Caused by: java.lang.NoSuchMethodError: org.apache.derby.jdbc.InternalDriver.embeddedDrive rAcceptsURL(Ljava/lang/String;)Z
[junit] at org.apache.derby.jdbc.AutoloadedDriver.connect(Unk nown Source)
[junit] at java.sql.DriverManager.getConnection(DriverManager .java:582)
...(trimmed)...
[junit] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1334)
[junit] ... 30 more
[junit] ------------- ---------------- ---------------
[junit]