Help with an issue setting up

112 views
Skip to first unread message

Ben Dol

unread,
Jul 1, 2013, 9:41:53 AM7/1/13
to geda-generic-dto-asse...@googlegroups.com
I am trying to setup geda-core using annotations and I am having trouble with this error:

Caused by: com.inspiresoftware.lib.dto.geda.exception.UnableToCreateInstanceException: Unable to create matcher: {0} for: {1} - {2}

It occurs when I try to call DTOAssembler.newAssembler(...) not sure what is causing this issue. Here is the full stack trace:

Caused by: com.inspiresoftware.lib.dto.geda.exception.UnableToCreateInstanceException: Unable to create matcher: {0} for: {1} - {2}
    at com.inspiresoftware.lib.dto.geda.assembler.CollectionPipeMetadata.newBeanForClass(CollectionPipeMetadata.java:168)
    at com.inspiresoftware.lib.dto.geda.assembler.CollectionPipeMetadata.<init>(CollectionPipeMetadata.java:87)
    at com.inspiresoftware.lib.dto.geda.assembler.MetadataChainAnnotationBuilder.buildCollectionChain(MetadataChainAnnotationBuilder.java:117)
    at com.inspiresoftware.lib.dto.geda.assembler.MetadataChainAnnotationBuilder.build(MetadataChainAnnotationBuilder.java:56)
    at com.inspiresoftware.lib.dto.geda.assembler.DTOtoEntityAssemblerImpl.mapRelationMapping(DTOtoEntityAssemblerImpl.java:132)
    at com.inspiresoftware.lib.dto.geda.assembler.DTOtoEntityAssemblerImpl.<init>(DTOtoEntityAssemblerImpl.java:99)
    at com.inspiresoftware.lib.dto.geda.assembler.DTOtoEntityAssemblerImpl.<init>(DTOtoEntityAssemblerImpl.java:71)
    at com.inspiresoftware.lib.dto.geda.assembler.DTOAssembler.createNewAssembler(DTOAssembler.java:146)
    at com.inspiresoftware.lib.dto.geda.assembler.DTOAssembler.newAssembler(DTOAssembler.java:532)
    at com.inspiresoftware.lib.dto.geda.assembler.DTOAssembler.newAssembler(DTOAssembler.java:491)
    at nz.co.doltech.ims.framework.api.geda.AnnotationGedaMapper.addMapping(AnnotationGedaMapper.java:78)
    at nz.co.doltech.ims.framework.api.geda.AnnotationGedaMapper.scanClassesWith(AnnotationGedaMapper.java:62)
    at nz.co.doltech.ims.framework.api.geda.AnnotationGedaMapper.scan(AnnotationGedaMapper.java:45)
    at nz.co.doltech.ims.framework.api.geda.AnnotationGedaMapper.setPackagesToScan(AnnotationGedaMapper.java:121)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1132)
    ... 61 more
Caused by: java.lang.InstantiationException: com.inspiresoftware.lib.dto.geda.adapter.DtoToEntityMatcher
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at com.inspiresoftware.lib.dto.geda.assembler.CollectionPipeMetadata.newBeanForClass(CollectionPipeMetadata.java:166)
    ... 79 more
 
Here is a sample of my DTO object:

@Dto
@MapsTo(ActivityEntity.class) // class for my project use (still transitioning to a new mapper)
@SuppressWarnings("serial")
public class Activity implements DomainObject, Comparable<Activity> {
   
    @DtoField int id;
    @DtoField String name;
    @DtoField String description;
   
    public Activity() {}
   
    @Override
    public int getId() {
        return id;
    }
    @Override
    public void setId(int id) {
        this.id = id;
    }
   
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
   
    // Adapter functionality
   
    public static final DomainProvidesKey<Activity> KEY_PROVIDER =
            new DomainProvidesKey<Activity>() {
        public Object getKey(Activity domain) {
            return domain == null ? null : domain.getId();
        }
    };
   
    @Override
    public int compareTo(Activity o) {
        if(o == null || getId() < o.getId()) {
            return -1;
        } else if(getId() == o.getId()) {
            return 0;
        } else {
            return 1;
        }
    }
   
    @Override
    public boolean equals(Object o) {
        if(o instanceof Activity) {
            return getId() == ((Activity) o).getId();
        }
        return false;
    }
   
    public static class Adapter extends DomainAdapter<Activity> {
        public Adapter() { }
    }
}

Denis Pavlov

unread,
Jul 1, 2013, 10:57:22 AM7/1/13
to geda-generic-dto-asse...@googlegroups.com
Hi Ben,

This exception occurs when you use @DtoCollection or @DtoMap mapping that are bidirectional (i.e. you will be writing from entity to dto and then dto to entity).

Matcher ensures that when you write dto to entity the collection items are properly synchronized. If you do not need this then mark your collection as read only (e.g. @DtoCollection(readOnly= true)), which will remove the issue altogether. Otherwise you need to give proper class for matcher class that has default constructor or key for adapters and supply matcher object as arguments in adapters map.


Lastly, have a look at the examples module that can be downloaded from maven. There is comprehensive set of fully functional examples just in case you get lost in the documentation (On this page you can see where examples are in the examples module http://inspire-software.com/confluence/display/GeDA/Documentation). 

This is as much information as I can give you at this point. If you need further assistance you need to provide me with full details of your mapping so that I can tell you exactly what is wrong. (You can send it directly to my email).

BTW - those messages in stack trace "matcher: {0} for: {1} - {2}" seem weird - they should be filled with field names and class names. Is this how your stack trace really look like? or was it changes manually in the post? 

Regards,
Denis
Reply all
Reply to author
Forward
0 new messages