Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Hibernate - MySQL - Error connecting

  1. #11
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Is the properties file in the ROOT of the class directory (I assume you mean classes in the WEB-INF directory?). Else try changing classpath: to classpath:/ (although I thought that spring strips the leading slash).

    Also make sure that all the keys are in the properties file and that they are correct (also check my spelling because I did it from the top of my head).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  2. #12
    Join Date
    Mar 2009
    Location
    Spain
    Posts
    9

    Default Still didn't get it.

    Hello.

    Re-taking this. Any help?

    Thank you again, Marten.

    But I still have this problem.

    I know this has to be very simple. I am not getting to read from a properties file. (hibernate.properties)

    In applicationContext.xml I have this:

    Code:
    <bean class="org.springframework.beans.factory.PropertyPlaceHolderConfigurer">
    		<property name="locations" value="classpath:./hibernate.properties" />
    </bean>
    
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    		<property name="username" value="${hibernate.connection.username}" />
    		<property name="password" value="${hibernate.connection.password}" />
    		<property name="url" value="${hibernate.connection.url}" />
    		<property name="driverClassName" value="${hibernate.connection.driver_class}" />
    		<property name="initialSize" value="5" />
    		<property name="maxActive" value="20" />
    </bean>
    And in the hibernate.properties I have:

    Code:
    hibernate.connection.driver_class=com.mysql.jdbc.Driver
    hibernate.connection.url=jdbc:mysql://localhost:3306/consulta
    hibernate.connection.username=ElPiter
    hibernate.connection.password=password
    hibernate.dialect=org.hibernate.dialect.MySQLDialect
    However, I am getting this error when creating context (starting up Tomcat Server):

    Code:
    GRAVE: Context initialization failed
    org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Could not resolve placeholder 'hibernate.connection.username'
    The properties file is in WEB-INF/classes. And the spelling is correct. As far as I checked it N-1 times

    Obviously something must be wrong. But I don't get what it is.
    Would you take a new look?

    Thanks, Pedro
    Last edited by pgbonino; May 10th, 2009 at 05:37 AM. Reason: changing greetings

  3. #13
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Enable debug logging and see if the file gets read. If it isn't it isn't in the location you think it is...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

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