Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Eclipselink 2.0 with Spring 3: has anyone yet managed it
Eclipselink 2.0 with Spring 3: has anyone yet managed it [message #534345] Tue, 18 May 2010 18:20 Go to next message
Marc Schlegel is currently offline Marc SchlegelFriend
Messages: 92
Registered: July 2009
Member
Hello Everyone

Since quite some time I am trying to configure my little app to use
EclipseLink 2.0 with JPA 2 and configure it via Spring 3.

I am using the latest Spring release (3.0.2) and I am running into all
kinds of errors when the application is started.

My persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
persistence_2_0.xsd"
version="1.0">
<!-- version="2.0"> -->

<persistence-unit name="itea" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider >
<class>de.eye4eye.itea.model.User</class>
<class>de.eye4eye.itea.model.EntityBase</class>
<properties>
<property name="javax.persistence.jdbc.url"
value="jdbc:mysql://localhost:3306/itea" />
<property name="javax.persistence.jdbc.driver"
value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.username" value="itea" />
<property name="javax.persistence.jdbc.password" value="4711" />
<property name="eclipselink.target-database" value="MySQL" />
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.logging.level" value="INFO" />
</properties>
</persistence-unit>

My latest attempt in the spring-configuration looks like this

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0 .xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context -3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/lang
http://www.springframework.org/schema/lang/spring-lang-3.0.x sd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.x sd"
>

<bean id="entityManagerFactory"
class=" org.springframework.orm.jpa.LocalContainerEntityManagerFacto ryBean ">
<property name="jpaVendorAdapter">
<bean
class=" org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapt er ">
</bean>
</property>
</bean>
</beans>



I am getting this error and I couldnt find any resources on it

org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'entityManagerFactory' defined in class path resource
[jpa.spring.xml]: Invocation of init method failed; nested exception is
java.lang.reflect.UndeclaredThrowableException


Sorry, that I cannot more precise. I am a beginner in Jpa and Spring. If
someone has a working example it would be awesome

Thanks in advance.
Marc
Re: Eclipselink 2.0 with Spring 3: has anyone yet managed it [message #534383 is a reply to message #534345] Tue, 18 May 2010 22:09 Go to previous messageGo to next message
Marc Schlegel is currently offline Marc SchlegelFriend
Messages: 92
Registered: July 2009
Member
Well, I got it running, but dont ask me what exactly I am doing here ( I
was just putting together some snippets I found here and there). If I am
running JPA2 now...I dont know :D

This is my bean-configuration

<bean id="entityManagerFactory"

class=" org.springframework.orm.jpa.LocalContainerEntityManagerFacto ryBean ">
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitName" value="itea" />
<property name="jpaDialect" ref="jpaDialect" />
<property name="jpaVendorAdapter">
<bean
class=" org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapt er ">
</bean>
</property>
<property name="loadTimeWeaver">
<bean

class=" org.springframework.instrument.classloading.SimpleLoadTimeWe aver " />
</property>
</bean>

<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource ">
<property name="username" value="db" />
<property name="password" value="xxxx" />
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/itea" />
</bean>

<bean id="jpaDialect"
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect " />

<bean
class=" org.springframework.orm.jpa.support.PersistenceAnnotationBea nPostProcessor "/>


BUT I AM A BIT CONFUSED BY THIS: why do I need to specify the
database-information for Spring again when I already have within the
persistence.xml?

Please enlighten me :)


Am 18.05.2010 20:20, schrieb Marc:
> Hello Everyone
>
> Since quite some time I am trying to configure my little app to use
> EclipseLink 2.0 with JPA 2 and configure it via Spring 3.
>
> I am using the latest Spring release (3.0.2) and I am running into all
> kinds of errors when the application is started.
>
> My persistence.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> persistence_2_0.xsd"
> version="1.0">
> <!-- version="2.0"> -->
>
> <persistence-unit name="itea" transaction-type="RESOURCE_LOCAL">
> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider >
> <class>de.eye4eye.itea.model.User</class>
> <class>de.eye4eye.itea.model.EntityBase</class>
> <properties>
> <property name="javax.persistence.jdbc.url"
> value="jdbc:mysql://localhost:3306/itea" />
> <property name="javax.persistence.jdbc.driver"
> value="com.mysql.jdbc.Driver" />
> <property name="javax.persistence.jdbc.username" value="itea" />
> <property name="javax.persistence.jdbc.password" value="4711" />
> <property name="eclipselink.target-database" value="MySQL" />
> <property name="eclipselink.ddl-generation" value="create-tables"/>
> <property name="eclipselink.logging.level" value="INFO" />
> </properties>
> </persistence-unit>
>
> My latest attempt in the spring-configuration looks like this
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:aop="http://www.springframework.org/schema/aop"
> xmlns:context="http://www.springframework.org/schema/context"
> xmlns:jee="http://www.springframework.org/schema/jee"
> xmlns:lang="http://www.springframework.org/schema/lang"
> xmlns:tx="http://www.springframework.org/schema/tx"
> xmlns:util="http://www.springframework.org/schema/util"
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0 .xsd
> http://www.springframework.org/schema/aop
> http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context -3.0.xsd
> http://www.springframework.org/schema/jee
> http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
> http://www.springframework.org/schema/lang
> http://www.springframework.org/schema/lang/spring-lang-3.0.x sd
> http://www.springframework.org/schema/tx
> http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
> http://www.springframework.org/schema/util
> http://www.springframework.org/schema/util/spring-util-3.0.x sd"
> >
>
> <bean id="entityManagerFactory"
> class=" org.springframework.orm.jpa.LocalContainerEntityManagerFacto ryBean ">
> <property name="jpaVendorAdapter">
> <bean
> class=" org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapt er ">
> </bean>
> </property>
> </bean>
> </beans>
>
>
>
> I am getting this error and I couldnt find any resources on it
>
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'entityManagerFactory' defined in class path resource
> [jpa.spring.xml]: Invocation of init method failed; nested exception is
> java.lang.reflect.UndeclaredThrowableException
>
>
> Sorry, that I cannot more precise. I am a beginner in Jpa and Spring. If
> someone has a working example it would be awesome
>
> Thanks in advance.
> Marc
Re: Eclipselink 2.0 with Spring 3: has anyone yet managed it [message #534869 is a reply to message #534383] Thu, 20 May 2010 13:42 Go to previous message
Shaun Smith is currently offline Shaun SmithFriend
Messages: 197
Registered: July 2009
Senior Member
On 18/5/2010 6:09 PM, Marc wrote:
> BUT I AM A BIT CONFUSED BY THIS: why do I need to specify the
> database-information for Spring again when I already have within the
> persistence.xml?
>
> Please enlighten me :)

When using Spring you should define a datasource which will be passed to
EclipseLink when it creates the EntityManagerFactory. And when using a
datasource you don't provide database login properties.

Take a look at the Spring JPA PetClinic for a full example.

--Shaun

>
>
> Am 18.05.2010 20:20, schrieb Marc:
>> Hello Everyone
>>
>> Since quite some time I am trying to configure my little app to use
>> EclipseLink 2.0 with JPA 2 and configure it via Spring 3.
>>
>> I am using the latest Spring release (3.0.2) and I am running into all
>> kinds of errors when the application is started.
>>
>> My persistence.xml
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>
>> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>> persistence_2_0.xsd"
>> version="1.0">
>> <!-- version="2.0"> -->
>>
>> <persistence-unit name="itea" transaction-type="RESOURCE_LOCAL">
>> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider >
>> <class>de.eye4eye.itea.model.User</class>
>> <class>de.eye4eye.itea.model.EntityBase</class>
>> <properties>
>> <property name="javax.persistence.jdbc.url"
>> value="jdbc:mysql://localhost:3306/itea" />
>> <property name="javax.persistence.jdbc.driver"
>> value="com.mysql.jdbc.Driver" />
>> <property name="javax.persistence.jdbc.username" value="itea" />
>> <property name="javax.persistence.jdbc.password" value="4711" />
>> <property name="eclipselink.target-database" value="MySQL" />
>> <property name="eclipselink.ddl-generation" value="create-tables"/>
>> <property name="eclipselink.logging.level" value="INFO" />
>> </properties>
>> </persistence-unit>
>>
>> My latest attempt in the spring-configuration looks like this
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <beans xmlns="http://www.springframework.org/schema/beans"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:aop="http://www.springframework.org/schema/aop"
>> xmlns:context="http://www.springframework.org/schema/context"
>> xmlns:jee="http://www.springframework.org/schema/jee"
>> xmlns:lang="http://www.springframework.org/schema/lang"
>> xmlns:tx="http://www.springframework.org/schema/tx"
>> xmlns:util="http://www.springframework.org/schema/util"
>> xsi:schemaLocation="http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans-3.0 .xsd
>> http://www.springframework.org/schema/aop
>> http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
>> http://www.springframework.org/schema/context
>> http://www.springframework.org/schema/context/spring-context -3.0.xsd
>> http://www.springframework.org/schema/jee
>> http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
>> http://www.springframework.org/schema/lang
>> http://www.springframework.org/schema/lang/spring-lang-3.0.x sd
>> http://www.springframework.org/schema/tx
>> http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
>> http://www.springframework.org/schema/util
>> http://www.springframework.org/schema/util/spring-util-3.0.x sd"
>> >
>>
>> <bean id="entityManagerFactory"
>> class=" org.springframework.orm.jpa.LocalContainerEntityManagerFacto ryBean ">
>> <property name="jpaVendorAdapter">
>> <bean
>> class=" org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapt er ">
>> </bean>
>> </property>
>> </bean>
>> </beans>
>>
>>
>>
>> I am getting this error and I couldnt find any resources on it
>>
>> org.springframework.beans.factory.BeanCreationException: Error creating
>> bean with name 'entityManagerFactory' defined in class path resource
>> [jpa.spring.xml]: Invocation of init method failed; nested exception is
>> java.lang.reflect.UndeclaredThrowableException
>>
>>
>> Sorry, that I cannot more precise. I am a beginner in Jpa and Spring. If
>> someone has a working example it would be awesome
>>
>> Thanks in advance.
>> Marc
>


--
Oracle <http://www.oracle.com>
Shaun Smith | Principal Product Manager
Phone: +19055023094
Oracle Server Technologies, Oracle TopLink
ORACLE Canada | 110 Matheson Boulevard West, Suite 100, Mississauga,
Ontario | L5R 3P4
Green Oracle <http://www.oracle.com/commitment> Oracle is committed to
developing practices and products that help protect the environment
Previous Topic:[ANN] EMFT Texo: generating pure pojos and the ORM from ecore/xsd models
Next Topic:Native query mapping requires JPA annotations
Goto Forum:
  


Current Time: Fri Mar 29 06:32:14 GMT 2024

Powered by FUDForum. Page generated in 0.02265 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top