java.lang.StackOverflowError #231

Closed
khalidr opened this Issue Sep 17, 2012 · 21 comments

Comments

Projects
None yet
3 participants
@khalidr

khalidr commented Sep 17, 2012

I am seeing a java.lang.StackOverflowError when running APT on my domain classes. We are using Hibernate 3.3.2.GA.

Here are the pom.xml changes:

    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <version>2.7.3</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-jpa</artifactId>
        <version>2.7.3</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.1</version>
    </dependency>


                <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>maven-apt-plugin</artifactId>
            <version>1.0.4</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Here is the exception:

java.lang.StackOverflowError
at java.util.HashMap$KeyIterator.(HashMap.java:826)
at java.util.HashMap.newKeyIterator(HashMap.java:840)
at java.util.HashMap$KeySet.iterator(HashMap.java:874)
at java.util.HashSet.iterator(HashSet.java:153)
at com.mysema.query.codegen.EntityType.getSuperType(EntityType.java:162)
at com.mysema.query.codegen.TypeResolver.resolveTypeExtends(TypeResolver.java:82)
at com.mysema.query.codegen.TypeResolver.resolve(TypeResolver.java:39)
at com.mysema.query.codegen.TypeResolver.resolveWithParameters(TypeResolver.java:99)
at com.mysema.query.codegen.TypeResolver.resolve(TypeResolver.java:44)
at com.mysema.query.codegen.TypeResolver.resolveWithParameters(TypeResolver.java:99)
at com.mysema.query.codegen.TypeResolver.resolve(TypeResolver.java:44)
at com.mysema.query.codegen.TypeResolver.resolveWithParameters(TypeResolver.java:99)
at com.mysema.query.codegen.TypeResolver.resolve(TypeResolver.java:44)
at com.mysema.query.codegen.TypeResolver.resolveWithParameters(TypeResolver.java:99)
at com.mysema.query.codegen.TypeResolver.resolve(TypeResolver.java:44)
at com.mysema.query.codegen.TypeResolver.resolveWithParameters(TypeResolver.java:99)
at com.mysema.query.codegen.TypeResolver.resolve(TypeResolver.java:44)
at com.mysema.query.codegen.TypeResolver.resolveWithParameters(TypeResolver.java:99)
at com.mysema.query.codegen.TypeResolver.resolve(TypeResolver.java:44)
at com.mysema.query.codegen.TypeResolver.resolveWithParameters(TypeResolver.java:99)
at com.mysema.query.codegen.TypeResolver.resolve(TypeResolver.java:44)
at com.mysema.query.codegen.TypeResolver.resolveWithParameters(TypeResolver.java:99)
at com.mysema.query.codegen.TypeResolver.resolve(TypeResolver.java:44)
at com.mysema.query.codegen.TypeResolver.resolveWithParameters(TypeResolver.java:99)
at com.mysema.query.codegen.TypeResolver.resolve(TypeResolver.java:44)
at com.mysema.query.codegen.TypeResolver.resolveWithParameters(TypeResolver.java:99)

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 17, 2012

Member

This looks like it is caused by an Entity class with generic type parameters. Could you provide a sample domain which results in the same error?

Member

timowest commented Sep 17, 2012

This looks like it is caused by an Entity class with generic type parameters. Could you provide a sample domain which results in the same error?

@khalidr

This comment has been minimized.

Show comment
Hide comment
@khalidr

khalidr Sep 17, 2012

Problem is that we have a huge domain and i dont know which class is causing the problem. Is there a way to enable some logging?

khalidr commented Sep 17, 2012

Problem is that we have a huge domain and i dont know which class is causing the problem. Is there a way to enable some logging?

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 17, 2012

Member

You can use the

<showWarnings>true</showWarnings> 

option

Member

timowest commented Sep 17, 2012

You can use the

<showWarnings>true</showWarnings> 

option

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 17, 2012

Member

It seems to be an entity with a version of itself as a generic parameter. Maybe something like

class Customer<T extends Customer>

But I'd like to know the exact case.

Member

