New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map entity property throws a NPE #4

Closed
timowest opened this Issue Oct 3, 2011 · 2 comments

Comments

Projects
None yet
1 participant
@timowest
Member

timowest commented Oct 3, 2011

I have the following entity classes, beside a couple of other (so far non critical).

@Entity(value = "USER", noClassnameStored = true)
public class User implements IUser, UserDetails, Account {
    ....
    @Embedded
    private Map<String, UserAttribute> properties;
    ....
    //usual getter an setters

}

@Embedded
public class UserAttribute implements IAttribute {

    //simple property values (String, Object or Date)
}

When i generate the sources with mvn i run into:

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.NullPointerException
at com.mysema.query.apt.ExtendedTypeFactory.createMapType(ExtendedTypeFactory.java:234)
at com.mysema.query.apt.ExtendedTypeFactory.createInterfaceType(ExtendedTypeFactory.java:366)
at com.mysema.query.apt.ExtendedTypeFactory.handleDeclaredType(ExtendedTypeFactory.java:462)
at com.mysema.query.apt.ExtendedTypeFactory.handle(ExtendedTypeFactory.java:441)
at com.mysema.query.apt.ExtendedTypeFactory.createType(ExtendedTypeFactory.java:158)
at com.mysema.query.apt.ExtendedTypeFactory.getType(ExtendedTypeFactory.java:151)
at com.mysema.query.apt.ElementHandler.handleMethodProperty(ElementHandler.java:182)
at com.mysema.query.apt.ElementHandler.handleEntityType(ElementHandler.java:104)
at com.mysema.query.apt.Processor.process(Processor.java:467)
at com.mysema.query.apt.Processor.processEntities(Processor.java:669)
at com.mysema.query.apt.Processor.processAnnotations(Processor.java:181)
at com.mysema.query.apt.Processor.process(Processor.java:127)
at com.mysema.query.mongodb.morphia.MorphiaAnnotationProcessor.process(MorphiaAnnotationProcessor.java:
54)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.j
ava:625)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnviron
ment.java:554)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.ja
va:699)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:981)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:115)
at com.mysema.maven.apt.AbstractProcessorMojo.execute(AbstractProcessorMojo.java:210)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

Excluding the above user class by removing the entity annotation
leads to a successful source generation.

version apt 1.0.2, version dsl 2.2.2

Any ideas? I tried playing with

<querydsl.mapAccessors>false</querydsl.mapAccessors>

and
<querydsl.mapAccessors>true</querydsl.mapAccessors>

but this seems to have no effect, even omitting the option completely
yields the same error result.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Oct 3, 2011

Member

Timo Westkämper (timo-westkamper) wrote on 2011-09-26: #1

Could you provide a minimal example project where this fails? I have not yet been able to reproduce this issue.
Changed in querydsl:
status: New → In Progress
importance: Undecided → High
Thomas Adams (heinrich-adams) wrote on 2011-09-28: RE: [Bug 856099] Re: Map entity property throws a NPE #2

Hi,

Trying to create a simple example from the bottom up, however
I could not reproduce that either. However, removing all properties of the
entities and adding them step by step up again, I'm now getting
trouble to generate the sources again (same stacktrace as before)

@entity(value = "PERSON", noClassnameStored = true)
public class Person implements
org.apache.shindig.social.opensocial.model.Person {

private static final long serialVersionUID = 1L;

@id
private ObjectId objectId = null;

private String id;
....

  // the next two methods are causing the trouble

@override
public Map<String, ?> getAppData() {
return personAppData;
}

@override
public void setAppData(Map<String, ?> appData) {
Map<String, String> m = new HashMap<String, String>();
for (Iterator iterator =
appData.keySet().iterator(); iterator
.hasNext();) {

String k = iterator.next();
String v = (String) appData.get(k);

m.put(k, v);

}
personAppData = m;
}

Once these 2 methods are removed at least the source generation runs
through, however there is now
A Qstring class generated with compiler errors:

public class QString extends BeanPath {

...

public QString(BeanPath<String> entity) {
    super(entity.getMetadata());
}

public QString(PathMetadata<?> metadata) {
    super(metadata);
}

...

}

The compiler complains about : The constructor
BeanPath(PathMetadata<capture#2-of ?>) is undefined.

This is really out of my expertise now, so far what
I got when using querydsl with JPA in that case was
a StringPath.

C. Thomas

-----Original Message-----
From: bounces@canonical.com [mailto:bounces@canonical.com] On Behalf Of Timo
Westkämper
Sent: 26 September 2011 15:50
To: heinrich.adams@gmail.com
Subject: [Bug 856099] Re: Map entity property throws a NPE

Could you provide a minimal example project where this fails? I have not yet
been able to reproduce this issue.

** Changed in: querydsl
Status: New => In Progress

** Changed in: querydsl
Importance: Undecided => High

[...]

Title:
Map entity property throws a NPE

Status in Querydsl:
In Progress

Bug description:
I have the following entity classes, beside a couple of other (so far
non critical).

@entity(value = "USER", noClassnameStored = true)
public class User implements IUser, UserDetails, Account {
....
@Embedded
private Map<String, UserAttribute> properties;
....
//usual getter an setters

}

@Embedded
public class UserAttribute implements IAttribute {

      //simple property values (String, Object or Date)

}

When i generate the sources with mvn i run into:

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.NullPointerException
at
com.mysema.query.apt.ExtendedTypeFactory.createMapType(ExtendedTypeFactory.j
ava:234)
at
com.mysema.query.apt.ExtendedTypeFactory.createInterfaceType(ExtendedTypeFac
tory.java:366)
at
com.mysema.query.apt.ExtendedTypeFactory...

Read more...
Timo Westkämper (timo-westkamper) wrote on 2011-09-30: #3

I added now support for all kinds of untyped Collection properties in Querydsl APT. Could you try this again with the Git master branch?

Member

timowest commented Oct 3, 2011

Timo Westkämper (timo-westkamper) wrote on 2011-09-26: #1

Could you provide a minimal example project where this fails? I have not yet been able to reproduce this issue.
Changed in querydsl:
status: New → In Progress
importance: Undecided → High
Thomas Adams (heinrich-adams) wrote on 2011-09-28: RE: [Bug 856099] Re: Map entity property throws a NPE #2

Hi,

Trying to create a simple example from the bottom up, however
I could not reproduce that either. However, removing all properties of the
entities and adding them step by step up again, I'm now getting
trouble to generate the sources again (same stacktrace as before)

@entity(value = "PERSON", noClassnameStored = true)
public class Person implements
org.apache.shindig.social.opensocial.model.Person {

private static final long serialVersionUID = 1L;

@id
private ObjectId objectId = null;

private String id;
....

  // the next two methods are causing the trouble

@override
public Map<String, ?> getAppData() {
return personAppData;
}

@override
public void setAppData(Map<String, ?> appData) {
Map<String, String> m = new HashMap<String, String>();
for (Iterator iterator =
appData.keySet().iterator(); iterator
.hasNext();) {

String k = iterator.next();
String v = (String) appData.get(k);

m.put(k, v);

}
personAppData = m;
}

Once these 2 methods are removed at least the source generation runs
through, however there is now
A Qstring class generated with compiler errors:

public class QString extends BeanPath {

...

public QString(BeanPath<String> entity) {
    super(entity.getMetadata());
}

public QString(PathMetadata<?> metadata) {
    super(metadata);
}

...

}

The compiler complains about : The constructor
BeanPath(PathMetadata<capture#2-of ?>) is undefined.

This is really out of my expertise now, so far what
I got when using querydsl with JPA in that case was
a StringPath.

C. Thomas

-----Original Message-----
From: bounces@canonical.com [mailto:bounces@canonical.com] On Behalf Of Timo
Westkämper
Sent: 26 September 2011 15:50
To: heinrich.adams@gmail.com
Subject: [Bug 856099] Re: Map entity property throws a NPE

Could you provide a minimal example project where this fails? I have not yet
been able to reproduce this issue.

** Changed in: querydsl
Status: New => In Progress

** Changed in: querydsl
Importance: Undecided => High

[...]

Title:
Map entity property throws a NPE

Status in Querydsl:
In Progress

Bug description:
I have the following entity classes, beside a couple of other (so far
non critical).

@entity(value = "USER", noClassnameStored = true)
public class User implements IUser, UserDetails, Account {
....
@Embedded
private Map<String, UserAttribute> properties;
....
//usual getter an setters

}

@Embedded
public class UserAttribute implements IAttribute {

      //simple property values (String, Object or Date)

}

When i generate the sources with mvn i run into:

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.NullPointerException
at
com.mysema.query.apt.ExtendedTypeFactory.createMapType(ExtendedTypeFactory.j
ava:234)
at
com.mysema.query.apt.ExtendedTypeFactory.createInterfaceType(ExtendedTypeFac
tory.java:366)
at
com.mysema.query.apt.ExtendedTypeFactory...

Read more...
Timo Westkämper (timo-westkamper) wrote on 2011-09-30: #3

I added now support for all kinds of untyped Collection properties in Querydsl APT. Could you try this again with the Git master branch?

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 19, 2011

Member

Released in 2.2.5

Member

timowest commented Nov 19, 2011

Released in 2.2.5

@timowest timowest closed this Nov 19, 2011

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