Results 1 to 3 of 3

Thread: who said anything about derby?

  1. #1
    Join Date
    Feb 2005
    Posts
    28

    Default who said anything about derby?

    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/StringZ"

    (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]

  2. #2
    Join Date
    Feb 2005
    Posts
    28

    Default solved...

    the problem was nothing to do spring of course. i had an old derby.jar in my classpath. i guess since derby (jdb?) is part of java6, it registers itself with the driver manager -- first. then when the URL came in, my old derby.jar classes got loaded in and didn't have the method the driver manager wanted.

    sheesh.

  3. #3
    Join Date
    Mar 2008
    Location
    SF Bay Area, California
    Posts
    11

    Question "then when the URL came in" ??

    I am still learning xml schema and using xmlns etc and
    i am curious about that phrase you used in your solved reply
    and to what exactly you refer.

    Is that phrase a reference to the "[url]" syntax in the xsi: ... part of the
    xmlns ? i have not seen the [url] syntax used before?
    I suppose i need a book on the latest definition of xml namespaces.

Posting Permissions

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