timowest commented Sep 17, 2012

It seems to be an entity with a version of itself as a generic parameter. Maybe something like

class Customer<T extends Customer>

But I'd like to know the exact case.

@khalidr

This comment has been minimized.

Show comment
Hide comment
@khalidr

khalidr Sep 17, 2012

Hmmm...still no logs. Here is what i did:

        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>maven-apt-plugin</artifactId>
            <version>1.0.4</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                        <showWarnings>true</showWarnings>
                    </configuration>
                </execution>
            </executions>
        </plugin>

khalidr commented Sep 17, 2012

Hmmm...still no logs. Here is what i did:

        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>maven-apt-plugin</artifactId>
            <version>1.0.4</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                        <showWarnings>true</showWarnings>
                    </configuration>
                </execution>
            </executions>
        </plugin>
@khalidr

This comment has been minimized.

Show comment
Hide comment
@khalidr

khalidr Sep 17, 2012

Looks like you are right.

public class MyOrder<B extends MyOrder<B>> extends Order<B>

Is there anything that can be done to get around this problem (aside from removing the generic parameters)?

I still could not get the apt tool to log anything.

khalidr commented Sep 17, 2012

Looks like you are right.

public class MyOrder<B extends MyOrder<B>> extends Order<B>

Is there anything that can be done to get around this problem (aside from removing the generic parameters)?

I still could not get the apt tool to log anything.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 18, 2012

Member

How does the type parameter of Order look like? I will see if I can do a quickfix.

Member

timowest commented Sep 18, 2012

How does the type parameter of Order look like? I will see if I can do a quickfix.

@khalidr

This comment has been minimized.

Show comment
Hide comment
@khalidr

khalidr Sep 18, 2012

@MappedSuperclass
@AttributeOverride(name = "id", column = @Column(name = "ORDER_ID"))
public abstract class Order<B extends Order<B>> extends BaseEntity<B> implements Cloneable

khalidr commented Sep 18, 2012

@MappedSuperclass
@AttributeOverride(name = "id", column = @Column(name = "ORDER_ID"))
public abstract class Order<B extends Order<B>> extends BaseEntity<B> implements Cloneable
@mirkosertic

This comment has been minimized.

Show comment
Hide comment
@mirkosertic

mirkosertic Sep 18, 2012

Hi there

I am also getting the same error with QueryDSL 2.7.3. I am using HibernateDomainExporter with my own Maven plugin. Here is the StackTrace:

[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] null
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
java.lang.StackOverflowError
at java.lang.Class.getEnclosingMethod0(Native Method)
at java.lang.Class.getEnclosingMethodInfo(Class.java:929)
at java.lang.Class.getEnclosingClass(Class.java:1081)
at java.lang.Class.getCanonicalName(Class.java:1169)
at com.mysema.codegen.support.ClassUtils.getFullName(ClassUtils.java:28)
at com.mysema.codegen.model.ClassType.(ClassType.java:45)
at com.mysema.codegen.model.ClassType.(ClassType.java:34)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:221)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:223)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:223)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:223)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:223)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:223)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:223)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)

Hi there

I am also getting the same error with QueryDSL 2.7.3. I am using HibernateDomainExporter with my own Maven plugin. Here is the StackTrace:

[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] null
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
java.lang.StackOverflowError
at java.lang.Class.getEnclosingMethod0(Native Method)
at java.lang.Class.getEnclosingMethodInfo(Class.java:929)
at java.lang.Class.getEnclosingClass(Class.java:1081)
at java.lang.Class.getCanonicalName(Class.java:1169)
at com.mysema.codegen.support.ClassUtils.getFullName(ClassUtils.java:28)
at com.mysema.codegen.model.ClassType.(ClassType.java:45)
at com.mysema.codegen.model.ClassType.(ClassType.java:34)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:221)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:223)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:223)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:223)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:223)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:223)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)
at com.mysema.query.codegen.TypeFactory.getTypeParameter(TypeFactory.java:223)
at com.mysema.query.codegen.TypeFactory.getTypeParameters(TypeFactory.java:203)
at com.mysema.query.codegen.TypeFactory.getParameters(TypeFactory.java:165)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:97)
at com.mysema.query.codegen.TypeFactory.create(TypeFactory.java:79)

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 18, 2012

