Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Hibernate Basics Persisting Data with Hibernate Saving Data with Hibernate


Hi all,

I am working on this video: https://teamtreehouse.com/library/hibernate-basics/persisting-data-with-hibernate/saving-data-with-hibernate

When I run the application there seems to be NullPointerException instead of Hibernate: insert into Contact (id, email, firstname, lastname, phone) values (null, ?, ?, ?, ?).

Here is part of my console output:

INFO: HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
Hibernate: drop table Contact if exists
Hibernate: create table Contact (id integer generated by default as identity, email varchar(255), firstname varchar(255), lastname varchar(255), phone bigint, primary key (id))
Mar 04, 2017 7:47:12 PM org.hibernate.tool.schema.internal.SchemaCreatorImpl applyImportSources
INFO: HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@66fdec9'
Exception in thread "main" java.lang.NullPointerException
    at com.teamtreehouse.contactmgr.Application.main(Application.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Any help would be much appreciated, thank you!

Alexander Nikiforov
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,174 Points

Interesting error.

But I can't help without seeing actual project.

If you know/can post a project on GitHub and share a link, will be glad to take a look.

Otherwise, can't help :)

2,225 Points

Did you forget to add the java transaction api as dependency in Gradle? The dependency block in your build.gradle file should look similiar to this:

dependencies {
    compile 'org.hibernate:hibernate-core:5.1.0.Final'
    compile 'com.h2database:h2:1.4.191'
    compile 'javax.transaction:jta:1.1'