Results 1 to 5 of 5

Thread: Problems with Hsql dataSource for petclinic

Hybrid View

  1. #1
    Join Date
    Oct 2006
    Location
    Sydney
    Posts
    12

    Default Problems with Hsql dataSource for petclinic

    I have read the doco. on Petclinic DataBase setup re: connection pooled DataSource with Tomcat. I guess this is a Tomcat Hsql issue but I'm a newbie struggling to get my first sample app. running so please forgive me ;-).

    For Hsql the petclinic doco. says I need to place petstore_tomcat_hsql.xml in apache-tomcat-5.5.20\webapps.

    I placed hsqldb.jar in apache-tomcat-5.5.20\common\lib

    The Hsql database is started. As I can do queries using the Hsql manager.

    I receive the following exception when starting tomcat.

    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
    Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
    at org.apache.naming.NamingContext.lookup(NamingConte xt.java:769)

  2. #2
    Join Date
    Jul 2006
    Location
    Philadelphia, PA, USA
    Posts
    341

    Default

    Hey mclachpa,

    This seems like a JNDI issue, and I haven't worked with JNDI yet besides some reading.

    However, I don't think it's enough to simply place petstore_tomcat_hsql.xml in $CATALINA_HOME/webapps. Don't you need to configure the DataSource in the $CATALINA_HOME/conf/server.xml file? I also wasn't able to find any mention of doing so in the Petclinic documentation, so I may be wrong here.

    Here is some info on configuring a JNDI DataSource in Tomcat: http://tomcat.apache.org/tomcat-5.5-...les-howto.html

    Also, have you gotten the application working with a locally defined DataSource first?

    Hope this helps!

    -Arthur Loder

  3. #3
    Join Date
    Oct 2006
    Location
    Sydney
    Posts
    12

    Default Cannot create JDBC driver of class '' for connect URL 'null'

    Yes I got further.

    I had to uncomment the reference to the resource in web.xml.

    Now having problems with the DataSource retreival using the newly named org.apache.tomcat.dbcp.dbcp.BasicDataSource. (I just love it how these things change names every so often,...not!)

    The exception I get is :

    2006-10-27 15:34:17,861 WARN [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 0, SQLState: null
    2006-10-27 15:34:17,861 ERROR [org.hibernate.util.JDBCExceptionReporter] - Cannot create JDBC driver of class '' for connect URL 'null'2006-10-27 15:34:17,861 WARN [org.hibernate.cfg.SettingsFactory] - Could not obtain connection metadata
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.create DataSource(BasicDataSource.java:780)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getCon nection(BasicDataSource.java:540)
    at org.springframework.orm.hibernate3.LocalDataSource ConnectionProvider.getConnection(LocalDataSourceCo nnectionProvider.java:81)
    at org.hibernate.cfg.SettingsFactory.buildSettings(Se ttingsFactory.java:76)
    at org.hibernate.cfg.Configuration.buildSettings(Conf iguration.java:1933)
    at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1216)
    at org.springframework.orm.hibernate3.LocalSessionFac toryBean.newSessionFactory(LocalSessionFactoryBean .java:807)
    at org.springframework.orm.hibernate3.LocalSessionFac toryBean.buildSessionFactory(LocalSessionFactoryBe an.java:740)
    at org.springframework.orm.hibernate3.AbstractSession FactoryBean.afterPropertiesSet(AbstractSessionFact oryBean.java:131)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1062)

    I'm pretty sure the Resource is configured correctly in Tomcxat with the NEW!! configuration style.

    <Resource
    auth="Container"
    name="jdbc/petclinic"
    type="javax.sql.DataSource"
    password=""
    driverClassName="org.hsqldb.jdbcDriver"
    maxIdle="2"
    maxWait="5000"
    username="sa"
    url="jdbc:hsqldb:hsql://localhost:9001"
    maxActive="4"
    factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" />

    The Tomcat administrator shows it normally configured
    Last edited by mclachpa; Oct 27th, 2006 at 12:43 AM.

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    I pasted your error into google and there are lots of resources talking about the same thing. Might be worth having a look through those.

    http://www.laliluna.de/260.html for example

  5. #5
    Join Date
    Oct 2006
    Location
    Sydney
    Posts
    12

    Default

    That was the last missing piece. My context.xml now looks like.

    <Context path="/petclinic" debug="1" reloadable="false">
    <Loader loaderClass="org.springframework.instrument.classl oading.tomcat.TomcatInstrumentableClassLoader" useSystemClassLoaderAsParent="false"/>
    <ResourceLink global='jdbc/petclinic' name='jdbc/petclinic' type="javax.sql.Datasource"/>
    </Context>

    Quite a bit different to what was downloaded and run "out-of-the box". Maybe somebody would like to update the petclinic config files and doco for the next poor newbie trying to impress his boss ;-)

Posting Permissions

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