Map entity property throws a NPE

Bug #856099 reported by Thomas Adams
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Invalid
High
Unassigned

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.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.

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

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
Revision history for this message
Thomas Adams (heinrich-adams) wrote : RE: [Bug 856099] Re: Map entity property throws a NPE
Download full text (6.4 KiB)

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<String> 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: <email address hidden> [mailto:<email address hidden>] On Behalf Of Timo
Westkämper
Sent: 26 September 2011 15:50
To: <email address hidden>
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

--
You received this bug notification because you are subscribed to the bug
report.
https://bugs.launchpad.net/bugs/856099

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...

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

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

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :
Changed in querydsl:
status: In Progress → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.