9 Replies Latest reply on Oct 25, 2008 8:28 AM by elenctic87

    Seam2.1CR entities generation problem

    kinson516
      I use jbosstools 3.0.0alpha+seam2.1CR. when I generate seam entities(reverse engineer from database), errors occurred. How to resolve it. Here is the error message and log.
      thanks.


      `
      Can't generate seam entities
        org.hibernate.tool.hbm2x.ExporterException: Error while processing Entity: com.bb.zp.entity.Vender with template view/list.xhtml.ftl
        Error while processing Entity: com.bb.zp.entity.Vender with template view/list.xhtml.ftl
          org.hibernate.tool.hbm2x.ExporterException: Error while processing Entity: com.bb.zp.entity.Vender with template view/list.xhtml.ftl
          Error while processing Entity: com.bb.zp.entity.Vender with template view/list.xhtml.ftl
          freemarker.core.InvalidReferenceException: Expression util.isToOne is undefined on line 27, column 38 in view/list.xhtml.ftl.
          Expression util.isToOne is undefined on line 27, column 38 in view/list.xhtml.ftl.

      in the console:

      2008-10-08 11:43:22,314 ERROR main freemarker.runtime -

      Expression util.isToOne is undefined on line 27, column 38 in view/list.xhtml.ftl.
      The problematic instruction:
      ----------
      ==> if !c2h.isCollection(property) && !util.isToOne(property) && property != pojo.versionProperty! [on line 27, column 1 in view/list.xhtml.ftl]
      ----------

      Java backtrace for programmers:
      ----------
      freemarker.core.InvalidReferenceException: Expression util.isToOne is undefined on line 27, column 38 in view/list.xhtml.ftl.
              at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
              at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134)
              at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:114)
              at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
              at freemarker.core.Expression.isTrue(Expression.java:138)
              at freemarker.core.NotExpression.isTrue(NotExpression.java:66)
              at freemarker.core.AndExpression.isTrue(AndExpression.java:68)
              at freemarker.core.AndExpression.isTrue(AndExpression.java:68)
              at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:77)
              at freemarker.core.Environment.visit(Environment.java:196)
              at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160)
              at freemarker.core.Environment.visit(Environment.java:351)
              at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95)
              at freemarker.core.Environment.visit(Environment.java:196)
              at freemarker.core.MixedContent.accept(MixedContent.java:92)
              at freemarker.core.Environment.visit(Environment.java:196)
              at freemarker.core.Environment.process(Environment.java:176)
              at freemarker.template.Template.process(Template.java:232)
              at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:255)
              at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplateProducer.java:67)
              at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:28)
              at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:103)
              at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:148)
              at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:137)
              at org.hibernate.tool.hbm2x.GenericExporter$2.process(GenericExporter.java:43)
              at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:128)
              at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
              at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate$1.execute(CodeGenerationLaunchDelegate.java:248)
              at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:64)
              at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:89)
              at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.runExporters(CodeGenerationLaunchDelegate.java:223)
              at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:136)
              at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:764)
              at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:614)
              at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:607)
              at org.jboss.tools.seam.ui.wizard.SeamGenerateEnitiesWizard$1.execute(SeamGenerateEnitiesWizard.java:306)
              at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:511)
              at org.jboss.tools.seam.ui.wizard.SeamBaseWizard$1.execute(SeamBaseWizard.java:77)
              at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:104)
              at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
              at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:116)
              at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:458)
              at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:366)
              at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:934)
              at org.jboss.tools.seam.ui.wizard.SeamBaseWizard.performFinish(SeamBaseWizard.java:66)
              at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:742)
              at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:373)
              at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
              at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
              at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
              at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
              at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
              at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
              at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
              at org.eclipse.jface.window.Window.open(Window.java:801)
              at org.eclipse.ui.internal.actions.NewWizardShortcutAction.run(NewWizardShortcutAction.java:135)
              at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
              at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:583)
              at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:500)
              at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
              at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
              at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
              at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
              at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
              at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
              at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
              at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
              at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
              at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
              at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
              at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
              at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
              at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
              at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
              at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
              at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386)
              at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
              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.equinox.launcher.Main.invokeFramework(Main.java:549)
              at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
              at org.eclipse.equinox.launcher.Main.run(Main.java:1236)

      `


        • 1. Re: Seam2.1CR entities generation problem
          sanghakanwar

          we also faced the same issue. I have put it in the jboss-tools forum.


          My Link


          As a workaround, use the cmd line seam generate-entities .

          • 2. Re: Seam2.1CR entities generation problem
            tcmartin24

            I too have encountered the same problem.  Backing out into the command-line version of seam-gen may not be an option due to the fact that I tried to initiate the project using JBoss Seam Tools plugin for Eclipse, which created a standard Eclipse Web Tools Project and whose directory structure is different from a command-line seam-gen generated project and doesn't include the ant build scripts.


            I thought I'd add though, that this problem doesn't seem to exist with jboss-seam-2.1.0.BETA.  I'm seeing it just with CR1.  I tried downloading the newest daily build of CR1 and that didn't work either.


            Incidentally, I've customized my CR1 seam directory with custom company templates and tried moving those customizations back into BETA1.  But, when I use the eclipse seam project wizard to create a new project, I don't get my customizations (yes, I've made sure I'm pointing at the BETA1 seam directory and that's it's registered in the eclipse - seam - preferences (not the exact path)).  It's as if the eclipse seam plugin doesn't know how to use the seam directory's templates if the version of seam is previous to CR1???  If I switch back over to my customized CR1 seam directory and use the eclipse seam plugin to create a new project, I get my customizations.  Weird.

            • 3. Re: Seam2.1CR entities generation problem
              dan.j.allen

              I'm really trying to figure out what is going wrong here, but I am having extreme difficulty understanding why all of a sudden JBossTools cannot locate the correct version of the org.jboss.seam.tool.Util class. Plenty of the templates are using the methods lower() and upper() from the same class, but they get tripped up on the new isToOne() method. This is obviously something we will have resolved for the GA, but for the time being you are going to need to run it from the commandline if you are trying to use CR1.

              • 4. Re: Seam2.1CR entities generation problem
                tcmartin24

                See my post here for a temporary fix that will allow to get around this problem without resorting to the command line.


                Dan, per my suggestion for temporary fix above, I wonder if the seam plugin must be binding an older Util class into the freemarker template context, which is why my temporary fix is able to work.

                • 5. Re: Seam2.1CR entities generation problem
                  dan.j.allen

                  Yep, your fix is simply a rollback to the previous configuration (which is certainly viable). What you lose, and the reason I added util.isToOne(), is so that one-to-one relationships are displayed in the UI.


                  This is definitely the case that JBossTools is using an older version of the Util class (somehow, somewhere). The problem is, I grep-ed the crap out of all the source code on my harddrive (the plugin and the source code for the plugin) and I cannot figure out where it is loading the Util class. I am waiting on Max to get back to me on that.


                  I know for a fact that FreeMarker does know about the util object because there are other methods that it uses from that class. It just doesn't see this new method.


                  As a final note, we are going to move this method into the c2h object because that is where it should really be. I just had to create this method in the interim until Hibernate Tools is updated.

                  • 6. Re: Seam2.1CR entities generation problem
                    dan.j.allen

                    This problem is now solved in the trunk (and hence Seam 2.1.0.GA). I fixed it by making isToOne a FreeMarker function rather than using a method on the Util class. This is a better approach anyway since it keeps all the logic within the FreeMarker templates where it is more portable (as you can now appreciate having seen this problem).

                    • 7. Re: Seam2.1CR entities generation problem
                      tcmartin24

                      Awesome!

                      • 8. Re: Seam2.1CR entities generation problem
                        elenctic87

                        I am still seeing this problem with 2.1.0 GA and with JBT 3.0.0 alpha1.  What version of JBT should I be running in order for 2.1 GA to work smoothly in Eclipse?  I tried the 10-23 nightly build of JBT and could not even get a new seam project to work, but that is an aside as my question is more about how to resolve the generate entities problem in 2.1CR.  Thank you.  Nice book, btw.

                        • 9. Re: Seam2.1CR entities generation problem
                          elenctic87

                          nm. Found the solution (the patch from Jira).