Member

@khalidr and @mirkosertic I need sample domains that fail. I tried with the signatures you gave, but they worked.

Member

timowest commented Sep 18, 2012

@khalidr and @mirkosertic I need sample domains that fail. I tried with the signatures you gave, but they worked.

timowest added a commit that referenced this issue Sep 18, 2012

@mirkosertic

This comment has been minimized.

Show comment
Hide comment
@mirkosertic

mirkosertic Sep 19, 2012

Hi

I am using the HibernateDomainExporter, and i don't know how to enable logging. Any ideas?

Regards
Mirko

Hi

I am using the HibernateDomainExporter, and i don't know how to enable logging. Any ideas?

Regards
Mirko

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 19, 2012

Member

There is currently not much logging in the HibernateDomainExporter, but you could search for a similar case or debug.

Member

timowest commented Sep 19, 2012

There is currently not much logging in the HibernateDomainExporter, but you could search for a similar case or debug.

@khalidr

This comment has been minimized.

Show comment
Hide comment
@khalidr

khalidr Sep 19, 2012

Yeah thats my problem too. I don't know which class is causing the
problem. I tried enableWarnings but that did not show any additional logs.
On Sep 19, 2012 3:19 AM, "Timo Westkämper" notifications@github.com wrote:

There is currently not much logging in the HibernateDomainExporter, but
you could search for a similar case or debug.


Reply to this email directly or view it on GitHubhttps://github.com/mysema/querydsl/issues/231#issuecomment-8681475.

khalidr commented Sep 19, 2012

Yeah thats my problem too. I don't know which class is causing the
problem. I tried enableWarnings but that did not show any additional logs.
On Sep 19, 2012 3:19 AM, "Timo Westkämper" notifications@github.com wrote:

There is currently not much logging in the HibernateDomainExporter, but
you could search for a similar case or debug.


Reply to this email directly or view it on GitHubhttps://github.com/mysema/querydsl/issues/231#issuecomment-8681475.

@mirkosertic

This comment has been minimized.

Show comment
Hide comment
@mirkosertic

mirkosertic Sep 19, 2012

Ok these are the problematic signatures:

public abstract class HidaBez<B extends HidaBez<B, G>, G extends HidaBezGruppe<G, B>> extends CapiBCKeyedByGrundstueck {
}

public abstract class HidaBezGruppe<G extends HidaBezGruppe<G, B>, B extends HidaBez<B, G>> extends
        CapiBCKeyedByGrundstueck {
}

In TypeFactory:223 it tries to create a new TypeExtends() for rawType HidaBez of typeVariable B for class HidaBezGruppe for index i = 1. This starts a recursion in the create() Method for the rawType.

Ok these are the problematic signatures:

public abstract class HidaBez<B extends HidaBez<B, G>, G extends HidaBezGruppe<G, B>> extends CapiBCKeyedByGrundstueck {
}

public abstract class HidaBezGruppe<G extends HidaBezGruppe<G, B>, B extends HidaBez<B, G>> extends
        CapiBCKeyedByGrundstueck {
}

In TypeFactory:223 it tries to create a new TypeExtends() for rawType HidaBez of typeVariable B for class HidaBezGruppe for index i = 1. This starts a recursion in the create() Method for the rawType.

@mirkosertic

This comment has been minimized.

Show comment
Hide comment
@mirkosertic

mirkosertic Sep 19, 2012

There is also another problem with Hibernate bidirectional references:

