Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » "No [EntityType] was found" Error with Spring 3.0.5 and EclipseLink 2.3.2
"No [EntityType] was found" Error with Spring 3.0.5 and EclipseLink 2.3.2 [message #814389] Tue, 06 March 2012 11:43 Go to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 4
Registered: December 2011
Junior Member
I am trying to pick up EclipseLink for use in Tomcat/Jetty hosted GWT web app. The application needs a persistence back end and I've already tried to get OpenJPA working but with no luck.

I've got further with EclipseLink so the spring configuration loads OK but at runtime when I try and query the database I get the following IllegalArgumentException:


No [EntityType] was found for the key class [audit.orm.ServerDetail] in the Metamodel - please verify that the [Entity] class was referenced in persistence.xml using a specific <class>audit.orm.ServerDetail</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
	at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entityEmbeddableManagedTypeNotFound(MetamodelImpl.java:174)
	at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entity(MetamodelImpl.java:194)
	at org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl.from(AbstractQueryImpl.java:97)


Having debugged this error the problem seems to be classloader related, in the MetamodelImpl at line 192 it tries to get the EntityType out of the map, now my entity class is in the map but with a different ObjectID, so the get fails! I'm guessing that EclipseLink is using it's own classloader during setup which results in it having a different class object loaded.

At dev time I'm using GWT so this is hosted using Jetty.

Any ideas as to what is wrong, it's very frustrating failing at such an early hurdle especially as something has worked because I can see the entities in the map.

Spring and persistence config below:

<?xml version="1.0"?>
<persistence version="1.0">
	<persistence-unit name="audit" transaction-type="RESOURCE_LOCAL">
		<class>audit.orm.ServerDetail</class>
		
		<!-- EclipseLink should create the database schema automatically -->
		<property name="eclipselink.ddl-generation" value="create-tables" />
		<property name="eclipselink.ddl-generation.output-mode"
			value="database" />
		<property name="eclipselink.logging.level" value="FINE"/>
	</persistence-unit>
</persistence>


my spring config is:

    <!-- Database/ORM configuration -->
    <bean id="datasource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
        <property name="driverClass" value="$CONTAINER{audit.db.driver}" />
        <property name="jdbcUrl" value="$CONTAINER{audit.db.url}" />
        <property name="username" value="$CONTAINER{audit.db.username}"/>
        <property name="password" value="$CONTAINER{audit.db.password}"/>
        <property name="idleConnectionTestPeriod" value="60"/>
        <property name="idleMaxAge" value="240"/>
        <property name="maxConnectionsPerPartition" value="10"/>
        <property name="minConnectionsPerPartition" value="4"/>
        <property name="partitionCount" value="1"/>
        <property name="acquireIncrement" value="2"/>
        <property name="statementsCacheSize" value="100"/>
        <property name="releaseHelperThreads" value="0"/>
    </bean>
    
    <bean
     class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
    
	<bean id="auditDatabaseSessionFactory"
		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="audit" />
        <property name="persistenceUnitManager" ref="persistenceUnitManager" />
		<property name="jpaDialect" ref="jpaDialect"></property>
		<property name="jpaVendorAdapter">
            <bean
                class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
            </bean>
        </property>
	</bean>
	
	<bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
        <property name="defaultDataSource" ref="datasource" />
        <property name="dataSources">
            <map>
                <entry>
                    <key>
                        <value>jdbc/__default</value>
                    </key>
                    <ref bean="datasource" />
                </entry>
                <entry>
                    <key>
                        <value>jdbc/jta</value>
                    </key>
                    <ref bean="datasource" />
                </entry>
            </map>
        </property>
        <property name="loadTimeWeaver">
            <bean class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver" />
        </property>
    </bean>
	
	<bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />

    <bean id="transactionManager"
        class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="auditDatabaseSessionFactory"/>
    </bean>
  
    <bean id="auditDatabaseSession" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
        <property name="entityManagerFactory" ref="auditDatabaseSessionFactory"/>
    </bean>
Re: "No [EntityType] was found" Error with Spring 3.0.5 and EclipseLink 2.3.2 [message #825172 is a reply to message #814389] Tue, 20 March 2012 15:10 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Do you just get errors with the type-safe Criteria API? Try JPQL and using Criteria with just strings instead of the meta-model.
If this works, then it seems to be an issue related to the meta-model, you might try logging a bug.

If these don't work either, then you have classpath issues. You might try to isolate your different frameworks, to see which is causing the issue, or try some of the basic Spring examples. Also ensure that you close your EntityManagerFactorys if you are redeploying. EclipseLink also has a persistence unit property for passing the class loader to the persistence unit, that may be useful.


James : Wiki : Book : Blog : Twitter
Previous Topic:@Version and DescriptorException
Next Topic:Query work in 2.0.1 but don't in 2.3.2
Goto Forum:
  


Current Time: Wed Dec 17 21:32:16 GMT 2014

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

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