в модуль com.faster xml .jackson.databind ошибка - PullRequest
0 голосов
/ 19 февраля 2020

При использовании Jackson ObjectMapper возникает проблема с привязкой данных Джексона. Мой класс Pojo кажется доступным. Я просто не могу передать оператор mapper.readvalue.

Я получаю следующую ошибку:

Невозможно сделать доступным publi c молекулярный. Gene.Gene (): модуль WfGJsonParser не "экспортирует" молекулярный "для модуля com.faster xml .jackson.databind

Мой module.info:


        module WfGJsonParser {
            requires commons.cli;
            requires com.fasterxml.jackson.core;
            requires com.fasterxml.jackson.databind;
            requires com.fasterxml.jackson.annotation;
        }

    ```

    > JSonParser.java
    ```
    package molecular;
    import java.io.File;
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    import com.fasterxml.jackson.core.JsonParseException;
    import com.fasterxml.jackson.databind.ObjectMapper;
    import molecular.generated.Gene;
    public class JSonParser{
    private String chr;
        private String position;
    public JSonParser(String json) throws JsonParseException, IOException {
            // TODO Auto-generated constructor stub

            System.out.println(json); // prints /Resources/template/internal_standard_report.json

    byte[] jsonData = Files.readAllBytes(Paths.get(json));

            //create ObjectMapper instance
            ObjectMapper mapper = new ObjectMapper();

            Gene gene = mapper.readValue(new File(json), Gene.class);

            System.out.println("gene:\n"+gene);

            System.out.println(gene.getGeneSummary());
            System.out.println(gene.getChromosome());
        }

    }

Gene.java



 package edu.jhmi.molecular.generated;

import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
    "GeneName",
    "GeneSummary",
    "SimplifiedGeneSummary",
    "SimplifiedGeneSummaryWithGermline",
    "Chromosome",
    "PrimaryTranscript",
    "Position",
    "HighestDrugEvidenceLevel",
    "Classification",
    "FunctionImpact",
    "IsOncogene",
    "Score",
    "GeneAnnotation",
    "Variants",
    "VariantInfoList"
})
public class Gene {

    @JsonProperty("GeneName")
    private String geneName;
    @JsonProperty("GeneSummary")
    private String geneSummary;
    @JsonProperty("SimplifiedGeneSummary")
    private String simplifiedGeneSummary;
    @JsonProperty("SimplifiedGeneSummaryWithGermline")
    private String simplifiedGeneSummaryWithGermline;
    @JsonProperty("Chromosome")
    private String chromosome;
    @JsonProperty("PrimaryTranscript")
    private String primaryTranscript;
    @JsonProperty("Position")
    private String position;
    @JsonProperty("HighestDrugEvidenceLevel")
    private String highestDrugEvidenceLevel;
    @JsonProperty("Classification")
    private String classification;
    @JsonProperty("FunctionImpact")
    private String functionImpact;
    @JsonProperty("IsOncogene")
    private Boolean isOncogene;
    @JsonProperty("Score")
    private Double score;
    @JsonProperty("GeneAnnotation")
    private String geneAnnotation;
    @JsonProperty("Variants")
    private List<Variant> variants = new ArrayList<Variant>();
    @JsonProperty("VariantInfoList")
    private String variantInfoList;

    /**
     * No args constructor for use in serialization
     * 
     */
    public Gene() {
    }

    /**
     * 
     * @param chromosome
     * @param isOncogene
     * @param geneSummary
     * @param simplifiedGeneSummary
     * @param functionImpact
     * @param variants
     * @param classification
     * @param score
     * @param geneName
     * @param highestDrugEvidenceLevel
     * @param position
     * @param geneAnnotation
     * @param simplifiedGeneSummaryWithGermline
     * @param primaryTranscript
     * @param variantInfoList
     */
    public Gene(String geneName, String geneSummary, String simplifiedGeneSummary, String simplifiedGeneSummaryWithGermline, String chromosome, String primaryTranscript, String position, String highestDrugEvidenceLevel, String classification, String functionImpact, Boolean isOncogene, Double score, String geneAnnotation, List<Variant> variants, String variantInfoList) {
        super();
        this.geneName = geneName;
        this.geneSummary = geneSummary;
        this.simplifiedGeneSummary = simplifiedGeneSummary;
        this.simplifiedGeneSummaryWithGermline = simplifiedGeneSummaryWithGermline;
        this.chromosome = chromosome;
        this.primaryTranscript = primaryTranscript;
        this.position = position;
        this.highestDrugEvidenceLevel = highestDrugEvidenceLevel;
        this.classification = classification;
        this.functionImpact = functionImpact;
        this.isOncogene = isOncogene;
        this.score = score;
        this.geneAnnotation = geneAnnotation;
        this.variants = variants;
        this.variantInfoList = variantInfoList;
    }

    @JsonProperty("GeneName")
    public String getGeneName() {
        return geneName;
    }

    @JsonProperty("GeneName")
    public void setGeneName(String geneName) {
        this.geneName = geneName;
    }

    @JsonProperty("GeneSummary")
    public String getGeneSummary() {
        return geneSummary;
    }

    @JsonProperty("GeneSummary")
    public void setGeneSummary(String geneSummary) {
        this.geneSummary = geneSummary;
    }

    @JsonProperty("SimplifiedGeneSummary")
    public String getSimplifiedGeneSummary() {
        return simplifiedGeneSummary;
    }

    @JsonProperty("SimplifiedGeneSummary")
    public void setSimplifiedGeneSummary(String simplifiedGeneSummary) {
        this.simplifiedGeneSummary = simplifiedGeneSummary;
    }

    @JsonProperty("SimplifiedGeneSummaryWithGermline")
    public String getSimplifiedGeneSummaryWithGermline() {
        return simplifiedGeneSummaryWithGermline;
    }

    @JsonProperty("SimplifiedGeneSummaryWithGermline")
    public void setSimplifiedGeneSummaryWithGermline(String simplifiedGeneSummaryWithGermline) {
        this.simplifiedGeneSummaryWithGermline = simplifiedGeneSummaryWithGermline;
    }

    @JsonProperty("Chromosome")
    public String getChromosome() {
        return chromosome;
    }

    @JsonProperty("Chromosome")
    public void setChromosome(String chromosome) {
        this.chromosome = chromosome;
    }

    @JsonProperty("PrimaryTranscript")
    public String getPrimaryTranscript() {
        return primaryTranscript;
    }

    @JsonProperty("PrimaryTranscript")
    public void setPrimaryTranscript(String primaryTranscript) {
        this.primaryTranscript = primaryTranscript;
    }

    @JsonProperty("Position")
    public String getPosition() {
        return position;
    }

    @JsonProperty("Position")
    public void setPosition(String position) {
        this.position = position;
    }

    @JsonProperty("HighestDrugEvidenceLevel")
    public String getHighestDrugEvidenceLevel() {
        return highestDrugEvidenceLevel;
    }

    @JsonProperty("HighestDrugEvidenceLevel")
    public void setHighestDrugEvidenceLevel(String highestDrugEvidenceLevel) {
        this.highestDrugEvidenceLevel = highestDrugEvidenceLevel;
    }

    @JsonProperty("Classification")
    public String getClassification() {
        return classification;
    }

    @JsonProperty("Classification")
    public void setClassification(String classification) {
        this.classification = classification;
    }

    @JsonProperty("FunctionImpact")
    public String getFunctionImpact() {
        return functionImpact;
    }

    @JsonProperty("FunctionImpact")
    public void setFunctionImpact(String functionImpact) {
        this.functionImpact = functionImpact;
    }

    @JsonProperty("IsOncogene")
    public Boolean getIsOncogene() {
        return isOncogene;
    }

    @JsonProperty("IsOncogene")
    public void setIsOncogene(Boolean isOncogene) {
        this.isOncogene = isOncogene;
    }

    @JsonProperty("Score")
    public Double getScore() {
        return score;
    }

    @JsonProperty("Score")
    public void setScore(Double score) {
        this.score = score;
    }

    @JsonProperty("GeneAnnotation")
    public String getGeneAnnotation() {
        return geneAnnotation;
    }

    @JsonProperty("GeneAnnotation")
    public void setGeneAnnotation(String geneAnnotation) {
        this.geneAnnotation = geneAnnotation;
    }

    @JsonProperty("Variants")
    public List<Variant> getVariants() {
        return variants;
    }

    @JsonProperty("Variants")
    public void setVariants(List<Variant> variants) {
        this.variants = variants;
    }

    @JsonProperty("VariantInfoList")
    public String getVariantInfoList() {
        return variantInfoList;
    }

    @JsonProperty("VariantInfoList")
    public void setVariantInfoList(String variantInfoList) {
        this.variantInfoList = variantInfoList;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(Gene.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('[');
        sb.append("geneName");
        sb.append('=');
        sb.append(((this.geneName == null)?"<null>":this.geneName));
        sb.append(',');
        sb.append("geneSummary");
        sb.append('=');
        sb.append(((this.geneSummary == null)?"<null>":this.geneSummary));
        sb.append(',');
        sb.append("simplifiedGeneSummary");
        sb.append('=');
        sb.append(((this.simplifiedGeneSummary == null)?"<null>":this.simplifiedGeneSummary));
        sb.append(',');
        sb.append("simplifiedGeneSummaryWithGermline");
        sb.append('=');
        sb.append(((this.simplifiedGeneSummaryWithGermline == null)?"<null>":this.simplifiedGeneSummaryWithGermline));
        sb.append(',');
        sb.append("chromosome");
        sb.append('=');
        sb.append(((this.chromosome == null)?"<null>":this.chromosome));
        sb.append(',');
        sb.append("primaryTranscript");
        sb.append('=');
        sb.append(((this.primaryTranscript == null)?"<null>":this.primaryTranscript));
        sb.append(',');
        sb.append("position");
        sb.append('=');
        sb.append(((this.position == null)?"<null>":this.position));
        sb.append(',');
        sb.append("highestDrugEvidenceLevel");
        sb.append('=');
        sb.append(((this.highestDrugEvidenceLevel == null)?"<null>":this.highestDrugEvidenceLevel));
        sb.append(',');
        sb.append("classification");
        sb.append('=');
        sb.append(((this.classification == null)?"<null>":this.classification));
        sb.append(',');
        sb.append("functionImpact");
        sb.append('=');
        sb.append(((this.functionImpact == null)?"<null>":this.functionImpact));
        sb.append(',');
        sb.append("isOncogene");
        sb.append('=');
        sb.append(((this.isOncogene == null)?"<null>":this.isOncogene));
        sb.append(',');
        sb.append("score");
        sb.append('=');
        sb.append(((this.score == null)?"<null>":this.score));
        sb.append(',');
        sb.append("geneAnnotation");
        sb.append('=');
        sb.append(((this.geneAnnotation == null)?"<null>":this.geneAnnotation));
        sb.append(',');
        sb.append("variants");
        sb.append('=');
        sb.append(((this.variants == null)?"<null>":this.variants));
        sb.append(',');
        sb.append("variantInfoList");
        sb.append('=');
        sb.append(((this.variantInfoList == null)?"<null>":this.variantInfoList));
        sb.append(',');
        if (sb.charAt((sb.length()- 1)) == ',') {
            sb.setCharAt((sb.length()- 1), ']');
        } else {
            sb.append(']');
        }
        return sb.toString();
    }

    @Override
    public int hashCode() {
        int result = 1;
        result = ((result* 31)+((this.chromosome == null)? 0 :this.chromosome.hashCode()));
        result = ((result* 31)+((this.isOncogene == null)? 0 :this.isOncogene.hashCode()));
        result = ((result* 31)+((this.geneSummary == null)? 0 :this.geneSummary.hashCode()));
        result = ((result* 31)+((this.simplifiedGeneSummary == null)? 0 :this.simplifiedGeneSummary.hashCode()));
        result = ((result* 31)+((this.functionImpact == null)? 0 :this.functionImpact.hashCode()));
        result = ((result* 31)+((this.variants == null)? 0 :this.variants.hashCode()));
        result = ((result* 31)+((this.classification == null)? 0 :this.classification.hashCode()));
        result = ((result* 31)+((this.score == null)? 0 :this.score.hashCode()));
        result = ((result* 31)+((this.geneName == null)? 0 :this.geneName.hashCode()));
        result = ((result* 31)+((this.highestDrugEvidenceLevel == null)? 0 :this.highestDrugEvidenceLevel.hashCode()));
        result = ((result* 31)+((this.position == null)? 0 :this.position.hashCode()));
        result = ((result* 31)+((this.geneAnnotation == null)? 0 :this.geneAnnotation.hashCode()));
        result = ((result* 31)+((this.simplifiedGeneSummaryWithGermline == null)? 0 :this.simplifiedGeneSummaryWithGermline.hashCode()));
        result = ((result* 31)+((this.primaryTranscript == null)? 0 :this.primaryTranscript.hashCode()));
        result = ((result* 31)+((this.variantInfoList == null)? 0 :this.variantInfoList.hashCode()));
        return result;
    }

    @Override
    public boolean equals(Object other) {
        if (other == this) {
            return true;
        }
        if ((other instanceof Gene) == false) {
            return false;
        }
        Gene rhs = ((Gene) other);
        return ((((((((((((((((this.chromosome == rhs.chromosome)||((this.chromosome!= null)&&this.chromosome.equals(rhs.chromosome)))&&((this.isOncogene == rhs.isOncogene)||((this.isOncogene!= null)&&this.isOncogene.equals(rhs.isOncogene))))&&((this.geneSummary == rhs.geneSummary)||((this.geneSummary!= null)&&this.geneSummary.equals(rhs.geneSummary))))&&((this.simplifiedGeneSummary == rhs.simplifiedGeneSummary)||((this.simplifiedGeneSummary!= null)&&this.simplifiedGeneSummary.equals(rhs.simplifiedGeneSummary))))&&((this.functionImpact == rhs.functionImpact)||((this.functionImpact!= null)&&this.functionImpact.equals(rhs.functionImpact))))&&((this.variants == rhs.variants)||((this.variants!= null)&&this.variants.equals(rhs.variants))))&&((this.classification == rhs.classification)||((this.classification!= null)&&this.classification.equals(rhs.classification))))&&((this.score == rhs.score)||((this.score!= null)&&this.score.equals(rhs.score))))&&((this.geneName == rhs.geneName)||((this.geneName!= null)&&this.geneName.equals(rhs.geneName))))&&((this.highestDrugEvidenceLevel == rhs.highestDrugEvidenceLevel)||((this.highestDrugEvidenceLevel!= null)&&this.highestDrugEvidenceLevel.equals(rhs.highestDrugEvidenceLevel))))&&((this.position == rhs.position)||((this.position!= null)&&this.position.equals(rhs.position))))&&((this.geneAnnotation == rhs.geneAnnotation)||((this.geneAnnotation!= null)&&this.geneAnnotation.equals(rhs.geneAnnotation))))&&((this.simplifiedGeneSummaryWithGermline == rhs.simplifiedGeneSummaryWithGermline)||((this.simplifiedGeneSummaryWithGermline!= null)&&this.simplifiedGeneSummaryWithGermline.equals(rhs.simplifiedGeneSummaryWithGermline))))&&((this.primaryTranscript == rhs.primaryTranscript)||((this.primaryTranscript!= null)&&this.primaryTranscript.equals(rhs.primaryTranscript))))&&((this.variantInfoList == rhs.variantInfoList)||((this.variantInfoList!= null)&&this.variantInfoList.equals(rhs.variantInfoList))));
    }

}

Я получаю следующую ошибку:

Исключение в потоке "main" java .lang.reflect.InaccessibleObjectException: Невозможно сделать общедоступным молекулярный.generated.Gene () доступным: модуль WfGJsonParser не "экспортирует молекулярный.генерированный" в модуль com.faster xml .jackson.databind в java .base / java .lang.reflect.AccessibleObject.checkCanSetAccessible (AccessibleObject. java: 341) в java .base / java .lang.reflect.AccessibleObject.checkCanSetA AccessibleObject. java: 281) в java .base / java .lang.reflect.Constructor.checkCanSetAccessible (Constructor. java: 189) в java .base / java .lang.reflect. Constructor.setAccessible (Конструктор. java: 182) на com.fa ster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.util.ClassUtil.checkAndFixAccess (ClassUtil. java: 914) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.deser.impl.CreatorCollector._fixAccess (CreatorCollector. java: 271) на com.faster xml .jackson . databind@2.9.9/com.fasterxml.jackson.databind.deser.impl.CreatorCollector.setDefaultCreator (CreatorCollector. java: 131) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.deser.BasicDeserializerFactory._addDeserializerConstructors (BasicDeserializerFactory. java: 452) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.deser.BasicDeserializerFactory._constructDefaultValueInstantiator (BasicDeserializerFactory . java: 352) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findValueInstantiator (BasicDeserializerFactory. java: 269) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer (BeanDeserializerFactory. java: 214 ) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer (BeanDeserializerFactory. java: 137) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2 (DeserializerCache. java: 411) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer (DeserializerCache. java: 349) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2 (DeserializerCache. java: 264) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer (DeserializerCache. java: 244) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer (DeserializerCache. java: 142) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer (DeserializationContext. java: 477) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer (ObjectMapper. java: 4190) на com.fas ter xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose (ObjectMapper. java: 4009) на com.faster xml .jackson. databind@2.9.9/com.fasterxml.jackson.databind.ObjectMapper.readValue (ObjectMapper. java: 2902) на WfGJsonParser / молекулярный.JSonParser. (JSonParser . java: 39) в WfGJsonParser / молекулярный. WfGMain.main (WfGMain. java: 30)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...