Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » No [ManagedType] type... SpringData app trying to move from Hibernate(On deploy, I get error No [ManagedType]. I dont have a persistance.xml)
No [ManagedType] type... SpringData app trying to move from Hibernate [message #1739567] Wed, 03 August 2016 03:01 Go to next message
Phil Scadden is currently offline Phil ScaddenFriend
Messages: 12
Registered: July 2010
Junior Member
This is a Spring Data application that I am trying to move from Hibernate to EclipseLink. What I have found with google isnt helpful (esp solved by moving to Hibernate).

Error is:
Caused by: java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [my.domain.boreservice.domain.BoreHole] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>my.domain.boreservice.domain.BoreHole</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.

No persistance.xml so exclude-unlisted-classes should default to false.
@Configuration
@EnableTransactionManagement
@EnableLoadTimeWeaving
@EnableJpaRepositories(basePackages="my.domain.boreservice.repository", queryLookupStrategy=QueryLookupStrategy.Key.CREATE_IF_NOT_FOUND)
public class DataConfig extends JpaBaseConfiguration {
    
    
    /*
    * Data Source Config
    */  
    @Bean
    public DataSource dataSource() {
        final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
        dsLookup.setResourceRef(true);
        DataSource dataSource = dsLookup.getDataSource("jdbc/myconnection");
        return dataSource;
    } 
    
    /*
    * Jpa Config
    */
    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource());
        emfb.setPersistenceUnitName("BoreServiceJPA");
        emfb.setPackagesToScan("my.domain.boreservice.domain");
        return emfb;
    }
    
    @Bean
    public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
        JpaTransactionManager txnMgr = new JpaTransactionManager();
        txnMgr.setEntityManagerFactory(emf);
        return txnMgr;
    }
    
     @Override
    protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
        EclipseLinkJpaVendorAdapter eclipseLinkJpaVendorAdapter  = new EclipseLinkJpaVendorAdapter();
        eclipseLinkJpaVendorAdapter.setShowSql(true);
        eclipseLinkJpaVendorAdapter.setGenerateDdl(false);        
        return eclipseLinkJpaVendorAdapter;
    }
 
    @Override
    protected Map<String, Object> getVendorProperties() {
        final Map<String, Object> ret = new HashMap<>();
        ret.put(PersistenceUnitProperties.BATCH_WRITING, BatchWriting.JDBC);
        ret.put(PersistenceUnitProperties.WEAVING, detectWeavingMode());
        return ret;
    }
    
       private String detectWeavingMode() {
        return InstrumentationLoadTimeWeaver.isInstrumentationAvailable() ? "true" : "static";
}

}

