Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help with IllegalArgumentException: Object: ... is not a known entity type.

610861Nov 28 2007 — edited Apr 1 2008
Hi there.

I'm trying to get TopLink JPA running with Oracle / Spring / JUnit, but so far with no success. The exception I get when trying to persist my rather simple entity is :

///////////////////

java.lang.IllegalArgumentException: Object: com.yospace.tundra.mediafarm.job.Job@38b554 is not a known entity type.
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:3198)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.persist(EntityManagerImpl.java:190)
...

///////////////////
My entity class is :

package com.yospace.tundra.mediafarm.job;

// imports ...

@Entity()
public class Job
{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

public Job()
{
}

/**
* @return the id
*/
public Long getId()
{
return id;
}

/**
* Set the id of this job.
*
* @param id
*/
public void setId(Long id)
{
this.id = id;
}
}

///////////////////
My persistence.xml is :

<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_1_0.xsd" version="1.0">
<persistence-unit name="TundraPu" transaction-type="RESOURCE_LOCAL">
<provider>
oracle.toplink.essentials.PersistenceProvider
</provider>

<!-- List all entity classes here. -->
<class>com.yospace.tundra.mediafarm.job.Job</class>
<properties>
<property name="toplink.logging.level" value="FINE"/>
</properties>
</persistence-unit>
</persistence>

///////////////////
My spring.xml is :

<?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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

<bean id="jobDao" class="com.yospace.tundra.mediafarm.job.JobDao">
</bean>

<!-- Location of test database configuration. -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/test/resources/jdbc.properties</value>
</list>
</property>
</bean>

<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"
value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>

<!-- Toplink JPA entity manager configuration. -->
<bean id="loadTimeWeaver" class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver"/>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter">
<property name="databasePlatform"
value="${jpavendor.dialect}" />
<property name="generateDdl" value="true" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="loadTimeWeaver" ref="loadTimeWeaver"/>
</bean>

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

<!-- JPA transaction manager configuration. -->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory"
ref="entityManagerFactory" />
</bean>

<tx:annotation-driven transaction-manager="transactionManager" />

</beans>


This fails when I run a JUnit test under Eclipse -- it falls over on the first operation, which creates then attempts to persist a job.

I wonder if anyone has any ideas as to what exactly I'm doing wrong ...?

Thanks,
Henry
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 29 2008
Added on Nov 28 2007
8 comments
7,795 views