pepite/play--database

Error importing data model from postgre

Opened this issue · 1 comments

Using the db:import command on a project with a postgre backend db causes the following error. Tested on play 1.0.3 and 1.1 with db mod 1.0.2 and 1.1.1

~ _ _
~ _ __ | | __ _ _ | |
~ | '
| |/ ' | || ||
~ | /|_|__|__ ()
~ |
| |__/
~
~ play! 1.1-beta2, http://www.playframework.org
~
~ Generating POJOs from the database
~
12:33:53,688 INFO ~ Starting /home/aste/workspace/EWM
12:33:53,692 INFO ~ Module secure is available (/usr/lib/play/modules/secure)
12:33:53,693 INFO ~ Module db is available (/usr/lib/play/modules/db)
12:33:53,693 INFO ~ Module crud is available (/usr/lib/play/modules/crud)
12:33:53,967 WARN ~ You're running Play! in DEV mode
12:33:57,664 ERROR ~

Method public java.lang.String org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getJavaTypeName(org.hibernate.mapping.Property,boolean) threw an exception when invoked on org.hibernate.tool.hbm2x.pojo.EntityPOJOClass(models.CrtCertificates)

The problematic instruction:

==> ${pojo.getJavaTypeName(property, jdk5)} [on line 11, column 45 in pojo/PojoFields.ftl]

in include "PojoFields.ftl" [on line 9, column 1 in pojo/Pojo.ftl]

Java backtrace for programmers:

freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getJavaTypeName(org.hibernate.mapping.Property,boolean) threw an exception when invoked on org.hibernate.tool.hbm2x.pojo.EntityPOJOClass(models.CrtCertificates)
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:136)
at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
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.ConditionalBlock.accept(ConditionalBlock.java:79)
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.include(Environment.java:1375)
at freemarker.core.Include.accept(Include.java:155)
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.IfBlock.accept(IfBlock.java:82)
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.visit(Environment.java:233)
at freemarker.core.BlockAssignment.accept(BlockAssignment.java:83)
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:245)
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:97)
at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:84)
at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:73)
at org.hibernate.tool.hbm2x.GenericExporter.exportClasses(GenericExporter.java:56)
at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:41)
at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
at play.modules.db.Importer.main(Importer.java:98)
Caused by: org.hibernate.tool.hbm2x.ExporterException: Could not resolve type without exception for org.hibernate.mapping.Property(crtRelationshipsesForParentId) Value: org.hibernate.mapping.Set(models.CrtCertificates.crtRelationshipsesForParentId)
at org.hibernate.tool.hbm2x.Cfg2JavaTool.getRawTypeName(Cfg2JavaTool.java:279)
at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.java:180)
at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getJavaTypeName(BasicPOJOClass.java:815)
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 freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:616)
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:113)
... 41 more
Caused by: java.lang.NullPointerException
at org.hibernate.tool.hbm2x.visitor.JavaTypeFromValueVisitor.accept(JavaTypeFromValueVisitor.java:43)
at org.hibernate.mapping.OneToMany.accept(OneToMany.java:138)
at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.java:301)
at org.hibernate.tool.hbm2x.Cfg2JavaTool.getGenericCollectionDeclaration(Cfg2JavaTool.java:286)
at org.hibernate.tool.hbm2x.Cfg2JavaTool.getRawTypeName(Cfg2JavaTool.java:263)
... 49 more
Exception in thread "main" org.hibernate.tool.hbm2x.ExporterException: Error while processing template pojo/Pojo.ftl
at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:251)
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:97)
at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:84)
at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:73)
at org.hibernate.tool.hbm2x.GenericExporter.exportClasses(GenericExporter.java:56)
at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:41)
at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
at play.modules.db.Importer.main(Importer.java:98)
Caused by: freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getJavaTypeName(org.hibernate.mapping.Property,boolean) threw an exception when invoked on org.hibernate.tool.hbm2x.pojo.EntityPOJOClass(models.CrtCertificates)
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:136)
at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.Expression.getStringValue(Expression.java:93)
at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
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.ConditionalBlock.accept(ConditionalBlock.java:79)
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.include(Environment.java:1375)
at freemarker.core.Include.accept(Include.java:155)
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.IfBlock.accept(IfBlock.java:82)
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.visit(Environment.java:233)
at freemarker.core.BlockAssignment.accept(BlockAssignment.java:83)
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:245)
... 9 more
Caused by: org.hibernate.tool.hbm2x.ExporterException: Could not resolve type without exception for org.hibernate.mapping.Property(crtRelationshipsesForParentId) Value: org.hibernate.mapping.Set(models.CrtCertificates.crtRelationshipsesForParentId)
at org.hibernate.tool.hbm2x.Cfg2JavaTool.getRawTypeName(Cfg2JavaTool.java:279)
at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.java:180)
at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getJavaTypeName(BasicPOJOClass.java:815)
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 freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:616)
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:113)
... 41 more
Caused by: java.lang.NullPointerException
at org.hibernate.tool.hbm2x.visitor.JavaTypeFromValueVisitor.accept(JavaTypeFromValueVisitor.java:43)
at org.hibernate.mapping.OneToMany.accept(OneToMany.java:138)
at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.java:301)
at org.hibernate.tool.hbm2x.Cfg2JavaTool.getGenericCollectionDeclaration(Cfg2JavaTool.java:286)
at org.hibernate.tool.hbm2x.Cfg2JavaTool.getRawTypeName(Cfg2JavaTool.java:263)
... 49 more