Caused by: java.lang.IllegalArgumentException: No property found for ch.bedag.gba.capitastra.model.beschreibung.GbPlan._ch.bedag.gba.capitastra.model.beschreibung.GbPlanMaster.versionsBackref
at com.mysema.query.jpa.codegen.HibernateDomainExporter.getType(HibernateDomainExporter.java:408)
at com.mysema.query.jpa.codegen.HibernateDomainExporter.handleProperty(HibernateDomainExporter.java:319)
at com.mysema.query.jpa.codegen.HibernateDomainExporter.collectTypes(HibernateDomainExporter.java:312)
at com.mysema.query.jpa.codegen.HibernateDomainExporter.execute(HibernateDomainExporter.java:229)
at ch.bedag.gba.maven.plugin.querydsl.HibernateExportMojo.execute(HibernateExportMojo.java:62)

The exporter should check org.hibernate.mapping.Property.isBackRef()

There is also another problem with Hibernate bidirectional references:

Caused by: java.lang.IllegalArgumentException: No property found for ch.bedag.gba.capitastra.model.beschreibung.GbPlan._ch.bedag.gba.capitastra.model.beschreibung.GbPlanMaster.versionsBackref
at com.mysema.query.jpa.codegen.HibernateDomainExporter.getType(HibernateDomainExporter.java:408)
at com.mysema.query.jpa.codegen.HibernateDomainExporter.handleProperty(HibernateDomainExporter.java:319)
at com.mysema.query.jpa.codegen.HibernateDomainExporter.collectTypes(HibernateDomainExporter.java:312)
at com.mysema.query.jpa.codegen.HibernateDomainExporter.execute(HibernateDomainExporter.java:229)
at ch.bedag.gba.maven.plugin.querydsl.HibernateExportMojo.execute(HibernateExportMojo.java:62)

The exporter should check org.hibernate.mapping.Property.isBackRef()

@mirkosertic

This comment has been minimized.

Show comment
Hide comment
@mirkosertic

mirkosertic Sep 19, 2012

And another Problem is that EntitySerializer cannot correctly handle types with persistent properties from superclasses which itself are not managed by hibernate.

Exception:

14:54:28,588 ERROR ydsl.MyHibernateDomainExporter - Error creating class for ch.bedag.gba.capitastra.model.beschreibung.Teilgrundstueck
java.lang.IllegalStateException: No entity type for ch.bedag.gba.capitastra.model.EffectivityBusinessClass
at com.mysema.query.codegen.EntitySerializer.initEntityFields(EntitySerializer.java:250)
at com.mysema.query.codegen.EntitySerializer.constructors(EntitySerializer.java:177)
at com.mysema.query.codegen.EntitySerializer.serialize(EntitySerializer.java:582)

And another Problem is that EntitySerializer cannot correctly handle types with persistent properties from superclasses which itself are not managed by hibernate.

Exception:

14:54:28,588 ERROR ydsl.MyHibernateDomainExporter - Error creating class for ch.bedag.gba.capitastra.model.beschreibung.Teilgrundstueck
java.lang.IllegalStateException: No entity type for ch.bedag.gba.capitastra.model.EffectivityBusinessClass
at com.mysema.query.codegen.EntitySerializer.initEntityFields(EntitySerializer.java:250)
at com.mysema.query.codegen.EntitySerializer.constructors(EntitySerializer.java:177)
at com.mysema.query.codegen.EntitySerializer.serialize(EntitySerializer.java:582)

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 19, 2012

Member

@mirkosertic could you create new tickets for the other issues with more details?

Member

timowest commented Sep 19, 2012

@mirkosertic could you create new tickets for the other issues with more details?

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 19, 2012

Member

@mirkosertic Your issue has been fixed with the latest commit. @khalidr could you provide a sample domain?

Member

timowest commented Sep 19, 2012

@mirkosertic Your issue has been fixed with the latest commit. @khalidr could you provide a sample domain?

@mirkosertic

This comment has been minimized.

Show comment
Hide comment
@mirkosertic

mirkosertic Sep 20, 2012

Done, created #234 + #235

Done, created #234 + #235

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 24, 2012

Member

Fully fixed now, @khalidr 's problem was the same as in #236

Member

timowest commented Sep 24, 2012

Fully fixed now, @khalidr 's problem was the same as in #236

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 29, 2012

Member

Released in 2.8.0

Member

timowest commented Sep 29, 2012

Released in 2.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment