Skip to content

Lazy initialization error with LOG4J turned on - failed to lazily initialize a collection of role: ...no session or session was closed [SPR-8342] #12990

Closed

Description

@spring-projects-issues

Sujith Radhakrishnan opened SPR-8342 and commented

With log4J set to DEBUG ALL, I get the following error when a client access the server via amf remote-messaging.

INFO: [ERROR,LazyInitializationException] failed to lazily initialize a collection of role: ...., no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.switchpt.tbm.entity.Projects.tbmJobDescs, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:383)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:375)
at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:122)
at org.hibernate.collection.PersistentSet.size(PersistentSet.java:162)
at org.springframework.core.style.DefaultValueStyler.style(DefaultValueStyler.java:104)
at org.springframework.core.style.DefaultValueStyler.style(DefaultValueStyler.java:72)

It works fine if i disable the log.

Looks like the issue is caused by line# 159 in GenericConversionService.java:
156 public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
157 assertNotNull(sourceType, targetType);
158 if (logger.isDebugEnabled()) {
159 logger.debug("Converting value " + StylerUtils.style(source) + " of " + sourceType + " to " + targetType);
160 }
161 if (sourceType == TypeDescriptor.NULL) {

The log is trying to deserialize the data causing the issue...


Affects: 3.0.5

Issue Links:

2 votes, 3 watchers

Activity

  1. spring-projects-issues commented on May 17, 2011

    @spring-projects-issues
    CollaboratorAuthor

    Jeremy Grelle commented

    This is likely rarely enough encountered that it may not be worth explicitly addressing, but I have moved it here (from Spring BlazeDS) since the source of the problem is GenericConversionService, and in particular, its use of StylerUtils.style, which forces initialization of lazy Hibernate proxies due to its attempt at deep traversal.

  2. spring-projects-issues commented on Sep 22, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Closing groups of outdated issues. Please reopen if still relevant.

  3. added
    type: bug
    status: declined
    in: core
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: corestatus: declined

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions