History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: APF-895
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Matt Raible
Reporter: Mike Kelland
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
AppFuse

AMP Template Execution Exception on Composite Primary Keys

Created: 18/Sep/07 09:37 PM   Updated: 18/Sep/07 11:30 PM
Component/s: Tools - AMP
Affects Version/s: 2.0 Final
Fix Version/s: None

Environment: Windows Vista, Mysql 5.0.45, Maven 2.0.7, JDK 1.6.0 02


 Description  « Hide
When running mvn appfuse:gen-model followed by mvn appfuse:gen on each entity generated (and once the hibernate.cfg.xml is filled with mapping elements for all the entities), when a composite foreign key is encountered, the process fails with:

[myproject] ERROR [main] runtime.error(96) |
Method public java.lang.String org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getG
etterSignature(org.hibernate.mapping.Property) threw an exception when invoked o
n org.hibernate.tool.hbm2x.pojo.ComponentPOJOClass(com.clarestow.myproject.m
odel.CompositeId)
The problematic instruction:
----------
==> assignment: getIdMethodName=pojo.getGetterSignature(pojo.identifierProperty)
 [on line 2, column 1 in appfuse/web/struts/action-test.ftl]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateModelException: Method public java.lang.String org.h
ibernate.tool.hbm2x.pojo.BasicPOJOClass.getGetterSignature(org.hibernate.mapping
.Property) threw an exception when invoked on org.hibernate.tool.hbm2x.pojo.Comp
onentPOJOClass(com.clarestow.myproject.model.CompositeId)
        at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:13
6)
        at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
        at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
        at freemarker.core.Assignment.accept(Assignment.java:90)
        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:231)
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:247)
        at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplatePro
ducer.java:67)
        at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.ja
va:28)
        at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.ja
va:97)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.j
ava:146)
        at org.appfuse.tool.AppFuseExporter$1.exportPOJO(AppFuseExporter.java:21
4)
        at org.hibernate.tool.hbm2x.GenericExporter.exportComponent(GenericExpor
ter.java:131)
        at org.hibernate.tool.hbm2x.GenericExporter$3.process(GenericExporter.ja
va:61)
        at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java
:126)
        at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java
:95)
        at org.appfuse.tool.AppFuseExporter.generateWeb(AppFuseExporter.java:151
)
        at org.appfuse.tool.AppFuseExporter.doStart(AppFuseExporter.java:50)
        at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java
:95)
        at org.appfuse.mojo.HibernateExporterMojo.doExecute(HibernateExporterMoj
o.java:228)
        at org.appfuse.mojo.exporter.AppFuseGeneratorMojo.doExecute(AppFuseGener
atorMojo.java:251)
        at org.appfuse.mojo.HibernateExporterMojo.execute(HibernateExporterMojo.
java:138)
        at org.appfuse.mojo.exporter.AppFuseGeneratorMojo.execute(AppFuseGenerat
orMojo.java:204)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:443)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandalone
Goal(DefaultLifecycleExecutor.java:493)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:463)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:311)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:278)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:143)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:280)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: java.lang.NullPointerException
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getMetaAsString(Cfg2JavaTool.ja
va:78)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.ja
va:168)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.ja
va:164)
        at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getGetterSignature(Basic
POJOClass.java:549)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:583)

        at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:11
3)
        ... 43 more
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error while processing template appfuse/web/struts/action-test.ftl
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.hibernate.tool.hbm2x.ExporterException: Error while processing template appf
use/web/struts/action-test.ftl
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:253)
        at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplatePro
ducer.java:67)
        at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.ja
va:28)
        at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.ja
va:97)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.j
ava:146)
        at org.appfuse.tool.AppFuseExporter$1.exportPOJO(AppFuseExporter.java:21
4)
        at org.hibernate.tool.hbm2x.GenericExporter.exportComponent(GenericExpor
ter.java:131)
        at org.hibernate.tool.hbm2x.GenericExporter$3.process(GenericExporter.ja
va:61)
        at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java
:126)
        at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java
:95)
        at org.appfuse.tool.AppFuseExporter.generateWeb(AppFuseExporter.java:151
)
        at org.appfuse.tool.AppFuseExporter.doStart(AppFuseExporter.java:50)
        at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java
:95)
        at org.appfuse.mojo.HibernateExporterMojo.doExecute(HibernateExporterMoj
o.java:228)
        at org.appfuse.mojo.exporter.AppFuseGeneratorMojo.doExecute(AppFuseGener
atorMojo.java:251)
        at org.appfuse.mojo.HibernateExporterMojo.execute(HibernateExporterMojo.
java:138)
        at org.appfuse.mojo.exporter.AppFuseGeneratorMojo.execute(AppFuseGenerat
orMojo.java:204)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:443)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandalone
Goal(DefaultLifecycleExecutor.java:493)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:463)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:311)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:278)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:143)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:280)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: freemarker.template.TemplateModelException: Method public java.lang.S
tring org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getGetterSignature(org.hibern
ate.mapping.Property) threw an exception when invoked on org.hibernate.tool.hbm2
x.pojo.ComponentPOJOClass(com.clarestow.myproject.model.CompositeId)
        at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:13
6)
        at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
        at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
        at freemarker.core.Assignment.accept(Assignment.java:90)
        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:231)
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelpe
r.java:247)
        ... 34 more
Caused by: java.lang.NullPointerException
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getMetaAsString(Cfg2JavaTool.ja
va:78)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.ja
va:168)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.ja
va:164)
        at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getGetterSignature(Basic
POJOClass.java:549)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:583)

        at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:11
3)
        ... 43 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Tue Sep 18 22:26:18 EDT 2007
[INFO] Final Memory: 18M/33M
[INFO] ------------------------------------------------------------------------

 All   Comments   Change History   FishEye      Sort Order:
Matt Raible - 18/Sep/07 11:05 PM
Yeah, AMP doesn't support composite keys at this point. If you're able to provide an example of what they should look like in the UI (as hidden fields or whatnot, we'd be happy to add support). Basically, the easiest way to develop (for me) is if there's a fully working example (UI, tests, etc.) and then I can reverse engineer from there.

You might also look at Customizing AMP Templates - maybe you can figure out how to add the functionality.

http://appfuse.org/display/APF/AppFuse+Maven+Plugin#AppFuseMavenPlugin-customization

Mike Kelland - 18/Sep/07 11:30 PM
Good call - hadn't thought of that and have re-jigged my project not to use composite keys - I don't think they're entirely necessary.