그래서 현재 Java Web app 및 C# client app으로 구성된 시스템에서 작업하고 있습니다. 웹 응용 프로그램은 프로그램 클래스의 엔티티 객체를 반환 방법을 가지고 자바 웹 서비스를 가지고 :Jpa 엔터티에 대한 원격 액세스
@WebMethod(operationName = "getProgram")
public Program getProgram(@WebParam(name = "macAddress") String macAddress){
Device device = DeviceManager.getInstance().getDevice(macAddress);
if(device != null){
return device.getProgram();
}
return null;
}
많은 속성과 관계가 유형 프로그램이 반환 개체 :
@Entity
@Table(name = "PROGRAM", schema = "APP")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Program.getProgramsByWeather", query = "SELECT p FROM Program p WHERE p.weather = :weather")})
public class Program extends DbEntity implements Serializable {
private static final long serialVersionUID = 1L;
@JoinColumn(name = "LOGO_ID", referencedColumnName = "ID")
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch= FetchType.EAGER)
private Logo logo;
@JoinColumn(name = "WEATHER_ID", referencedColumnName = "ID")
@ManyToOne
private Weather weather;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "program", orphanRemoval = true)
private List<ProgramPlaylist> programPlaylistList = new ArrayList<>();
@OneToMany(cascade = CascadeType.ALL, mappedBy = "program", orphanRemoval = true)
private List<ProgramTicker> programTickerList = new ArrayList<>();
@Column(name = "UPDATED")
private boolean updated;
public Program() {
}
public Program(String name, AppUser owner) {
super(name, owner);
}
public Logo getLogo() {
return logo;
}
public void setLogo(Logo logo) {
this.logo = logo;
}
public Weather getWeather() {
return weather;
}
public void setWeather(Weather weather) {
this.weather = weather;
}
public boolean isUpdated() {
return updated;
}
public void setUpdated(boolean updated) {
this.updated = updated;
}
@XmlElement
public List<ProgramPlaylist> getProgramPlaylistList() {
return programPlaylistList;
}
@XmlElement
public List<ProgramTicker> getProgramTickerList() {
return programTickerList;
}
@Override
public String toString() {
return "Program[ id=" + getId() + " ]";
}
}
클라이언트 이 객체를 가져올 수 있으며 DbEntity에서 상속받은 program.name과 같은 클라이언트 응용 프로그램의 일부 속성에 액세스 할 수 있지만 다음과 같이 호출하려고 시도합니다.
program.logo.name
클라이언트에서 NullReferenceException을 발생시킵니다. programPlaylistList ArrayList의 요소를 반복 할 때도 같은 예외가 발생합니다.
클라이언트에 전달 된 개체 자체가 완전히로드되지 않았다고 가정합니다.
어떻게이 문제를 해결할 수 있습니까?
편집 좋아, 그래서 클라이언트가 서비스에서 얻을하고이 제대로하지만 어떤 이유로 오브젝트 필드가 채워지지 않습니다 주로 널 것을 XML 응답을 인쇄. 왜 이런 현상이 발생합니까?
누구? 나는 정말로 여기에 붙어있어 ... –