0

Hey, Guys. J'ai une erreur quand je fais mvn wildfly: déployer. J'utilise wildfly 10.1.0.Final, hibernate ogm 5.0.10.Final et Cassandra 3.0.9. Voici le massage d'erreur complète:Erreur lors de la commande mvn wildfly: deploy: impossible de déterminer le rôle côté principal de la collection com.sensorhound.aigateway.domain.IOConfiguration.nodeData

[ERREUR] Impossible d'exécuter but org.wildfly.plugins: wildfly-maven-plugin: 1.1.0.Final: déployer (default-cli) sur le projet aigateway: Impossible d'exécuter le déploiement de l'objectif: {"WFLYCTL0062: L'opération composite a échoué et a été annulée Étapes ayant échoué:" => {"Opération step-1" => {"WFLYCTL0080: Echec services" => {"jboss. persistenceunit. "aigateway.war # JPAService \" "=> " org.jboss.msc.service.StartException en service jboss.persistenceunit. \ "aigateway.war # JPAService \": javax.persistence.PersistenceException: [ PersistenceUnit: JPAService] Impossible de construire SessionFactory Hibernate [ERREUR] Causée par: javax.persistence.PersistenceException: [PersistenceUnit: JPAService] Impossible de construire SessionFactory Hibernate [ERREUR] Causée par: org.hibernate.HibernateException: Impossible de déterminer le rôle principal de côté pour la collecte com.sensorhound.aigateway.domain.IOConfiguration.nodeData "}," WFLYCTL0412: services obligatoires qui ne sont pas installés: »=> [ " jboss.persistenceunit \" # aigateway.war JPAService \ ""] , "WFLYCTL0180: Services avec des dépendances manquantes/indisponibles" => undefined}}} [ERREUR] -> [Aide 1] [ERREUR] [ERREUR] Pour voir la trace complète de les erreurs, réexécutez Maven avec le commutateur -e. [ERREUR] Réexécutez Maven en utilisant le commutateur -X pour activer la journalisation complète du débogage. [ERREUR] [ERREUR] Pour plus d'informations sur les erreurs et les solutions possibles, s'il vous plaît lire les articles suivants: [ERREUR] [Aide 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Voici le code pour la table "IO_CONFIGURATION":

@Entity 
@Indexed 
@Table(name = "IO_CONFIGURATION") 
public class IOConfiguration implements Serializable { 

    private static final long serialVersionUID = 7542743172221933818L; 

    @Id 
    @Column(name = "IO_CONFIGURATION_ID") 
    protected String ioConfigurationId; 

    @Column(name = "ACTIVE") 
    protected Boolean active; 

    @Column(name = "NAME") 
    protected String name; 

    @Column(name = "CONVERSION_TYPE") 
    protected String conversionType; 

    @Column(name = "M_INFO") 
    protected Double mInfo; 

    @Column(name = "B_INFO") 
    protected Double bInfo; 

    @Column(name = "VOLTAGE_DIVIDE") 
    protected String voltageDivide; 

    @Column(name = "SAMPLE_RANGE") 
    protected String sampleRange; 

    @Column(name = "SAMPLE_PERIOD") 
    protected Integer samplePeriod; 

    @Column(name = "STORE_ROW") 
    protected Boolean storeRow; 

    @Column(name = "STORE_CONVERTED") 
    protected Boolean storeConverted; 

    @Column(name = "DEFAULT_GRAPH") 
    protected String defaultGraph; 

    @Column(name = "TITLE") 
    protected String title; 

    @Column(name = "UNIT") 
    protected String unit; 

    @Column(name = "RANGE_LOWERBOUND") 
    protected Integer rangeLowerbound; 

    @Column(name = "RANGE_UPPERBOUND") 
    protected Integer rangeUpperbound; 

    @JsonBackReference 
    @OneToMany(mappedBy = "ioConfiguration") 
    protected List<Alert> alerts; 

    @JsonBackReference 
    @OneToMany(mappedBy = "ioConfiguration") 
    protected List<DataSeriesMeta> dataSeriesMeta; 

    @JsonBackReference 
    @OneToMany(mappedBy = "ioConfiguration") 
    protected List<NodeData> nodeData; 

    @Column(name = "CODE") 
    protected String code; 

    public IOConfiguration() {} 
    //...getters and setter 
} 

Voici le code de table "NODE_DATA":

@Entity 
@Indexed 
@IdClass(NodeDataPK.class) 
@Table(name = "NODE_DATA") 
public class NodeData implements Serializable { 

    private static final long serialVersionUID = -3411753713406246973L; 

    @Id 
    @FieldBridge(impl = ByteBridge.class) 
    @JoinColumn(name = "IO_CONFIGURATION_ID", referencedColumnName = "IO_CONFIGURATION_ID") 
    @ManyToOne 
    protected IOConfiguration ioConfiguration; 

    @Id 
    @Column(name = "TIME") 
    protected Long time; 

    @Column(name = "VALUE") 
    protected Double value; 

    public NodeData() {} 

    public NodeDataPK getNodeDataId() { 
    NodeDataPK nodeDataPK = new NodeDataPK(); 
    nodeDataPK.setTime(this.time); 
    nodeDataPK.setIoConfigurationId(this.ioConfiguration.getIoConfigurationId()); 
    return nodeDataPK; 
    } 

    public void setNodeDataId(NodeDataPK nodeDataPK) { 
    this.time = nodeDataPK.getTime(); 
    IOConfigurationDAO ioConfigurationDAO = new IOConfigurationDAO(); 
    ioConfigurationDAO.init(); 
    IOConfiguration ioConfiguration = 
     ioConfigurationDAO.findIOConfiguration(nodeDataPK.getIoConfigurationId()); 
    this.ioConfiguration = ioConfiguration; 
    } 



    /** 
    * @return the ioConfiguration 
    */ 
    public IOConfiguration getIoConfiguration() { 
    return ioConfiguration; 
    } 

    /** 
    * @param ioConfiguration the ioConfiguration to set 
    */ 
    public void setIoConfiguration(IOConfiguration ioConfiguration) { 
    this.ioConfiguration = ioConfiguration; 
    } 

    /** 
    * @return the time 
    */ 
    public Long getTime() { 
    return time; 
    } 

    /** 
    * @param time the time to set 
    */ 
    public void setTime(Long time) { 
    this.time = time; 
    } 

    /** 
    * @return the value 
    */ 
    public double getValue() { 
    return value; 
    } 

    /** 
    * @param value the value to set 
    */ 
    public void setValue(double value) { 
    this.value = value; 
    } 

    /** 
    * @return the serialversionuid 
    */ 
    public static long getSerialversionuid() { 
    return serialVersionUID; 
    } 
} 

Voici la clé primaire composite pour NodeData e ntity:

public class NodeDataPK implements Serializable { 

    /** 
    * 
    */ 
    private static final long serialVersionUID = -3239860594324151192L; 

    // @Column(name = "IO_CONFIGURATION") 
    protected String ioConfiguration; 

    // @Column(name = "TIME") 
    protected Long time; 

    public NodeDataPK() {} 

    public NodeDataPK(String ioConfigId, Long time) { 
    this.ioConfiguration = ioConfigId; 
    this.time = time; 
    } 

    /** 
    * @return the channelName 
    */ 
    public String getIoConfigurationId() { 
    return ioConfiguration; 
    } 

    /** 
    * @param channelName the channelName to set 
    */ 
    public void setIoConfigurationId(String ioConfigurationId) { 
    this.ioConfiguration = ioConfigurationId; 
    } 

    /** 
    * @return the time 
    */ 
    public Long getTime() { 
    return time; 
    } 

    /** 
    * @param time the time to set 
    */ 
    public void setTime(Long time) { 
    this.time = time; 
    } 

    @Override 
    public int hashCode() { 
    return ioConfiguration.hashCode() + time.hashCode(); 
    } 

    @Override 
    public boolean equals(Object o) { 
    if (o == null) { 
     return false; 
    } 
    if (!(o instanceof NodeDataPK)) { 
     return false; 
    } 
    NodeDataPK nodeDataPK = (NodeDataPK) o; 
    if (((NodeDataPK) o).getIoConfigurationId() != nodeDataPK.getIoConfigurationId() 
     && ((NodeDataPK) o).getTime() != nodeDataPK.getTime()) { 
     return false; 
    } 

    return true; 
    } 
} 

Et voici le ByteBridge je copiais:

public class ByteBridge extends NumberBridge implements Serializable { 
    @Override 
    public Object stringToObject(String stringValue) { 
    if (StringHelper.isEmpty(stringValue)) 
     return null; 
    return Byte.valueOf(stringValue); 
    } 
} 

Je ne sais pas ce qui se passe, et il y a peu de message sur cette erreur quand je google. Si vous avez besoin d'informations, je suis prêt à partager. Quelqu'un m'aide s'il vous plait.

Merci!

Répondre

0

les gars, j'ai résolu ce problème en utilisant EmbeddedId. Selon la documentation de JPA, IdClass et EmbeddedId devraient atteindre le même objectif. Mais je ne peux pas trouver ce qui ne va pas avec ma version IdClass. Donc je passe juste à EmbeddedId et ça marche. Voici le code modifié:

@Embeddable 
public class NodeDataPK implements Serializable { 

    /** 
    * 
    */ 
    private static final long serialVersionUID = -3239860594324151192L; 


    protected String ioConfiguration; 

    @Column(name = "TIME") 
    protected Long time; 

    public NodeDataPK() {} 

    public NodeDataPK(String ioConfigId, Long time) { 
    this.ioConfiguration = ioConfigId; 
    this.time = time; 
    } 

    /** 
    * @return the channelName 
    */ 
    public String getIoConfiguration() { 
    return ioConfiguration; 
    } 

    /** 
    * @param channelName the channelName to set 
    */ 
    public void setIoConfiguration(String ioConfigurationId) { 
    this.ioConfiguration = ioConfigurationId; 
    } 

    /** 
    * @return the time 
    */ 
    public Long getTime() { 
    return time; 
    } 

    /** 
    * @param time the time to set 
    */ 
    public void setTime(Long time) { 
    this.time = time; 
    } 

    @Override 
    public int hashCode() { 
    return ioConfiguration.hashCode() + time.hashCode(); 
    } 

    @Override 
    public boolean equals(Object o) { 
    if (o == null) { 
     return false; 
    } 
    if (!(o instanceof NodeDataPK)) { 
     return false; 
    } 
    NodeDataPK nodeDataPK = (NodeDataPK) o; 
    if (((NodeDataPK) o).getIoConfiguration() != nodeDataPK.getIoConfiguration() 
     && ((NodeDataPK) o).getTime() != nodeDataPK.getTime()) { 
     return false; 
    } 

    return true; 
    } 
} 

@Entity 
@Indexed 
// @IdClass(NodeDataPK.class) 
@Table(name = "NODE_DATA") 
public class NodeData implements Serializable { 

    private static final long serialVersionUID = -3411753713406246973L; 

    // @Id 
    // @FieldBridge(impl = ByteBridge.class) 
    // @JoinColumn(name = "IO_CONFIGURATION_ID", referencedColumnName = "IO_CONFIGURATION_ID") 
    // @ManyToOne 
    // @JsonManagedReference 
    // protected IOConfiguration ioConfiguration; 
    // 
    // @Id 
    // @Column(name = "TIME") 
    // protected Long time; 

    @DocumentId 
    @EmbeddedId 
    @FieldBridge(impl = ByteBridge.class) 
    protected NodeDataPK nodeDataPK; 

    @JoinColumn(name = "IO_CONFIGURATION") 
    @MapsId("ioConfiguration") 
    @ManyToOne 
    protected IOConfiguration ioConfiguration; 

    @Column(name = "VALUE") 
    protected Double value; 

    public NodeData() {} 

    // public NodeDataPK getNodeDataId() { 
    // NodeDataPK nodeDataPK = new NodeDataPK(); 
    // nodeDataPK.setTime(this.time); 
    // nodeDataPK.setIoConfiguration(this.ioConfiguration.getIoConfigurationId()); 
    // return nodeDataPK; 
    // } 
    // 
    // public void setNodeDataId(NodeDataPK nodeDataPK) { 
    // this.time = nodeDataPK.getTime(); 
    // IOConfigurationDAO ioConfigurationDAO = new IOConfigurationDAO(); 
    // ioConfigurationDAO.init(); 
    // IOConfiguration ioConfiguration = 
    // ioConfigurationDAO.findIOConfiguration(nodeDataPK.getIoConfiguration()); 
    // this.ioConfiguration = ioConfiguration; 
    // } 

    public NodeDataPK getNodeDataId() { 
    return this.nodeDataPK; 
    } 

    public void setNodeDataId(NodeDataPK nodeDataPK) { 
    this.nodeDataPK = nodeDataPK; 
    } 



    /** 
    * @return the ioConfiguration 
    */ 
    public IOConfiguration getIoConfiguration() { 
    return ioConfiguration; 
    } 

    /** 
    * @param ioConfiguration the ioConfiguration to set 
    */ 
    public void setIoConfiguration(IOConfiguration ioConfiguration) { 
    this.ioConfiguration = ioConfiguration; 
    } 

    // /** 
    // * @return the time 
    // */ 
    // public Long getTime() { 
    // return time; 
    // } 
    // 
    // /** 
    // * @param time the time to set 
    // */ 
    // public void setTime(Long time) { 
    // this.time = time; 
    // } 

    public Long getTime() { 
    return this.getNodeDataId().getTime(); 
    } 

    public void setTime(Long time) { 
    this.getNodeDataId().setTime(time); 
    } 

    /** 
    * @return the value 
    */ 
    public double getValue() { 
    return value; 
    } 

    /** 
    * @param value the value to set 
    */ 
    public void setValue(double value) { 
    this.value = value; 
    } 

    /** 
    * @return the serialversionuid 
    */ 
    public static long getSerialversionuid() { 
    return serialVersionUID; 
    } 



}