运行DataNucleus Enhancer 3.1.0-release的NullPointerException

时间:2012-08-06 07:06:09

标签: java dos jdo datanucleus

我正在从DOS运行DataNucleus增强器,如下所示:

java -cp C:\Users\Chania\workspace\myproject\war\WEB-INF\classes\;C:\repo\datanucleus-full-3.1.0-release\lib\datanucleus-enhancer-3.1.0-release.jar;C:\repo\datanucleus-full-3.1.0-release\lib\datanucleus-core-3.1.0-release.jar;C:\repo\datanucleus-full-3.1.0-release\deps\jdo-api-3.1-SNAPSHOT-20110926.jar;C:\repo\datanucleus-full-3.1.0-release\lib\datanucleus-api-jdo-3.1.0-release.jar;C:\repo\datanucleus-full-3.1.0-release\deps\log4j-1.2.14.jar;C:\repo\datanucleus-full-3.1.0-release\deps\asm-4.0.jar -Dlog4j.configuration=file:C:\repo\datanucleus-full-3.1.0-release\log4j.properties org.datanucleus.enhancer.DataNucleusEnhancer -v C:\Users\Chania\workspace\myproject\war\WEB-INF\classes\com\myproject\domain\*.class > logfile.txt

我正在使用的Java版本是:

java version "1.6.0_27"

我得到的错误如下:

 ...
 308  [main] DEBUG DataNucleus.Persistence  - Added converter for java.net.URI<->java.lang.String using org.datanucleus.store.types.converters.URIStringConverter
 308  [main] DEBUG DataNucleus.Persistence  - Added converter for java.net.URL<->java.lang.String using org.datanucleus.store.types.converters.URLStringConverter
 309  [main] DEBUG DataNucleus.Persistence  - Added converter for java.util.UUID<->java.lang.String using org.datanucleus.store.types.converters.UUIDStringConverter
 309  [main] DEBUG DataNucleus.Persistence  - TypeConverter for javax.time.calendar.LocalDate<->java.lang.String ignored since java type not present in CLASSPATH
 310  [main] DEBUG DataNucleus.Persistence  - TypeConverter for javax.time.calendar.LocalTime<->java.lang.String ignored since java type not present in CLASSPATH
 311  [main] DEBUG DataNucleus.Persistence  - TypeConverter for javax.time.calendar.LocalTime<->java.lang.Long ignored since java type not present in CLASSPATH
 312  [main] DEBUG DataNucleus.Persistence  - TypeConverter for javax.time.calendar.LocalDateTime<->java.lang.String ignored since java type not present in CLASSPATH
 312  [main] DEBUG DataNucleus.Persistence  - Type converter support loaded
 312  [main] DEBUG DataNucleus.MetaData  - MetaDataManager : Input=(XML,Annotations), XML-Validation=false, XML-Suffices=(persistence=*.jdo, orm=orm, query=*.jdoquery), JDO-listener=false
 338  [main] DEBUG DataNucleus.MetaData  - MetaData Management : Loading Metadata for classes "[com.myproject.domain.Record, com.myproject.domain.RecordSummary, com.myproject.domain.Comment]" ...
 411  [main] DEBUG DataNucleus.MetaData  - Class "com.myproject.domain.Record" has been specified with JDO annotations so using those.
 596  [main] DEBUG DataNucleus.MetaData  - Class "com.myproject.domain.RecordSummary" has been specified with JDO annotations so using those.
 600  [main] DEBUG DataNucleus.MetaData  - Class "com.myproject.domain.Comment" has been specified with JDO annotations so using those.
 Errors were encountered when loading the specified MetaData files and classes. See the nested exceptions for details
604  [main] ERROR DataNucleus.Enhancer  - DataNucleus Enhancer completed with an error. Please review the enhancer log for full details. Some classes may have been enhanced but some caused errors
 Errors were encountered when loading the specified MetaData files and classes. See the nested exceptions for details
org.datanucleus.exceptions.NucleusUserException: Errors were encountered when loading the specified MetaData files and classes. See the nested exceptions for details
    at org.datanucleus.metadata.MetaDataManager.loadClasses(MetaDataManager.java:536)
    at org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:734)
    at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:525)
    at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1258)
Caused by: java.lang.NullPointerException
    at org.datanucleus.api.jdo.metadata.JDOAnnotationReader.processMemberAnnotations(JDOAnnotationReader.java:1682)
    at org.datanucleus.metadata.annotations.AbstractAnnotationReader.getMetaDataForClass(AbstractAnnotationReader.java:206)
    at org.datanucleus.metadata.annotations.AnnotationManagerImpl.getMetaDataForClass(AnnotationManagerImpl.java:171)
    at org.datanucleus.metadata.MetaDataManager.loadAnnotationsForClass(MetaDataManager.java:2650)
    at org.datanucleus.metadata.MetaDataManager.loadClasses(MetaDataManager.java:496)
    ... 3 more
Nested Throwables StackTrace:
java.lang.NullPointerException
    at org.datanucleus.api.jdo.metadata.JDOAnnotationReader.processMemberAnnotations(JDOAnnotationReader.java:1682)
    at org.datanucleus.metadata.annotations.AbstractAnnotationReader.getMetaDataForClass(AbstractAnnotationReader.java:206)
    at org.datanucleus.metadata.annotations.AnnotationManagerImpl.getMetaDataForClass(AnnotationManagerImpl.java:171)
    at org.datanucleus.metadata.MetaDataManager.loadAnnotationsForClass(MetaDataManager.java:2650)
    at org.datanucleus.metadata.MetaDataManager.loadClasses(MetaDataManager.java:496)
    at org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:734)
    at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:525)
    at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1258)
DataNucleus Enhancer completed with an error. Please review the enhancer log for full details. Some classes may have been enhanced but some caused errors

增强类的来源如下:

@PersistenceCapable(detachable = "true")
public class Record implements Serializable, Cacheable<String> {

    private static final long serialVersionUID = 9022509306966814904L;

    @PrimaryKey
    @Persistent(defaultFetchGroup = "true", valueStrategy = IdGeneratorStrategy.IDENTITY)
    private String id;

    @Name
    @Persistent(defaultFetchGroup = "true")
    private String name;

    @Name
    @Persistent(defaultFetchGroup = "true")
    private String surname;

    @Persistent(defaultFetchGroup = "true")
    private Date dateOfBirth;

    @Persistent(defaultFetchGroup = "true")
    private Date dateRecorded;

    @Persistent(defaultFetchGroup = "true")
    private String locationId;

    @Persistent(embedded = "true", defaultFetchGroup = "true")
    private CustomLocation customLocation;

    @Persistent(defaultFetchGroup = "true")
    private Category category;

    @Persistent(embedded = "true", defaultFetchGroup = "true")
    private CustomCategory customCategory;

    @Persistent(defaultFetchGroup = "true")
    private String description;

    @Persistent(embeddedElement = "true", defaultFetchGroup = "true")
    private List<StoredImageInfo> images;

    @Persistent(embeddedElement = "true", defaultFetchGroup = "true")
    private List<StoredAudioInfo> audio;

    @Persistent(embeddedElement = "true", defaultFetchGroup = "true")
    private List<StoredFileInfo> files;

    @Persistent(defaultFetchGroup = "true")
    private ModerationMode moderationMode;

    @Persistent(defaultFetchGroup = "true")
    private VisibilityMode visibilityMode;

    @Persistent(embedded = "true", defaultFetchGroup = "true")
    private UserProfileSummary owner;

    @Persistent(embeddedElement = "true", defaultFetchGroup = "true")
    private Map<String, UserProfileSummary> editors;

    @Persistent(embeddedElement = "true", defaultFetchGroup = "true")
    private Map<String, UserProfileSummary> connections;

    @Persistent(embeddedElement = "true", defaultFetchGroup = "true")
    private Map<String, RecordSummary> recordConnections;

    @Persistent(defaultFetchGroup = "true")
    private RecordType type;

    @Persistent(defaultFetchGroup = "true")
    private Date expiry;

    public Record() {
    }

    public Record(Record copy) {
        deepCopy(copy);
    }

    ...
}


@PersistenceCapable(embeddedOnly = "true")
public class RecordSummary implements Serializable {

    private static final long serialVersionUID = 9024309306966814904L;

    @Persistent(defaultFetchGroup = "true")
    private String id;

    @Persistent(defaultFetchGroup = "true")
    private RecordRole role;

    @Persistent(defaultFetchGroup = "true")
    private String name;

    @Persistent(defaultFetchGroup = "true")
    private String surname;

    @Persistent(defaultFetchGroup = "true")
    private Date dateOfBirth;

    @Persistent(defaultFetchGroup = "true")
    private Date dateRecorded;

    @SuppressWarnings("unused")
    private RecordSummary() {
        // for serialization
    }

    ...
}


@PersistenceCapable(detachable = "true")
public class Comment implements Attachable<String>, Serializable {

    private static final long serialVersionUID = -7624377549524333808L;

    @PrimaryKey
    @Persistent(defaultFetchGroup = "true", valueStrategy = IdGeneratorStrategy.IDENTITY)
    private String id;

    @Persistent(defaultFetchGroup = "true")
    private String recordId;

    @Persistent(defaultFetchGroup = "true")
    private String username;

    @Persistent(defaultFetchGroup = "true")
    private Date date;

    @Persistent(defaultFetchGroup = "true")
    private String content;

    @SuppressWarnings("unused")
    private Comment() {
        // for serialization
    }

    ...
}

我没有得到任何有关datanucleus enhancer 3.0发布的例外情况(尽管有3.0的其他问题:problem 1problem 2)。 这是DataNucleus 3.1的错误还是我做错了什么?

更新:DataNucleus Enhancer会为标有NullPointerException的所有列表字段抛出@Persistent(embeddedElement = "true")。这很可能是DataNucleus 3.1 Enhancer的错误。

更新2 :根据请求,我包含了可以重现问题的最少代码:

@PersistenceCapable(detachable = "true")
public class Record {

    @PrimaryKey
    @Persistent(defaultFetchGroup = "true", valueStrategy = IdGeneratorStrategy.IDENTITY)
    private String id;

    @Persistent(embeddedElement = "true", defaultFetchGroup = "true")
    private List<MyEmbeddedElement> aList;

    public Record() {
    }

}


@PersistenceCapable(embeddedOnly = "true")
public class MyEmbeddedElement {

    @Persistent
    private String myField;

}

错误:

 730  [main] DEBUG DataNucleus.MetaData  - Class "com.myproject.domain.Record" has been specified with JDO annotations so using those.
 760  [main] DEBUG DataNucleus.MetaData  - Class "com.myproject.domain.MyEmbeddedElement" has been specified with JDO annotations so using those.
 Errors were encountered when loading the specified MetaData files and classes. See the nested exceptions for details
763  [main] ERROR DataNucleus.Enhancer  - DataNucleus Enhancer completed with an error. Please review the enhancer log for full details. Some classes may have been enhanced but some caused errors
 Errors were encountered when loading the specified MetaData files and classes. See the nested exceptions for details
org.datanucleus.exceptions.NucleusUserException: Errors were encountered when loading the specified MetaData files and classes. See the nested exceptions for details
    at org.datanucleus.metadata.MetaDataManager.loadClasses(MetaDataManager.java:536)
    at org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:734)
    at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:525)
    at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1258)
Caused by: java.lang.NullPointerException
    at org.datanucleus.api.jdo.metadata.JDOAnnotationReader.processMemberAnnotations(JDOAnnotationReader.java:1682)
    at org.datanucleus.metadata.annotations.AbstractAnnotationReader.getMetaDataForClass(AbstractAnnotationReader.java:206)
    at org.datanucleus.metadata.annotations.AnnotationManagerImpl.getMetaDataForClass(AnnotationManagerImpl.java:171)
    at org.datanucleus.metadata.MetaDataManager.loadAnnotationsForClass(MetaDataManager.java:2650)
    at org.datanucleus.metadata.MetaDataManager.loadClasses(MetaDataManager.java:496)
    ... 3 more
Nested Throwables StackTrace:
java.lang.NullPointerException
    at org.datanucleus.api.jdo.metadata.JDOAnnotationReader.processMemberAnnotations(JDOAnnotationReader.java:1682)
    at org.datanucleus.metadata.annotations.AbstractAnnotationReader.getMetaDataForClass(AbstractAnnotationReader.java:206)
    at org.datanucleus.metadata.annotations.AnnotationManagerImpl.getMetaDataForClass(AnnotationManagerImpl.java:171)
    at org.datanucleus.metadata.MetaDataManager.loadAnnotationsForClass(MetaDataManager.java:2650)
    at org.datanucleus.metadata.MetaDataManager.loadClasses(MetaDataManager.java:496)
    at org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:734)
    at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:525)
    at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1258)
DataNucleus Enhancer completed with an error. Please review the enhancer log for full details. Some classes may have been enhanced but some caused errors

更新3 :从3.0.2开始的所有DataNucleus版本中都存在此问题。

1 个答案:

答案 0 :(得分:1)

当我在我的应用程序中执行嵌入式收藏时,我

@Element(embedded="true")
Collection<OtherType> myCollField;

这对我有用,并且看起来更符合指定嵌入元素的方式。

你的地图字段也错了......地图没有“元素”,它有“键”和“值”