This same issue happened to me using play-1.1, db-1.1.1, and postgresql 8.4.

It happens whenever you have a table with Foreign Key. I made a simple testcase to reproduce the bug:

####Table creation script

CREATE TABLE students
(
  id serial NOT NULL,
  "name" character varying(20),
  CONSTRAINT pk_student PRIMARY KEY (id)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE students OWNER TO postgres;
GRANT ALL ON TABLE students TO postgres;

CREATE TABLE grades
(
  id serial NOT NULL,
  student_id integer,
  grade numeric(5,2),
  CONSTRAINT pk_grades PRIMARY KEY (id),
  CONSTRAINT fk_grades_student FOREIGN KEY (student_id)
      REFERENCES students (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE grades OWNER TO postgres;
GRANT ALL ON TABLE grades TO postgres;

####Corresponding stacktrace after running play db:import

~ play! 1.1, http://www.playframework.org
~
~ Generating POJOs from the database
~
18:17:02,528 INFO  ~ Starting c:\TEMP\sfweb2
18:17:02,544 INFO  ~ Module db is available (C:\TEMP\play-1.1\modules\db-1.1.1)
18:17:02,589 WARN  ~ You're running Play! in DEV mode
18:17:02,803 INFO  ~ Iterating on arguments, args.length = 0
18:17:02,804 INFO  ~ Importer will use db.driver = org.postgresql.Driver
18:17:02,804 INFO  ~ Importer will use db.user = postgres
18:17:02,804 INFO  ~ Importer will use db.password
18:17:02,804 INFO  ~ Importer will use db.url = jdbc:postgresql://localhost/prueba
18:17:03,256 INFO  ~ DB metadata reading done.
18:17:03,261 INFO  ~ POJO generation enabled.
18:17:03,283 INFO  ~ Starting POJO Exporter ...
18:17:03,606 ERROR ~

Method public java.lang.String org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getJavaTypeName(org.hibernate.mapping.Property,boolean) threw an exception when invoked on org.hibernate.tool.hbm2x.pojo.EntityPOJOClass(models.Students)
The problematic instruction:
----------
==> ${pojo.getJavaTypeName(property, jdk5)} [on line 11, column 45 in pojo/PojoFields.ftl]
 in include "PojoFields.ftl" [on line 9, column 1 in pojo/Pojo.ftl]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getJavaTypeName(org.hibernate.mapping.Property,boolean) threw an exception when invoked on org.hibernate.tool.hbm2x.pojo.EntityPOJOClass(models.Students)
        at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:136)
        at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
        at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
        at freemarker.core.Expression.getStringValue(Expression.java:93)
        at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
        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.ConditionalBlock.accept(ConditionalBlock.java:79)
        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.include(Environment.java:1375)
        at freemarker.core.Include.accept(Include.java:155)
        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.IfBlock.accept(IfBlock.java:82)
        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.visit(Environment.java:233)
        at freemarker.core.BlockAssignment.accept(BlockAssignment.java:83)
        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:245)
        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:97)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:84)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:73)
        at org.hibernate.tool.hbm2x.GenericExporter.exportClasses(GenericExporter.java:56)
        at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:41)
        at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
        at play.modules.db.Importer.main(Importer.java:177)
Caused by: org.hibernate.tool.hbm2x.ExporterException: Could not resolve type without exception for org.hibernate.mapping.Property(gradeses) Value: org.hibernate.mapping.Set(models.Students.gradeses)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getRawTypeName(Cfg2JavaTool.java:279)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.java:180)
        at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getJavaTypeName(BasicPOJOClass.java:815)
        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 freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:616)
        at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:113)
        ... 41 more
Caused by: java.lang.NullPointerException
        at org.hibernate.tool.hbm2x.visitor.JavaTypeFromValueVisitor.accept(JavaTypeFromValueVisitor.java:43)
        at org.hibernate.mapping.OneToMany.accept(OneToMany.java:138)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.java:301)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getGenericCollectionDeclaration(Cfg2JavaTool.java:286)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getRawTypeName(Cfg2JavaTool.java:263)
        ... 49 more
Exception in thread "main" org.hibernate.tool.hbm2x.ExporterException: Error while processing template pojo/Pojo.ftl
        at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:251)
        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:97)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:84)
        at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:73)
        at org.hibernate.tool.hbm2x.GenericExporter.exportClasses(GenericExporter.java:56)
        at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:41)
        at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
        at play.modules.db.Importer.main(Importer.java:177)
Caused by: freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getJavaTypeName(org.hibernate.mapping.Property,boolean) threw an exception when invoked on org.hibernate.tool.hbm2x.pojo.EntityPOJOClass(models.Students)
        at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:136)
        at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
        at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
        at freemarker.core.Expression.getStringValue(Expression.java:93)
        at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
        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.ConditionalBlock.accept(ConditionalBlock.java:79)
        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.include(Environment.java:1375)
        at freemarker.core.Include.accept(Include.java:155)
        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.IfBlock.accept(IfBlock.java:82)
        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.visit(Environment.java:233)
        at freemarker.core.BlockAssignment.accept(BlockAssignment.java:83)
        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:245)
        ... 9 more
Caused by: org.hibernate.tool.hbm2x.ExporterException: Could not resolve type without exception for org.hibernate.mapping.Property(gradeses) Value: org.hibernate.mapping.Set(models.Students.gradeses)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getRawTypeName(Cfg2JavaTool.java:279)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.java:180)
        at org.hibernate.tool.hbm2x.pojo.BasicPOJOClass.getJavaTypeName(BasicPOJOClass.java:815)
        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 freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:616)
        at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:113)
        ... 41 more
Caused by: java.lang.NullPointerException
        at org.hibernate.tool.hbm2x.visitor.JavaTypeFromValueVisitor.accept(JavaTypeFromValueVisitor.java:43)
        at org.hibernate.mapping.OneToMany.accept(OneToMany.java:138)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getJavaTypeName(Cfg2JavaTool.java:301)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getGenericCollectionDeclaration(Cfg2JavaTool.java:286)
        at org.hibernate.tool.hbm2x.Cfg2JavaTool.getRawTypeName(Cfg2JavaTool.java:263)
        ... 49 more

Seems like somehow is trying to inspect on a non-existing (pluralized?) field (models.Students.gradeses) which appears to be an inverse relationship to refer to all grades corresponding to a certain student_id.