Updated OpenLDBWS and OpenLDBSVWS examples in Java

85 views
Skip to first unread message

Peter Hicks

unread,
Dec 2, 2018, 6:04:48 AM12/2/18
to A gathering place for the Open Rail Data community
All,

FYI - I've released version 1.0.1 of the OpenLDBWS/OpenLDBSVWS examples at https://github.com/openraildata/openldbws-example-java and https://github.com/openraildata/openldbsvws-example-java/.

There are minimal changes:

  * Replaced deprecated logging interceptors
  * Added SLF4J logging framework
  * Added Maven compiler plugin
  * Removed unused imports
  * Cleaned up exceptions thrown


Peter



OpenTrainTimes Ltd. registered in England and Wales, company no. 09504022.
Registered office: 13a Davenant Road, Upper Holloway, London N19 3NW

Michael Flynn

unread,
Dec 3, 2018, 6:15:57 AM12/3/18
to A gathering place for the Open Rail Data community
Hi Peter,

I still can't run your example on the command line without adding the -xjc-npa argument which generates the extra namespace entries in the classes. The generated sources are different with or without the extra argument.  So, for example, in 'thalesgroup/rtti/_2012_01_13/ldb/types/ ~/tmp/java/xa/CallingPoint.java';

= = without = = >
..
@XmlType(name = "CallingPoint", propOrder = {
    "locationName",
    "crs",
    "st",
    "et",
    "at",
    "adhocAlerts"
})
public class CallingPoint {

    @XmlElement(required = true)
    protected String locationName;
    @XmlElement(required = true)
    protected String crs;
    protected String st;
    protected String et;
    protected String at;
    protected ArrayOfAdhocAlert adhocAlerts;
..

= = with = = >
..
@XmlType(name = "CallingPoint", namespace = "http://thalesgroup.com/RTTI/2012-01-13/ldb/types", propOrder = {
    "locationName",
    "crs",
    "st",
    "et",
    "at",
    "adhocAlerts"
})
public class CallingPoint {

    @XmlElement(namespace = "http://thalesgroup.com/RTTI/2012-01-13/ldb/types", required = true)
    protected String locationName;
    @XmlElement(namespace = "http://thalesgroup.com/RTTI/2012-01-13/ldb/types", required = true)
    protected String crs;
    @XmlElement(namespace = "http://thalesgroup.com/RTTI/2012-01-13/ldb/types")
    protected String st;
    @XmlElement(namespace = "http://thalesgroup.com/RTTI/2012-01-13/ldb/types")
    protected String et;
    @XmlElement(namespace = "http://thalesgroup.com/RTTI/2012-01-13/ldb/types")
    protected String at;
    @XmlElement(namespace = "http://thalesgroup.com/RTTI/2012-01-13/ldb/types")
    protected ArrayOfAdhocAlert adhocAlerts;
..

After generating the sources I compile and run (I again just commented out the  debugging code for this example) as so;

javac -cp src/main/java:~/tmp/java/lib/cxf/apache-cxf-3.2.7/lib/cxf-core-3.2.7.jar:/usr/share/java/slf4j/slf4j-api.jar src/main/java/com/openraildata/GetDepartureBoardExample.java 

java -cp src/main/java:~/tmp/java/lib/cxf/apache-cxf-3.2.7/lib/cxf-core-3.2.7.jar:/usr/share/java/slf4j/slf4j-api.jar:/usr/share/java/slf4j/slf4j-simple.jar com/openraildata/GetDepartureBoardExample

(Ordinarily I'd add for the debug code and arrange my CLASSPATH better.)

The code without the generated namespaces fails with;

"
Exception in thread "main" com.sun.xml.internal.ws.spi.db.DatabindingException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 39 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://thalesgroup.com/RTTI/2017-10-01/ldb/}BaseServiceItem". Use @XmlType.name and @XmlType.namespace to assign different names to them.
..
etc..
"

The code with runs with the nice list, eg.;

"
[main] INFO com.openraildata.GetDepartureBoardExample - Trains at London Euston
[main] INFO com.openraildata.GetDepartureBoardExample - ===============================================================================
[main] INFO com.openraildata.GetDepartureBoardExample - 10:10 to Chester - Delayed
[main] INFO com.openraildata.GetDepartureBoardExample - 10:20 to Manchester Piccadilly - Delayed
[main] INFO com.openraildata.GetDepartureBoardExample - 10:30 to Glasgow Central - On time
..
..etc..
"

I know the code runs 'without the argument' in both Netbeans and Eclipse.  I just don't how.  Any idea what's happening?  I'm still a bit of a newbie with Maven, Netbeans and Eclipse and, to be honest, Java.  For me though, I want the backstop (uugh, sorry;) of being able to compile and run without the IDE's.  Or at least know why and how they run cleanly in the IDE's without the additional generated namespace info.

Peter Hicks

unread,
Dec 3, 2018, 6:33:23 AM12/3/18
to Michael Flynn, A gathering place for the Open Rail Data community
Hi Mike

Are you following the instructions in the README and using Maven, or are you trying to replicate what Maven does by hand?

What if you run 'mvn clean install' and run java -jar target/<filename>.jar?

The likes of Maven, Gradle and other dependency managers exist so we don't have to download .jar files and assemble code on the command line by hand.


Peter

--
You received this message because you are subscribed to the Google Groups "A gathering place for the Open Rail Data community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openraildata-t...@googlegroups.com.
To post to this group, send email to openrail...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Flynn

unread,
Dec 3, 2018, 7:34:05 AM12/3/18
to A gathering place for the Open Rail Data community
Ah, "mvn clean install", rings a bell!  But only a bell, I did a Maven tutorial a while back...

>> The likes of Maven, Gradle and other dependency managers exist so we don't have to 
download .jar files and assemble code on the command line by hand.

This also rings a bell :)

I'll tell you what, Peter, you're right and I do need to read that tutorial again.  I would just say though the README is a bit scant on detail.  But I know there is a balance between having something spelled out and finding out for yourself.  I'm already far better versed with Maven.  

So now I could either run on command line with my, albeit convoluted compile and run, or just click the 'Build' button in an IDE (if nothing else the <extendedSoapHeader> saves me a load of work) or read up on Maven/Gradle.. 

Cheers
Mike
Reply all
Reply to author
Forward
0 new messages