Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1057667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:54:17+00:00 2026-05-16T17:54:17+00:00

Working with a legacy codebase in Grails. Under some conditions (we’re unclear exactly what)

  • 0

Working with a legacy codebase in Grails. Under some conditions (we’re unclear exactly what) we get a mysterious NPE, stack trace as below, while doing a findBy.

So far we’re sort of stymied; this appears in several fora for Hibernate but the responses seem to come down to “something is wrong with your schema.” It would be wonderful to find some additional detail to help us track the issue down.

Update

Thanks for the answer. Yes, it’s clear that at the point this NPE happens, version is null. The trouble is that when we look at it in the code, it’s not null.

We’ve begun to suspect there’s a threading issue.

Caused by: java.lang.NullPointerException
    at org.hibernate.type.LongType.next(LongType.java:79)
    at org.hibernate.engine.Versioning.increment(Versioning.java:131)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.getNextVersion(DefaultFlushEntityEventListener.java:387)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:279)
    at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:151)
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:49)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
    at org.codehaus.groovy.grails.plugins.quartz.listeners.SessionBinderJobListener.jobWasExecuted(SessionBinderJobListener.java:58)
    at org.quartz.core.QuartzScheduler.notifyJobListenersWasExecuted(QuartzScheduler.java:1910)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:54:18+00:00Added an answer on May 16, 2026 at 5:54 pm

    Here is my understanding of the trace:

    • you or something do a findBy
    • this triggers a flush
    • the session contains a dirty object with a version field (of type Long) that needs to get updated
    • Hibernate tries to get the next value for the version field for the update
    • and that’s where you get a NPE

    The body of org.hibernate.engine.Versioning.increment(Versioning.java:131) is:

    public static Object increment(Object version, VersionType versionType, SessionImplementor session) {
        Object next = versionType.next( version, session ); // line 131
        if ( log.isTraceEnabled() ) {
            log.trace(
                    "Incrementing: " +
                    versionType.toLoggableString( version, session.getFactory() ) +
                    " to " +
                    versionType.toLoggableString( next, session.getFactory() )
            );
        }
        return next;
    }
    

    And the body of org.hibernate.type.LongType.next(LongType.java:79) (which provides the implementation of the above versionType.next):

    public Object next(Object current, SessionImplementor session) {
        return new Long( ( (Long) current ).longValue() + 1 ); // line 79
    }
    

    It seems clear that the version passed to increment is null.

    I would thus look in the database for a record with a NULL value in its version column. Activating SQL logging might help to narrow down the search.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are working with some legacy code that accesses a shared drive by the
I have been working on some legacy C++ code that uses variable length structures
In the legacy codebase that I am working on, there is a condition evaluator
I'm recently working on this platform for which a legacy codebase issues a large
I'm working with a large existing codebase with tons of legacy code I can't
I'm working on some legacy code. I have a user control with a VtChart
I'm in a 10 person team working on a large legacy code base with
I am working with legacy systems at the moment, and a lot of work
I am working on a legacy project in VC++/Win32/MFC . Recently it became a
I'm working on a legacy app and for whatever reason it's trying to stuff

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.