facebook

Hibernate Reverse Engineering : 2 newbie problems/questions

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

    factset
    Participant

    Hello,

    I’m new to MyEclipse, and I struggle a bit with the Hibernate reverse engineering, 2 problems :

    1/ SessionFactoryId not found
    If I check the checkbox “Java Data Access Object(DAO) (Hibernate 3 only)”, the spring config files are found, but there is no SessionFactoryId available although there is one defined in the spring context file.
    So I cannot generate DAO because the sessionFactoryId field is mandatoryand I can’t set any value in it.

    But it is not a big deal because I will probably use a generic DAO, so I don’t really need that feature (that was just by curiosity).

    2/ No Java class generated
    Having unchecked the “DAO checkbox”, I start the reverse engineering, the process runs to its end without error, but I can’t see any generated Java class for mapped entities.
    The mapping files are successfully generated, but that’s it.

    Is there a problem somewhere ?

    Config : MyEclipse 5.5.M2 / Java EE 5 / Hibernate 3.2 / Spring 2
    I’ve started my Eclipse project from scratch : New Web project / Add Hibernate / Add Spring, create tables on DB then reverse engineering.

    Thank youuuuuu
    😉

    #269160 Reply

    Riyad Kalla
    Member

    factset,
    Sounds strange… can you dig into your <workspace dir>\.metadata\.logfile for me, look near the bottom, and find exceptions that may shed some light on what’s going on?

    #269218 Reply

    factset
    Participant

    Mmmm..
    Have juste cleaned the .log file (perhaps I should not have cleaned it ;-( because there was definitely some exceptions, but I wanted a clean log file before starting) and restarted a reverse engineering : no logs have been added.

    I’ll create a brand new project, and try again…
    Thanks
    Philippe

    #269220 Reply

    factset
    Participant

    I’ve progressed ! but it is still not 100% clear for me…

    1/ SessionFactoryId not found
    Still the same problem, don’t understand. But from the beginning I’ve noticed something strange, maybe it’s related ?
    Currently I use 3 spring configuration files ( 1 for persistence layer, 1 for services layer, 1 for presentation layer ), so you see on my web.xml file :

        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                /WEB-INF/applicationContext-data.xml,
                /WEB-INF/applicationContext-services.xml,
                /WEB-INF/applicationContext.xml
            </param-value>
        </context-param>

    In the MyEclipse project properties menus, I’ve added the 3 config files for Spring.
    But it seems that any bean defined in one file is not visible in the other file. That means MyEclipse displays a warning : Referenced bean … not found.

    For instance :
    applicationContext-data.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans
        xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    
    
        <bean id="datasource" class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiName">
                <value>java:comp/env/jdbc/ScudDS</value>
            </property>
        </bean>
    
        <bean id="sessionFactory"
            class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="configLocation">
                <value>classpath:hibernate.cfg.xml</value>
            </property>
        </bean>
    
    </beans>

    applicationContext-services.xml

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             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/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
               http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
    
        <!-- ***************************************************************** -->
        <!-- **                     Transaction Manager                     ** -->
        <!-- ***************************************************************** -->
        <!-- enable the configuration of transactional behavior based on annotations -->
        <tx:annotation-driven transaction-manager="transactionManager"/>
    
        <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
        <bean id="transactionManager"
            class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">   <!-- [color=red]A warning is displayed on that line : Referenced bean 'sessionFactory' not found [/color] -->
            <ref bean="sessionFactory" />
        </property>
        </bean>
        
        <!-- No services yet -->
        
    </beans>

    I’ve noticed as well that on project Properties / Hibernate : Spring LocalSession Factory Bean Id is always disabled, I can never set any value in here, but I don’t know if I have to…

    Could it be related to the fact I can not select a sessionFactoryId for a Hibernate reverse engineering ?

    2/ No Java class generated
    My apologies, my fault 😳 , In the reverse engineering window, I was not checking the “Java Data Object” checkbox because I had not realized that was for the Java entities classes…hum !
    Now Java classes are generated !

    When it comes to MyEclipse logs, I see a very recurent exception, although I can’t figure out WHEN it is thrown :

    !ENTRY org.eclipse.xsd 2 0 2007-04-23 10:50:43.155
    !MESSAGE White spaces are required between publicId and systemId.
    !STACK 0
    org.eclipse.emf.ecore.resource.Resource$IOWrappedException: White spaces are required between publicId and systemId.
    at org.eclipse.xsd.util.XSDResourceImpl.getDocument(XSDResourceImpl.java:344)
    at org.eclipse.xsd.util.XSDResourceImpl.getDocument(XSDResourceImpl.java:372)
    at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl.java:680)
    at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl.java:784)
    at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
    at org.eclipse.wst.xsd.contentmodel.internal.util.XSDSchemaLocatorImpl.locateSchema(XSDSchemaLocatorImpl.java:56)
    at org.eclipse.xsd.impl.XSDSchemaDirectiveImpl.locateSchema(XSDSchemaDirectiveImpl.java:400)
    at org.eclipse.xsd.impl.XSDSchemaDirectiveImpl.resolve(XSDSchemaDirectiveImpl.java:340)
    at org.eclipse.xsd.impl.XSDImportImpl.importSchema(XSDImportImpl.java:411)
    at org.eclipse.xsd.impl.XSDSchemaImpl.resolveSchema(XSDSchemaImpl.java:2136)
    at org.eclipse.xsd.impl.XSDSchemaImpl.resolveNamedComponent(XSDSchemaImpl.java:2164)
    at org.eclipse.xsd.impl.XSDSchemaImpl.resolveTypeDefinition(XSDSchemaImpl.java:2223)
    at org.eclipse.xsd.impl.XSDConcreteComponentImpl.resolveTypeDefinition(XSDConcreteComponentImpl.java:2328)
    at org.eclipse.xsd.impl.XSDComplexTypeDefinitionImpl.patch(XSDComplexTypeDefinitionImpl.java:997)
    at org.eclipse.xsd.impl.XSDConcreteComponentImpl.patch(XSDConcreteComponentImpl.java:526)
    at org.eclipse.xsd.impl.XSDNamedComponentImpl.patch(XSDNamedComponentImpl.java:768)
    at org.eclipse.xsd.impl.XSDElementDeclarationImpl.patch(XSDElementDeclarationImpl.java:545)
    at org.eclipse.xsd.impl.XSDConcreteComponentImpl.patch(XSDConcreteComponentImpl.java:526)
    at org.eclipse.xsd.impl.XSDSchemaImpl.patch(XSDSchemaImpl.java:1505)
    at org.eclipse.xsd.impl.XSDSchemaImpl.changeAttribute(XSDSchemaImpl.java:2335)
    at org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDConcreteComponentImpl.java:1240)
    at org.eclipse.xsd.impl.XSDSchemaImpl.setSchemaLocation(XSDSchemaImpl.java:829)
    at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl.java:756)
    at org.eclipse.xsd.util.XSDResourceImpl.doLoad(XSDResourceImpl.java:784)
    at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1094)
    at org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.buildXSDModel(XSDImpl.java:210)
    at org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.buildCMDocument(XSDImpl.java:169)
    at org.eclipse.wst.xsd.contentmodel.internal.CMDocumentFactoryXSD.createCMDocument(CMDocumentFactoryXSD.java:37)
    at org.eclipse.wst.xml.core.internal.contentmodel.ContentModelManager.createCMDocument(ContentModelManager.java:56)
    at org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentManagerImpl.buildCMDocument(CMDocumentManagerImpl.java:259)
    at org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentManagerImpl$1.run(CMDocumentManagerImpl.java:229)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
    Caused by: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId.
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at org.eclipse.xsd.util.XSDResourceImpl.getDocument(XSDResourceImpl.java:335)
    … 31 more

    and that other one (but it occured only 1 time this morning) :

    !ENTRY org.eclipse.ui 4 4 2007-04-23 11:36:31.613
    !MESSAGE Unhandled event loop exception

    !ENTRY org.eclipse.ui 4 0 2007-04-23 11:36:31.613
    !MESSAGE Failed to execute runnable (java.lang.NullPointerException)
    !STACK 0
    org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
    at org.eclipse.swt.SWT.error(SWT.java:3374)
    at org.eclipse.swt.SWT.error(SWT.java:3297)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:126)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3325)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
    at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
    at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
    at org.eclipse.core.launcher.Main.run(Main.java:977)
    at org.eclipse.core.launcher.Main.main(Main.java:952)
    Caused by: java.lang.NullPointerException
    at com.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob$6.getCompilationUnits(GenerateArtifactsJob.java:694)
    at com.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob$6.run(GenerateArtifactsJob.java:680)
    at com.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob$7.run(GenerateArtifactsJob.java:712)
    at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:155)
    at org.eclipse.ui.internal.UISynchronizer$1.run(UISynchronizer.java:36)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
    … 20 more

    Sorry for the length of that post, I know how boring it can be to read it…

    Have a nice day !
    Thanks
    Philippe

    #269232 Reply

    Riyad Kalla
    Member

    Philippe,
    Is this project something you can share with me? I want to dig into it and see what is going on…

    #269239 Reply

    factset
    Participant

    Usually I would say “no I can’t” (because of some confidential information).
    But we are lucky because I’m just starting, so there is not yet any feature or secret, and I work currently on a technical subject : not business related.

    Send me your email by PM, and I’ll zip the project for you.

    Thanks
    Philippe

    #269241 Reply

    Riyad Kalla
    Member

    Philippe,
    Please email the project to support@genuitec.com ATTN Riyad, with a link to this thread for reference. Thank you.

    #269242 Reply

    factset
    Participant

    Sent !

    If you need some explanations, do not hesitate to ask.

    Thanks
    Philippe

    #269256 Reply

    Riyad Kalla
    Member

    Philippe,
    Thank you for the project and excellent detail. First things first, I’m looking into why the spring beans aren’t resolving then we will go from there.

    #269278 Reply

    factset
    Participant

    Ok, thanks a lot.

    #269293 Reply

    Riyad Kalla
    Member

    Ahh ok it turns out to get the configs to see eachother, you have to add them all to a set:

    Attachments:
    You must be logged in to view attached files.
    #269297 Reply

    factset
    Participant

    Great !
    Now the beans are found, even if they are defined in another spring config file, and the Hibernate Reverse engineering now finds the sessionFactoryId !

    Thanks very much for your time !

    #269310 Reply

    Riyad Kalla
    Member

    Very cool, glad it’s working now.

Viewing 13 posts - 1 through 13 (of 13 total)
Reply To: Hibernate Reverse Engineering : 2 newbie problems/questions

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