All the database entities are there under domain. Works in hibernate but with a lot of hibernate hassle (lazyloading). EclipseLink 2.6.2, Spring 4.2.5
Any ideas please?
Re: No [ManagedType] type... SpringData app trying to move from Hibernate [message #1739642 is a reply to message #1739567] Wed, 03 August 2016 13:27 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Looks like an issue with your packaging and classloaders, such that the one or more classes isn't being picked up - depending on when/where the error is occurring, it could be during weaving or at runtime so it would help to show the full stack trace. Does adding it to the persistence.xml as the error suggests work, or have you tried static weaving?
Re: No [ManagedType] type... SpringData app trying to move from Hibernate [message #1739692 is a reply to message #1739642] Wed, 03 August 2016 21:36 Go to previous messageGo to next message
Phil Scadden is currently offline Phil ScaddenFriend
Messages: 12
Registered: July 2010
Junior Member
Thanks for your reply. Full stack trace below. Since I havent put instrumentation on JVM of test server, Weaving is static (I used debugger to double-check that). Since I am using the spring data, I dont have persistance.xml. exclude-unlisted-classes should default to false.

Borehole is the key entity. All other entities relate to it/descend from it.

The code has had some history. Originally quite a simple JPA-Eclipselink, it was moved to Spring data/Hibernate when converted to a REST service to bring in line with local IT standards for services. Hibernate is pain and is giving significant performance issues, so now trying to move back to Eclipselink, but within Spring.
Aug 03, 2016 2:49:06 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Aug 03, 2016 2:49:14 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'boreServiceRestController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: nz.cri.gns.boreservice.service.BoreHoleService nz.cri.gns.boreservice.controller.BoreServiceRestController.boreHoleService; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'boreHoleService' defined in file [C:\BoreService\target\boreservice-1.0\WEB-INF\classes\nz\cri\gns\boreservice\service\BoreHoleService.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [nz.cri.gns.boreservice.repository.BoreHoleRepository]: Error creating bean with name 'boreHoleRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [nz.cri.gns.boreservice.domain.BoreHole] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>nz.cri.gns.boreservice.domain.BoreHole</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'boreHoleRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [nz.cri.gns.boreservice.domain.BoreHole] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>nz.cri.gns.boreservice.domain.BoreHole</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5014)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5528)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:677)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:552)
	at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1717)
	at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1516)
	at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:912)
	at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:371)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: nz.cri.gns.boreservice.service.BoreHoleService nz.cri.gns.boreservice.controller.BoreServiceRestController.boreHoleService; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'boreHoleService' defined in file [C:\BoreService\target\boreservice-1.0\WEB-INF\classes\nz\cri\gns\boreservice\service\BoreHoleService.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [nz.cri.gns.boreservice.repository.BoreHoleRepository]: Error creating bean with name 'boreHoleRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [nz.cri.gns.boreservice.domain.BoreHole] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>nz.cri.gns.boreservice.domain.BoreHole</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'boreHoleRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [nz.cri.gns.boreservice.domain.BoreHole] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>nz.cri.gns.boreservice.domain.BoreHole</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
	... 57 more
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'boreHoleService' defined in file [C:\BoreService\target\boreservice-1.0\WEB-INF\classes\nz\cri\gns\boreservice\service\BoreHoleService.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [nz.cri.gns.boreservice.repository.BoreHoleRepository]: Error creating bean with name 'boreHoleRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [nz.cri.gns.boreservice.domain.BoreHole] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>nz.cri.gns.boreservice.domain.BoreHole</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'boreHoleRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [nz.cri.gns.boreservice.domain.BoreHole] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>nz.cri.gns.boreservice.domain.BoreHole</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
	... 59 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'boreHoleRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [nz.cri.gns.boreservice.domain.BoreHole] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>nz.cri.gns.boreservice.domain.BoreHole</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
	... 72 more
Caused by: java.lang.IllegalArgumentException: No [ManagedType] was found for the key class [nz.cri.gns.boreservice.domain.BoreHole] in the Metamodel - please verify that the [Managed] class was referenced in persistence.xml using a specific <class>nz.cri.gns.boreservice.domain.BoreHole</class> property or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element.
	at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.entityEmbeddableManagedTypeNotFound(MetamodelImpl.java:177)
	at org.eclipse.persistence.internal.jpa.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:519)
	at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:68)
	at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:67)
	at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:152)
	at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:99)
	at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185)
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251)
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237)
	at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
	... 83 more

Aug 03, 2016 2:49:14 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext



Re: No [ManagedType] type... SpringData app trying to move from Hibernate [message #1740267 is a reply to message #1739692] Thu, 11 August 2016 04:40 Go to previous message
Phil Scadden is currently offline Phil ScaddenFriend
Messages: 12
Registered: July 2010
Junior Member
Key to this one is NOT to extend JpaBaseConfiguration. Ie be careful to avoid Spring Boot packaging when not using Spring Boot. Once I had eradicated that, then it works okay.
Previous Topic:QueuableWeakCacheKey growing endlessly
Next Topic:Moxy reading in a stream of a large JSON file object by object.
Goto Forum:
  


Current Time: Sat Apr 20 01:38:19 GMT 2024

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

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

Back to the top