Announcement Announcement Module
Collapse
No announcement yet.
Problems setting up JPA2 (eclipselink) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems setting up JPA2 (eclipselink)

    The configuration below gives me the following error when trying to persist an ent. If I use"org.springframework.orm.jpa.LocalEntityManager FactoryBean" at least that work.

    If I use

    Code:
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> 
        <property name="persistenceUnitName" value="driftsloggPersistenceUnit" /> 
    </bean>
    this entityManagerFactory instead it works. What is wrong in my configuration. Can someone share eclipselink spring configuration?

    Thank you.



    Code:
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Object: no.mesta.driftslogg.services.Person[id=null, message='halloo....'] is not a known entity type.
    	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
    	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    	com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
    	com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)




    Code:
    <?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:context="http://www.springframework.org/schema/context"
    	xmlns:p="http://www.springframework.org/schema/p"
    	xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    
    
    
    	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory" />
    		<property name="dataSource" ref="dataSource" />
    	</bean>
    
    
    	<bean id="entityManager" class="org.springframework.orm.jpa.support.SharedEntityManagerBean" p:entityManagerFactory-ref="entityManagerFactory" />
    
    
    	<!-- //Works -->
    <!-- 	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> -->
    <!-- 	<property name="persistenceUnitName" value="driftsloggPersistenceUnit" /> -->
    <!-- 	</bean> -->
    
           <!-- //Does not work -->
    	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<property name="persistenceUnitName" value="driftsloggPersistenceUnit" />
    		<property name="dataSource" ref="dataSource" />
    		<property name="jpaDialect">
    			<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
    		</property>
    		<property name="jpaVendorAdapter">
    			<bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
    				<property name="databasePlatform" value="org.eclipse.persistence.platform.database.MySQLPlatform" />
    				<property name="showSql" value="true" />
    			</bean>
    		</property>
    		<property name="loadTimeWeaver">
    			<bean class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver" />
    		</property>
    	</bean>
    
    	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<property name="username" value="root" />
    		<property name="password" value="root" />
    		<property name="driverClassName" value="com.mysql.jdbc.Driver" />
    		<property name="url" value="jdbc:mysql://localhost/driftslogg" />
    	</bean>
    
    
    	<context:property-placeholder location="classpath:jdbc.properties" />
    
    
    	<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
    
    
    </beans>

    Edit:
    This is the output
    Code:
    [EL Info]: 2012-04-28 09:04:54.174--ServerSession(942973384)--Thread(Thread[http-bio-8080-exec-3,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.0.0.v20091127-r5931
    [EL Config]: 2012-04-28 09:04:54.19--ServerSession(942973384)--Connection(184859875)--Thread(Thread[http-bio-8080-exec-3,5,main])--connecting(DatabaseLogin(
    	platform=>MySQLPlatform
    	user name=> "root"
    	connector=>JNDIConnector datasource name=>null
    ))
    [EL Config]: 2012-04-28 09:04:54.367--ServerSession(942973384)--Connection(1762819149)--Thread(Thread[http-bio-8080-exec-3,5,main])--Connected: jdbc:mysql://localhost/driftslogg
    	User: root@localhost
    	Database: MySQL  Version: 5.5.16
    	Driver: MySQL-AB JDBC Driver  Version: mysql-connector-java-5.1.9 ( Revision: ${svn.Revision} )
    [EL Config]: 2012-04-28 09:04:54.369--ServerSession(942973384)--Connection(1623236944)--Thread(Thread[http-bio-8080-exec-3,5,main])--connecting(DatabaseLogin(
    	platform=>MySQLPlatform
    	user name=> "root"
    	connector=>JNDIConnector datasource name=>null
    ))
    [EL Config]: 2012-04-28 09:04:54.378--ServerSession(942973384)--Connection(119518863)--Thread(Thread[http-bio-8080-exec-3,5,main])--Connected: jdbc:mysql://localhost/driftslogg
    	User: root@localhost
    	Database: MySQL  Version: 5.5.16
    	Driver: MySQL-AB JDBC Driver  Version: mysql-connector-java-5.1.9 ( Revision: ${svn.Revision} )
    [EL Info]: 2012-04-28 09:04:54.387--ServerSession(942973384)--Thread(Thread[http-bio-8080-exec-3,5,main])--file:/Users/phe/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/driftslogg/WEB-INF/classes/_driftsloggPersistenceUnit login successful
    so I get a connection.

    Persistence unit
    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    	version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
    	<persistence-unit name="driftsloggPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    	 	<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    		<exclude-unlisted-classes>false</exclude-unlisted-classes>
    		<properties>
    			<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
    			<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/driftslogg" />
    			<property name="javax.persistence.jdbc.user" value="root" />
    			<property name="javax.persistence.jdbc.password" value="root" />
    
    			<!-- EclipseLink should create the database schema automatically -->
    			<property name="eclipselink.ddl-generation" value="create-tables" />
    			<property name="eclipselink.ddl-generation.output-mode" value="database" />
    		</properties>
    
    	</persistence-unit>
    </persistence>
    Last edited by phe; Apr 28th, 2012, 03:13 AM.
Working...
X