Project

General

Profile

Bug #9530

NPE in SessionFactory.SessionCloseThread when com.goldencode.p2j.persist.Persistence logger to CONFIG or lower level

Added by Galya B over 1 year ago. Updated over 1 year ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:

History

#1 Updated by Galya B over 1 year ago

The server exits on start with an exception, when logging for com.goldencode.p2j.persist.Persistence (or parent package) is enabled on level CONFIG or lower. The error log is as follows:

Caused by: java.lang.NullPointerException
    at com.goldencode.p2j.persist.orm.SessionFactory$SessionCloseThread.register(SessionFactory.java:315)
    at com.goldencode.p2j.persist.orm.SessionFactory$SessionCloseThread.access$000(SessionFactory.java:239)
    at com.goldencode.p2j.persist.orm.SessionFactory.<init>(SessionFactory.java:118)
    at com.goldencode.p2j.persist.Persistence$Context.<init>(Persistence.java:4643)
    at com.goldencode.p2j.persist.Persistence$Context.<init>(Persistence.java:4597)
    at com.goldencode.p2j.persist.Persistence$1.initialValue(Persistence.java:810)
    at com.goldencode.p2j.persist.Persistence$1.initialValue(Persistence.java:807)
    at com.goldencode.p2j.security.ContextLocal.getImpl(ContextLocal.java:556)
    at com.goldencode.p2j.security.ContextLocal.get(ContextLocal.java:460)
    at com.goldencode.p2j.persist.Persistence.message(Persistence.java:3421)
    at com.goldencode.p2j.persist.Persistence.createLockManager(Persistence.java:3593)
    at com.goldencode.p2j.persist.Persistence.initializeTenant(Persistence.java:3520)

The cause is that SessionCloseThread.register is called before SessionCloseThread.initialize by trying to log LOG.config(message("lock manager initialized [" + className + "]"));. This happens during Persistence.initialize(), because DatabaseManager.initialize() (instantiating Persistence.context) is called before SessionFactory.SessionCloseThread.initialize();.

#2 Updated by Radu Apetrii over 1 year ago

+ Ovidiu

#3 Updated by Ovidiu Maxiniuc over 1 year ago

Galia,
for some reason, the stack trace line number are not matching with my revision (either because of my mine changes or - less probable - yours).

Please check whether the Persistence.message() method looks like this:

   public String message(String message)
   {
      Context[] ctxs = contexts.get(false);
      Context ctx = (ctxs == null) ? null : ctxs[PRIVATE_IDX];  
      return "[" + Utils.describeContext() + "-->" +
             (ctx != null ? ctx.tenant.database : defaultTenant.database) +
             "] " + message;
   }

The important thing here is contexts.get(false). It prohibits the creation of a new context since one is not needed at this time.

You may need to rebase your branch.

#4 Updated by Galya B over 1 year ago

Ovidiu Maxiniuc wrote:

Galia,
for some reason, the stack trace line number are not matching with my revision (either because of my mine changes or - less probable - yours).

Please check whether the Persistence.message() method looks like this:[...]

The important thing here is contexts.get(false). It prohibits the creation of a new context since one is not needed at this time.

You may need to rebase your branch.

The branch I test on is not updated indeed. The issue seems to be fixed on trunk. The task can be closed.

#5 Updated by Greg Shah over 1 year ago

  • % Done changed from 0 to 100
  • Status changed from New to Rejected

Also available in: Atom PDF