BOnjour,

Je suis en train de développer une appli web contenant aussi des Web Services. Mon projet s'organise de cette manière

- (Client)
- (Core)
- (Serveur)

Ces trois projets utilisent Maven, donc mon serveur dépend du Core et pareil pour le Client.
Mon serveur accède à une base de données via Hibernate.

Mais mon problème est que lorsque je souhaite envoyer certains objets via mon web service, j'ai un problème de cycle dans le graphe. Voici les classes où j'ai mon problème :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
 
package core.object.application;
 
import java.util.Date;
import java.util.List;
 
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
 
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
 
import core.object.BasicRefObject;
import core.object.system.User;
 
@Entity
@Table(name = "Voltage")
@XmlRootElement()
public class Voltage extends BasicRefObject {
	private static final long serialVersionUID = -7590340638662303349L;
 
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id", nullable = false)
	private long id;
 
	@ManyToOne
	@JoinColumn(name = "creator", nullable = false)
	private User creator;
 
	@Column(name = "creationDate", nullable = false)
	private Date creationDate;
 
	@Column(name = "reference", nullable = false, unique = true)
	private String reference;
 
	@Column(name = "description", nullable = false)
	private String description;
 
	@LazyCollection(LazyCollectionOption.FALSE)
	@OneToMany(mappedBy = "voltage")
	private List<VoltageValue> voltageValueList;
 
	public long getId() {
		return id;
	}
 
	public void setId(long id) {
		this.id = id;
	}
 
	public User getCreator() {
		return creator;
	}
 
	public void setCreator(User creator) {
		this.creator = creator;
	}
 
	public Date getCreationDate() {
		return creationDate;
	}
 
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}
 
	public String getReference() {
		return reference;
	}
 
	public void setReference(String reference) {
		this.reference = reference;
	}
 
	public String getDescription() {
		return description;
	}
 
	public void setDescription(String description) {
		this.description = description;
	}
 
	public List<VoltageValue> getVoltageValueList() {
		return voltageValueList;
	}
 
	public void setVoltageValueList(List<VoltageValue> voltageValueList) {
		this.voltageValueList = voltageValueList;
	}
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 
package core.object.application;
 
import java.util.Date;
 
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
 
import org.eclipse.persistence.oxm.annotations.XmlInverseReference;
 
import core.object.BasicObject;
import core.object.system.User;
 
@Entity
@Table(name = "VoltageValue")
public class VoltageValue extends BasicObject {
	/**
         * 
         */
	private static final long serialVersionUID = 5563489030736775097L;
 
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id", nullable = false)
	private long id;
 
	@ManyToOne
	@JoinColumn(name = "creator", nullable = false)
	private User creator;
 
	@Column(name = "creationDate", nullable = false)
	private Date creationDate;
 
	@ManyToOne
	@JoinColumn(name = "voltage", nullable = false)
	@XmlInverseReference(mappedBy = "voltageValueList")
	private Voltage voltage;
 
	@ManyToOne
	@JoinColumn(name = "torque", nullable = false)
	private Torque torque;
 
	@ManyToOne
	@JoinColumn(name = "typeOfVoltageValue", nullable = false)
	private TypeOfVoltageValue typeOfVoltageValue;
 
	@Column(name = "frequency", nullable = false)
	private double frequency;
 
	@Column(name = "value", nullable = false)
	private double value;
 
	public long getId() {
		return id;
	}
 
	public void setId(long id) {
		this.id = id;
	}
 
	public User getCreator() {
		return creator;
	}
 
	public void setCreator(User creator) {
		this.creator = creator;
	}
 
	public Date getCreationDate() {
		return creationDate;
	}
 
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}
 
	public Voltage getVoltage() {
		return voltage;
	}
 
	public void setVoltage(Voltage voltage) {
		this.voltage = voltage;
	}
 
	public Torque getTorque() {
		return torque;
	}
 
	public void setTorque(Torque torque) {
		this.torque = torque;
	}
 
	public double getFrequency() {
		return frequency;
	}
 
	public void setFrequency(double frequency) {
		this.frequency = frequency;
	}
 
	public double getValue() {
		return value;
	}
 
	public void setValue(double value) {
		this.value = value;
	}
 
	public TypeOfVoltageValue getTypeOfVoltageValue() {
		return typeOfVoltageValue;
	}
 
	public void setTypeOfVoltageValue(TypeOfVoltageValue typeOfVoltageValue) {
		this.typeOfVoltageValue = typeOfVoltageValue;
	}
}
Je comprend bien d'où vient le problème, j'ai donc décidé d'installer MOXy. Pour cela j'ai créé un fichier jaxb.properties dans le serveur, dans le repertoire src/main/resources et j'ai configuré Maven pour l'inclure

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
 
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<version>2.5</version>
				<executions>
					<execution>
						<id>copy-resources</id>
						<phase>validate</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${basedir}\target\${project.build.finalName}\WEB-INF\classes\</outputDirectory>
							<resources>
								<resource>
									<directory>${basedir}\src\main\resources\</directory>
									<includes>
										<include>jaxb.properties</include>
									</includes>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
Mais cela ne fonctionne pas. Quelqu'un aurait-il une idée ?