Demoiselle-Nimble: Error generating CRUD Vaadin

Asked

Viewed 82 times

0

I’m using the class below, Banco.java, below:

@Entity
public class Banco implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id 
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="banco_seq_gen")
    @SequenceGenerator(name = "banco_seq_gen", sequenceName = "banco_id_seq",allocationSize=1)
    private Integer id;

    @Column
    @TextField
    @Field(prompt = "{banco.prompt.numero}", label = "{banco.label.numero}")
    @NotNull(message = "{banco.numero.erro.null}")
    private String numero;

    @Column
    @TextField
    @Field(prompt = "{banco.prompt.descricao}", label = "{banco.label.description}")
    @NotNull(message = "{banco.descricao.erro.null}")
    private String descricao;

    public Banco() {
        super();    
    }

    public Banco(String numero, String descricao) {     
        this.numero = numero;
        this.descricao = descricao;
    }

    // Getters and setter omitidos!
}

And the same is giving the following error:

INFO  FROM: C:\Demoiselle\ide\eclipse-4.4.1\plugins\br.gov.frameworkdemoiselle.tools.nimble.eclipse_1.2.0\templates\generate-crud-vaadin\src\main\resources\messages_en.properties.fragment.groovy
groovy.lang.MissingMethodException: No signature of method: static br.gov.frameworkdemoiselle.tools.nimble.util.ParserUtil.getClassAttributesFromFile() is applicable for argument types: (java.lang.String) values: [C:\Demoiselle\workspace\vaadinfinance/src/main/java/br/com/djsystem/domain/Banco.java]
    at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1370)
    at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1356)
    at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:50)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at SimpleTemplateScript2.run(SimpleTemplateScript2.groovy:5)
    at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:165)
    at groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.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.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:230)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at br.gov.frameworkdemoiselle.tools.nimble.template.GroovyTemplate.applyTemplate(GroovyTemplate.groovy:58)
    at br.gov.frameworkdemoiselle.tools.nimble.template.Template$applyTemplate.call(Unknown Source)
    at br.gov.frameworkdemoiselle.tools.nimble.util.TemplateUtil.applyTemplate(TemplateUtil.groovy:58)
    at br.gov.frameworkdemoiselle.tools.nimble.util.TemplateUtil$applyTemplate.call(Unknown Source)
    at br.gov.frameworkdemoiselle.tools.nimble.DemoiselleNimble$_applyTemplates_closure5.doCall(DemoiselleNimble.groovy:314)
    at sun.reflect.GeneratedMethodAccessor36.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906)
    at groovy.lang.Closure.call(Closure.java:412)
    at groovy.lang.Closure.call(Closure.java:425)
    at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFileRecurse(ResourceGroovyMethods.java:980)
    at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFileRecurse(ResourceGroovyMethods.java:978)
    at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFileRecurse(ResourceGroovyMethods.java:978)
    at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFileRecurse(ResourceGroovyMethods.java:978)
    at org.codehaus.groovy.runtime.ResourceGroovyMethods.eachFileRecurse(ResourceGroovyMethods.java:1212)
    at org.codehaus.groovy.runtime.dgm$763.invoke(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271)
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at br.gov.frameworkdemoiselle.tools.nimble.DemoiselleNimble.applyTemplates(DemoiselleNimble.groovy:293)
    at br.gov.frameworkdemoiselle.tools.nimble.DemoiselleNimble$applyTemplates.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
    at br.gov.frameworkdemoiselle.tools.nimble.gui.wizard.tools.TemplateVariablesStep2.finish(TemplateVariablesStep2.groovy:159)
    at br.gov.frameworkdemoiselle.tools.nimble.gui.wizard.tools.TemplateVariablesStep2$finish.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at br.gov.frameworkdemoiselle.tools.nimble.gui.wizard.GenericWizardFrame$_footer_closure1.doCall(GenericWizardFrame.groovy:103)
    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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906)
    at groovy.lang.Closure.call(Closure.java:412)
    at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:51)
    at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:82)
    at com.sun.proxy.$Proxy6.actionPerformed(Unknown Source)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

