Closed GoogleCodeExporter closed 9 years ago
I don't check for this being not null because all the collections are meant to
be initialised to an empty ArrayList. It may be that I have missed one. Can you
tell me which relationship is giving the problem?
Steve
Original comment by dr.s.m.f...@gmail.com
on 8 Jul 2014 at 10:07
Strangely, this occurs when any one-two-many entity relationship is parsed, if
an Entity is _not_ associated with more than 0 items on the other side of the
relation.
If, in your context, the exception never occurs, then I think that the reason
may be somewhere in my JAX-WS generated proxy code used for SOAP requests.
For example, the relation between a Dataset and Datafiles is generated as
follows (extra code omitted):
public class Dataset extends EntityBaseBean {
@XmlElement(nillable = true)
protected List<Datafile> datafiles;
// no public no-args constructor generated: on default init datafiles = null !
public List<Datafile> getDatafiles() {
if (datafiles == null) {
datafiles = new ArrayList<Datafile>();
}
return this.datafiles;
}
// and there is no generated setter!
}
Of course, this code is very ugly: I won't speak here about the SRP violation
in the getter, due to the lazy init, nor about the weird "protected" access to
the field. And I still don't see how it can be worked around, as it is JAX-WS
generated (am I missing some config?).
I suppose that somewhere deep behind, the exception may be related with the
access to the objects using java.lang.reflect: the fields are null by default.
Would you please be so kind as to add the non-null check to the condition? It
does not make the routine heavier, it's just a matter of a single ifnull goto
in the bytecode afterwards...
Original comment by anton.te...@gmail.com
on 8 Jul 2014 at 10:38
If you are generating your own client from the WSDL then you need to hack the
wsdl first to get decent code out of it. My code for this is:
#!/bin/sh
url=$1
wget --no-proxy --no-check-certificate "$url"/ICATService/ICAT?wsdl -O ICAT.wsdl
wget --no-proxy --no-check-certificate "$url"/ICATService/ICAT?xsd=1 -O ICAT.xsd
sed s#"$url"/ICATService/ICAT?xsd=1#ICAT.xsd# ICAT.wsdl > ICAT.wsdl.new && mv
ICAT.wsdl.new ICAT.wsdl
sed 's#ref="tns:\([a-z]*\)"#name="\1" type="tns:\1"#' ICAT.xsd > ICAT.xsd.new
&& mv ICAT.xsd.new ICAT.xsd
however I suggest you just use the client that I generate.
This is the ICAT entity on the client side. The failure you are getting is on
the server side with objects generated from the SOAP XML generated by your
client. The SOAP generator can only call getDatafiles() which can never return
null
Given that this code works fine for others when invoked from C#, C++, Python
and Java clients I think you must be generating a bad SOAP message. I don't
want to add code which should never be invoked but prefer to find out what is
actually going wrong.
Please give my client a try and see if the problem goes away.
Steve
Original comment by dr.s.m.f...@gmail.com
on 8 Jul 2014 at 12:38
In the absence of further replies I am closing this one.
Steve
Original comment by dr.s.m.f...@gmail.com
on 11 Dec 2014 at 3:30
Original issue reported on code.google.com by
anton.te...@gmail.com
on 8 Jul 2014 at 8:15