-
Jun 28th, 2011, 02:07 AM
#1
java.lang.IllegalArgumentException: Object is not a known entity type.
Hi,
I have a bundle which use JPA (EclipseLink) and expose an OSGi service.
The exposed service is actually a DAO object with one method (persist()).
The class of the entity which needs to be persisted has the @Entity annotation, is included in this bundle, and is loaded by the EntityManagerFactory when this is created.
Another bundle get the service reference and call the persist() method.
Eaven if the table is successfully generated in the db!, I get the exception:
java.lang.IllegalArgumentException: Object: ExecutedJobEntity [id=0, jobClass=com.kno.cloud.job.rentalExpiry.RentalExpi ry, status=true, exception=null, startTime=Tue Jun 28 09:20:50 EEST 2011, endTime=Tue Jun 28 09:20:50 EEST 2011] is not a known entity type.
Here is my spring context.xml for the first bundle:
<context:annotation-config/>
<tx:annotation-driven />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" init-method="createDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/JPATest"/>
<property name="username" value="root"/>
<property name="password" value="P@ssword"/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="persistenceUnitName" value="ExecutedJobsService"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.EclipseL inkJpaVendorAdapter">
<property name="generateDdl" value="true"/>
<property name="showSql" value="true"/>
<property name="database" value="MYSQL"/>
<property name="databasePlatform" value="org.eclipse.persistence.platform.database.M ySQLPlatform"/>
</bean>
</property>
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading .SimpleLoadTimeWeaver"/>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionM anager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="executedJobDao" scope="bundle" class="com.kno.cloud.schedulerFramework.dao.Execut edJobDao"/>
<osgi:service id="executedJobDaoOSGiService" ref="executedJobDao" interface="com.kno.cloud.schedulerFramework.dao.IE xecutedJob" />
<bean class="org.springframework.orm.jpa.support.Persist enceAnnotationBeanPostProcessor"/>
This is my persistence.xml:
<persistence-unit name="ExecutedJobsService" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceP rovider</provider>
<class>com.kno.cloud.schedulerFramework.entities.E xecutedJobEntity</class>
</persistence-unit>
Any help is very appreciated!
Thanks,
Roland
-
Jun 29th, 2011, 11:14 AM
#2
So... nobody can help with this?
Could sombody provide me then a simple configuration for JPA (EclipseLink) working with Spring dynamic modules?
-
Jul 12th, 2011, 05:27 AM
#3
It seems that using JPA in OSGi is complicated, especially because of load time weaving and some other limitations. I spent 4 days without success trying to integrate it in the project.
However, using JDBC is pretty straight forward, just use the com.springsource.org.apache.commons.dbcp, and everithing works as expected:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" init-method="createDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/JDBCTest"/>
<property name="username" value=""/>
<property name="password" value=""/>
</bean>
-
Jul 19th, 2011, 01:17 AM
#4
Hello!
Could you show the full stacktrace when you have got IllegalArgumentException?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules