Ошибка при выполнении mvn wildfly:deploy: не удалось определить основную побочную роль для коллекции com.sensorhound.aigateway.domain.IOConfiguration.nodeData


Эй, ребята. У меня возникает ошибка, когда я делаю mvn wildfly:deploy. Я использую wildfly 10.1.0.Final, hibernate ogm 5.0.10.Final и Cassandra 3.0.9. Вот полное сообщение об ошибке:

[ОШИБКА] Не удалось выполнить цель org.wildfly.plugins:wildfly-maven-plugin:1.1.0.Final:deploy (default-cli) в проекте aigateway: не удалось выполнить цель развертывания: {"WFLYCTL0062: составная операция не удалась и была выполнен откат. Неудачные шаги:" => {"Операция шаг-1" => {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"aigateway.war#JPAService\"" => "org.jboss .msc.service.StartException в службе jboss.persistenceunit.\"aigateway.war#JPAService\": javax.persistence.PersistenceException: [PersistenceUnit: JPAService] Невозможно построить Hibernate SessionFactory [ОШИБКА] Вызвано: javax.persistence.PersistenceException: [PersistenceUnit: JPAService] Невозможно построить Hibernate SessionFactory [ОШИБКА]. Причина: org.hibernate.HibernateException: не удалось определить главную побочную роль для коллекции com.sensorhound.aigateway.domain.IOConfiguration.nodeData"}", "WFLYCTL0412: необходимые службы которые не установлены:" => ["jboss.persistenceunit.\"aigateway.war#JPASe rvice\""],"WFLYCTL0180: Службы с отсутствующими/недоступными зависимостями" => undefined}}} [ОШИБКА] -> [Справка 1] [ОШИБКА] [ОШИБКА] Чтобы увидеть полную трассировку стека ошибок, перезапустите Maven с ключом -e. [ОШИБКА] Перезапустите Maven с параметром -X, чтобы включить полное ведение журнала отладки. [ОШИБКА] [ОШИБКА] Дополнительные сведения об ошибках и возможных решениях см. в следующих статьях: [ОШИБКА] [Справка 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Вот код для таблицы "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  
}  

Вот код для таблицы "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;  
  }  
}  

Вот составной первичный ключ для объекта NodeData:

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;  
  }  
}  

А вот и скопированный мной ByteBridge:

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

Я не знаю, что происходит, и когда я гуглю, появляется небольшое сообщение об этой ошибке. Если нужна информация, готов поделиться. Кто-нибудь, помогите мне, пожалуйста.

Спасибо!


person LebroNan    schedule 15.03.2017    source источник


Ответы (1)


ребята, я решил эту проблему с помощью EmbeddedId. Согласно документации JPA, IdClass и EmbeddedId должны достигать одной и той же цели. Но я не могу найти, что не так с моей версией IdClass. Поэтому я просто переключаюсь на EmbeddedId, и он работает. Вот модифицированный код:

@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;
  }



}
person LebroNan    schedule 17.03.2017