Announcement Announcement Module
Collapse

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
java.lang.IllegalArgumentException: Object is not a known entity type. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    So... nobody can help with this?

    Could sombody provide me then a simple configuration for JPA (EclipseLink) working with Spring dynamic modules?

    Comment


    • #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>

      Comment


      • #4
        Hello!

        Could you show the full stacktrace when you have got IllegalArgumentException?

        Comment

        Working...
        X