facebook

Forward engineering POJOs to database. (JPA/Hibernate)

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #311451 Reply

    Bojan Kaurin
    Member

    Hello everyone. I’m new here, and i’m trying out myeclipse IDE, so i have few questions.
    1. Is it possible to do forward enigneering(from POJOs with JPA annotations to database or from hibernate mapping files to database) in myeclipse and how(not manually, something like in second question)?
    2. I saw in dali project on eclipse option “generate tables from entities”(based on JPA annotations), is there anything like this in myeclipse?
    3. In myeclipse there is option to generate JPA annotations on POJOs, is there any option to auto generate hibernate *.hbm.xml mapping files from POJOs?
    4. If there isn’t option for forward engineering, can anyone explain to me why is that case in almost every IDE out there, is it really right way to create database first, and then generate model based on underlying database. As far as i know, the right way to develop some project is first design object model, then everything else, not vice versa.

    #311501 Reply

    bojankaurin,
    Sorry for the delayed response. In order to create database tables from java classes, you need to check “Enable dynamic DB Creation” when adding JPA capabilities. Please refer to the following link –
    http://www.myeclipseide.com/documentation/quickstarts/jpa_overview/
    Once this option is enabled, if you try to save a new object, the corresponding table will be created in the database accordingly.
    Let me know if that helps.

    #311511 Reply

    Bojan Kaurin
    Member

    Well, i’ve tried this, i don’t know how many times anymore, and i didn’t get it to work.

    refer to the following link –
    http://www.myeclipseide.com/documentation/quickstarts/jpa_overview/

    I saw this link, and read few times, and nothing :-(. This is so frustrating, all week along i’ve trying to get this to work, sorry for boring you on support mail, but i just couldn’t wait anymore(i hope you understand, and i hope i did not be too rude with all mails and posts :-().

    Now, let me show you what exactly happens when i try to do this.

    First i create simple java project, add one package, and only one class with integer identifier id, and getter and setter for id(it can’t be simpler than this :-)).
    Then, i add jpa capabilities to project, and generate jpa annotations on class.
    But when i’m adding jpa annotations there is exception thrown(I’m adding JPA annotations with MyEclipse/Add JPA Annotations).
    This is log entry for this exception

    
    
    !ENTRY org.eclipse.ltk.ui.refactoring 4 10000 2010-09-24 11:03:15.891
    !MESSAGE Internal Error
    !STACK 0
    org.eclipse.swt.SWTException: Invalid thread access
        at org.eclipse.swt.SWT.error(SWT.java:3884)
        at org.eclipse.swt.SWT.error(SWT.java:3799)
        at org.eclipse.swt.SWT.error(SWT.java:3770)
        at org.eclipse.swt.widgets.Widget.error(Widget.java:463)
        at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:355)
        at org.eclipse.swt.custom.StyledText.getBlockSelection(StyledText.java:3484)
        at org.eclipse.jface.text.TextViewer.getSelection(TextViewer.java:2523)
        at org.eclipse.jface.text.TextViewer$ViewerState.connect(TextViewer.java:1283)
        at org.eclipse.jface.text.TextViewer$ViewerState.<init>(TextViewer.java:1172)
        at org.eclipse.jface.text.TextViewer.disableRedrawing(TextViewer.java:5071)
        at org.eclipse.jface.text.TextViewer.setRedraw(TextViewer.java:5109)
        at org.eclipse.jface.text.TextViewer.setRedraw(TextViewer.java:5089)
        at org.eclipse.jface.text.TextViewer$RewriteTarget.setRedraw(TextViewer.java:1065)
        at org.eclipse.jface.text.TextViewer$DocumentRewriteSessionListener.documentRewriteSessionChanged(TextViewer.java:1465)
        at org.eclipse.jface.text.AbstractDocument.fireRewriteSessionChanged(AbstractDocument.java:1524)
        at org.eclipse.jface.text.AbstractDocument.startRewriteSession(AbstractDocument.java:1550)
        at org.eclipse.core.internal.filebuffers.SynchronizableDocument.startRewriteSession(SynchronizableDocument.java:98)
        at org.eclipse.ltk.core.refactoring.TextChange.performEdits(TextChange.java:271)
        at org.eclipse.ltk.core.refactoring.TextChange.perform(TextChange.java:238)
        at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
        at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
        at org.eclipse.ltk.core.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:260)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
        at org.eclipse.ltk.core.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:308)
        at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation.executeChange(UIPerformChangeOperation.java:92)
        at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:220)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
        at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
        at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
    
    !ENTRY org.eclipse.ltk.ui.refactoring 4 4 2010-09-24 11:03:15.892
    !MESSAGE Invalid thread access
    !STACK 0
    org.eclipse.swt.SWTException: Invalid thread access
        at org.eclipse.swt.SWT.error(SWT.java:3884)
        at org.eclipse.swt.SWT.error(SWT.java:3799)
        at org.eclipse.swt.SWT.error(SWT.java:3770)
        at org.eclipse.swt.widgets.Widget.error(Widget.java:463)
        at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:355)
        at org.eclipse.swt.custom.StyledText.getBlockSelection(StyledText.java:3484)
        at org.eclipse.jface.text.TextViewer.getSelection(TextViewer.java:2523)
        at org.eclipse.jface.text.TextViewer$ViewerState.connect(TextViewer.java:1283)
        at org.eclipse.jface.text.TextViewer$ViewerState.<init>(TextViewer.java:1172)
        at org.eclipse.jface.text.TextViewer.disableRedrawing(TextViewer.java:5071)
        at org.eclipse.jface.text.TextViewer.setRedraw(TextViewer.java:5109)
        at org.eclipse.jface.text.TextViewer.setRedraw(TextViewer.java:5089)
        at org.eclipse.jface.text.TextViewer$RewriteTarget.setRedraw(TextViewer.java:1065)
        at org.eclipse.jface.text.TextViewer$DocumentRewriteSessionListener.documentRewriteSessionChanged(TextViewer.java:1465)
        at org.eclipse.jface.text.AbstractDocument.fireRewriteSessionChanged(AbstractDocument.java:1524)
        at org.eclipse.jface.text.AbstractDocument.startRewriteSession(AbstractDocument.java:1550)
        at org.eclipse.core.internal.filebuffers.SynchronizableDocument.startRewriteSession(SynchronizableDocument.java:98)
        at org.eclipse.ltk.core.refactoring.TextChange.performEdits(TextChange.java:271)
        at org.eclipse.ltk.core.refactoring.TextChange.perform(TextChange.java:238)
        at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
        at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
        at org.eclipse.ltk.core.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:260)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
        at org.eclipse.ltk.core.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:308)
        at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation.executeChange(UIPerformChangeOperation.java:92)
        at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:220)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
        at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
        at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
    
    

    and here is the screenshot of exception when i try to generate jpa annotations

    and whatever i click it generates jpa.

    After that i add my class to persistance.xml with option MyEclipse/Synchronize JPA Entity Classes.

    And nothing happens in database, no mather what i do, create new class, make some changes on this one and save it again, nothing happens in database.
    Note that i’ve set database connection and schema when adding jpa capabilities to project.

    And here is my persistance.xml

    
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence     http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
        
        <persistence-unit name="JavaProjectPU" transaction-type="RESOURCE_LOCAL">
            <provider>oracle.toplink.essentials.PersistenceProvider</provider>
            <class>testPackage.TestClass</class>
              <properties>
                <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
                <property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/baza5"/>
                <property name="toplink.jdbc.user" value="root"/>
                <property name="toplink.jdbc.password" value="myPassword"/>
                <property name="toplink.ddl-generation" value="create-tables"/>
              </properties>
        </persistence-unit>
      
    </persistence>
    

    and here is this simple class with annotations generated(with throwed exception explained above)

    
    package testPackage;
    
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.Id;
    
    @Entity
    public class TestClass {
        @Id
        @GeneratedValue
        private int id;
        
        public int getId() {
            return id;
        }
    
        public void setId(int id) {
            this.id = id;
        }
    }
    

    Only there is error at class on @Entity line.
    It says: The table TestClass cannot be found on the database.
    But this is because i enabled database metadata analysis in project properties/MyEclipse/Java persistance.

    I’m using MyEclipse 8.6, and MySql 5.1 on Windows 7 Ultimate x64.

    #311530 Reply

    Bojan Kaurin
    Member

    I just want to let you know i succeeded, i’m talking about generating tables in database, your post was very helpful. .

    Once this option is enabled, if you try to save a new object, the corresponding table will be created in the database accordingly.

    Especially this part. I’ve been doing all other things few times, but i’ve never tried to save entity to database, i don’t know what i expected to happen, maybe something like in eclipse, where is option to generate tables, and that misled me all way along.

    But there is still this exception when i’m trying to generate annotations, just like i described in the above post.

    #311577 Reply

    bojankaurin,
    I could replicate this at my end and I have raised a PR with the dev team.
    They will get back to you on this.

    #311588 Reply

    Bojan Kaurin
    Member

    Thanks!

    #315193 Reply

    nuspy
    Member

    I noticed the same problem, doing the same things. (refer to https://www.genuitec.com/forums/topic/scaffolding-from-pojo-domain-class-not-working/#post-315191)
    And in the Tomcat .log file I can find this error: it seems MyEclipse can’t find the database connection ‘Nuovo_MySQL’ I previously created.

    14-mar-2011 9.42.30 org.apache.catalina.core.StandardContext listenerStart
    GRAVE: 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 ‘MotoDAO’: Injection of persistence fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘Nuovo_MySQL’ defined in class path resource [Scaff_4-generated-dao-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name ‘Nuovo_MySQL’ found
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessAfterInstantiation(PersistenceAnnotationBeanPostProcessor.java:311)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘Nuovo_MySQL’ defined in class path resource [Scaff_4-generated-dao-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name ‘Nuovo_MySQL’ found
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.orm.jpa.EntityManagerFactoryUtils.findEntityManagerFactory(EntityManagerFactoryUtils.java:99)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findNamedEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:488)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:470)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:599)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:570)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:180)
    at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessAfterInstantiation(PersistenceAnnotationBeanPostProcessor.java:308)
    … 40 more
    Caused by: java.lang.IllegalArgumentException: No persistence unit with name ‘Nuovo_MySQL’ found
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.obtainPersistenceUnitInfo(DefaultPersistenceUnitManager.java:379)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.determinePersistenceUnitInfo(LocalContainerEntityManagerFactoryBean.java:244)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:196)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
    … 57 more

    #315194 Reply

    nuspy
    Member

    I noticed the same problem, doing the same things. (refer to https://www.genuitec.com/forums/topic/scaffolding-from-pojo-domain-class-not-working/#post-315191)
    And in the Tomcat .log file I can find this error: it seems MyEclipse can’t find the database connection ‘Nuovo_MySQL’ I previously created.

    14-mar-2011 9.42.30 org.apache.catalina.core.StandardContext listenerStart
    GRAVE: 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 ‘MotoDAO’: Injection of persistence fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘Nuovo_MySQL’ defined in class path resource [Scaff_4-generated-dao-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name ‘Nuovo_MySQL’ found
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessAfterInstantiation(PersistenceAnnotationBeanPostProcessor.java:311)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4334)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘Nuovo_MySQL’ defined in class path resource [Scaff_4-generated-dao-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name ‘Nuovo_MySQL’ found
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.orm.jpa.EntityManagerFactoryUtils.findEntityManagerFactory(EntityManagerFactoryUtils.java:99)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findNamedEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:488)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:470)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:599)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:570)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:180)
    at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessAfterInstantiation(PersistenceAnnotationBeanPostProcessor.java:308)
    … 40 more
    Caused by: java.lang.IllegalArgumentException: No persistence unit with name ‘Nuovo_MySQL’ found
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.obtainPersistenceUnitInfo(DefaultPersistenceUnitManager.java:379)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.determinePersistenceUnitInfo(LocalContainerEntityManagerFactoryBean.java:244)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:196)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
    … 57 more

    #315195 Reply

    nuspy
    Member

    the screenshot of exception when i try to generate jpa annotations (org.eclipse.swt.SWTException: Invalid thread access ) seems to occour when the POJO class ftom which generate JPA annotations is still opened in Eclipse.
    Doesn’t seem to be relevant, anyhow: even in case the class is closed (and so the error windows doesn’t pop up) the following errors are throwed and the database is not created.

    #315223 Reply

    support-swapna
    Moderator

    nuspy,

    This issue is pertaining to MyEclipse for Spring.Please follow it up here :
    https://www.genuitec.com/forums/topic/scaffolding-from-pojo-domain-class-not-working/#post-315191

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: Forward engineering POJOs to database. (JPA/Hibernate)

You must be logged in to post in the forum log in