2

I can not seem to get moxy working with JAX-WS web services and hibernate. Despite what I do, @XMLInverseReference does not work. I'd expect it to fill in the application variable on a Site. What am I doing or understanding wrong?

I receive: org.hibernate.PropertyValueException: not-null property references a null or transient value: Site.application. If I add @XMLElement to Site.application, then I get a circular reference exception from JAXB.

It's worth mentioning all the marshaling and unmarshalling is handled by the JAX-WS WSServlet end point.

Also I verified my jaxb.properties is working correctly by doing the following:

public class Run {
    public static void main(String[] args) throws Exception {
        System.out.println(JAXBContext.newInstance(Site.class).getClass());
    }
}


Application:
@Entity
@Table(schema = "dbo", name = "Applications")
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class Application {
    @Id
    @Column(name = "id", nullable = false, insertable = false, updatable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @RemoteProperty
    @XmlElement
    private Integer id;
    @Column(name = "code", nullable = false, unique = true)
    @NaturalId
    @XmlElement
    private String code;
    @Column(name = "name")
    @XmlElement
    private String name;
    @OneToMany(mappedBy = "application", fetch = FetchType.EAGER)
    @Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
    @Cascade(value = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.DELETE, CascadeType.DELETE_ORPHAN})
    @Sort(type = SortType.NATURAL)
    @XmlElement
    private Set<Site> sites = new TreeSet<Site>();
}

Site:

@Entity
@Table(schema = "dbo", name = "Sites")
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class Site implements Identifiable<Integer>, Comparable<Site> {
    @Id
    @Column(name = "id", nullable = false, insertable = false, updatable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    @Column(name = "address", unique = true)
    @NaturalId(mutable = true)
    @XmlID
    private String address;
    @Column(name = "ssl")
    @XmlAttribute(required = true)
    private boolean ssl;
    @ManyToOne
    @JoinColumn(name = "applicationCode", nullable = false, referencedColumnName = "code")
    @XmlInverseReference(mappedBy = "code")
    private Application application;
}

jaxb.properties

javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
danieljimenez
  • 1,390
  • 4
  • 17
  • 26

1 Answers1

0

JAX-WS implementations do not necessarily respect the JAXB.properties. If you are using WebLogic 12.1.1 or GlassFish 3.1.2 the following will help:

bdoughan
  • 147,609
  • 23
  • 300
  • 400