Test on version 2 and 3 of the following.

1 answer

1


It really is a "bug" in the Vaadin generation template. But quite simple to solve. This template generates the attributes in the /src/main/Resources/messages_en.properties file that is created with the Demoiselle Maven archetype for a Vaadin application. As the name indicates is a message file to internationalize the application using as an option the English language (_en). Since it is a template, the result is not exactly a quality translation, but only the entries of the properties that should be translated manually. Even the file for Portuguese language generates the entries in a mechanical way based on the attributes names of the class pojo. These properties should also be corrected for better presentation. What is gained in this process is the work of creating the attributes and in the case of JSF templates to link them in the XHTML pages. Even, now I realize, that the template for Portuguese is also having a problem.

one of the goals of Demoiselle-Nimble templates is that they are just a sample of what can be done. Because it is possible and encouraged that the developer himself customize and improve as your needs.

Because it’s a mistake in the template, you don’t have to wait for the correction because, as I said, you can do it yourself in your environment.

Even so, I ask you to register the bug in the tracker of the project: http://tracker.frameworkdemoiselle.gov.br

We can consider correction in two ways:

  • 1) You have no interest in internationalizing the application, so you want to ignore this file: This way just delete the template files:

    C: Demoiselle ide eclipse-4.4.1 plugins br.gov.frameworkdemoiselle.tools.Nimble.eclipse_1. 2.0 templates generate-crud-vaadin src main Resources messages_en.properties.Fragment.groovy

    and

    C: Demoiselle ide eclipse-4.4.1 plugins br.gov.frameworkdemoiselle.tools.Nimble.eclipse_1. 2.0 templates generate-crud-vaadin src main Resources messages_en.properties.Fragment.groovy.conf

  • 2) You want to generate the file to internationalize the application.

To fix change the contents of the file: C: Demoiselle ide eclipse-4.4.1 plugins br.gov.frameworkdemoiselle.tools.Nimble.eclipse_1. 2.0 generate-crud-vaadin templates src main Resources messages_en.properties.Fragment.groovy for:

    menu.new.${bean} = ${pojo}
<%

import br.gov.frameworkdemoiselle.tools.nimble.util.ParserUtil as RU
def tmpFile = new File(beanPath+beanJavaName)
def attrList = RU.getAttributesFromClassFile(tmpFile)
   if (!attrList.isEmpty()) {
        attrList.each() { attrName, attrValue -> 
            String attrLow = attrName.toLowerCase() 
    %>
    ${bean}.label.${attrLow} = ${attrName}
    ${bean}.prompt.${attrLow} = ${pojo}'s ${attrName}
    <%
        }
    } else {
    %>
    ${bean}.label.text = Text
    ${bean}.prompt.text = ${pojo}'s Text 
    <%
}
%>

The problem in the template for Portuguese is that the content is the same as the other. There is even a bug in the archetype that generates the file because it is in "English" as well. Change C: Demoiselle ide eclipse-4.4.1 plugins en.gov.frameworkdemoiselle.tools.Nimble.eclipse_1. 2.0 templates generate-crud-vaadin src main Resources messages.properties.Fragment.groovy for:

    menu.new.${bean} = ${pojo}
<%

import br.gov.frameworkdemoiselle.tools.nimble.util.ParserUtil as RU
def tmpFile = new File(beanPath+beanJavaName)
def attrList = RU.getAttributesFromClassFile(tmpFile)
   if (!attrList.isEmpty()) {
        attrList.each() { attrName, attrValue -> 
            String attrLow = attrName.toLowerCase() 
    %>
    ${bean}.label.${attrLow} = ${attrName}
    ${bean}.prompt.${attrLow} = ${attrName} do ${pojo} 
    <%
        }
    } else {
    %>
    ${bean}.label.text = Texto
    ${bean}.prompt.text = Texto do ${pojo}
    <%
}
%>

With these tips, you can take a look at the other templates and if you want to make your improvements.

  • It worked perfectly, I changed the files as reported!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.