• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JPA-hibernate-spring config

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have an issue setting up datasource for my entity manager factory under spring.

spring config xml
=========================
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/nbl" />
<property name="user" value="********" />
<property name="password" value="*******" />
<property name="maxPoolSize" value="10" />
<property name="maxStatements" value="0" />
<property name="minPoolSize" value="5" />
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">

<property name="persistenceUnitName" value="NBL" />
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false" />
<property name="generateDdl" value="true" />
<property name="database" value="MYSQL" />
</bean>
</property>
</bean>

Exception
===========================================
i am seeing this error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource
[com/pjs2k/nbl/test/resource/spring-config-test.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException:
Failed to convert property value of type [com.mchange.v2.c3p0.ComboPooledDataSource] to required type [javax.sql.DataSource] for property 'dataSource';
nested exception is java.lang.IllegalArgumentException: Original must not be null
...
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.mchange.v2.c3p0.ComboPooledDataSource]
to required type [javax.sql.DataSource] for property 'dataSource'; nested exception is java.lang.IllegalArgumentException: Original must not be null
at org.springframework.beans.BeanWrapperImpl.convertF
orProperty(BeanWrapperImpl.java:391)

Is this some bean set operation problem.

Not sure what i ma doing wrong. Have configured my setup based on samples from the internet.

Am running eclipse with jdk1.5

Any pointers much appeciated.

Thanks in advance
 
joe sinnott
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LocalEntityManagerFactoryBean does not seem to have a datasource property
how does this get set up in spring?
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try something like this ...

Persistence.xml


applicationContext.xml (not full, just relevant parts)



jdbc.properties for the PropertyPlaceholderConfigurer

 
mort sahl
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forgot to add this to the applicationContext ...

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic