Skip to content

How to run the Server Example from the Docs? #10

Description

@dancesWithCycles

Hi folks,
Thank you so much for offering this repo and all the cooperation by now. I am wondering if there is an initiative or a project out there that is using this repo. Do you know any?

I am also wondering what is the right way to get this repo running? Do you know how?

I am facing some obstacles when I copy the Server Example,

make it a deployable class like this,

package de.swingbe.oba_siri;

import com.google.inject.Guice;
import com.google.inject.Injector;
import org.onebusaway.guice.jsr250.LifecycleService;
import org.onebusaway.siri.core.SiriCoreModule;
import org.onebusaway.siri.core.SiriServer;
import org.onebusaway.siri.jetty.SiriJettyModule;
import uk.org.siri.siri.ServiceDelivery;

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) {
        System.out.println("Hello world!");

        // Configure the Guice container
        List<Module> modules = new ArrayList<Module>();
        modules.addAll(SiriCoreModule.getModules());
        modules.add(new SiriJettyModule());
        Injector injector = Guice.createInjector(modules);

        SiriServer server = injector.getInstance(SiriServer.class);
        // Set our SIRI identity
        server.setIdentify("me");
        // Change the port and url we listen to for incoming client requests
        server.setUrl("http://*:8080/server.xml");

        // Start the client
        LifecycleService lifecycleService = injector.getInstance(LifecycleService.class);
        lifecycleService.start();

        // Publish a ServiceDelivery
        ServiceDelivery delivery = new ServiceDelivery() server.puslish(delivery);

        System.out.println("Bye!");
        return;
    }
}

see these IDE complains,

Screenshot_2022-04-17_14-30-07
Screenshot_2022-04-17_14-29-43
Screenshot_2022-04-17_14-29-07

and use this pom.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

...

    <dependencies>
        <dependency>
            <groupId>org.onebusaway</groupId>
            <artifactId>onebusaway-siri-core</artifactId>
            <version>1.0.7-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.onebusaway</groupId>
            <artifactId>onebusaway-siri-jetty</artifactId>
            <version>1.0.7-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <!-- Target Java versions -->
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <filters>
                                <filter>
                                    <!-- exclude signatures from merged JAR to avoid invalid signature messages -->
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <!-- The shaded JAR will not be the main artifact for the project, it will be attached
                              for deployment in the way source and docs are. -->
                            <shadedArtifactAttached>true
                            </shadedArtifactAttached>
                            <shadedClassifierName>shaded</shadedClassifierName>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <manifestEntries>
                                        <Main-Class>de.swingbe.oba_siri.Main
                                        </Main-Class>
                                    </manifestEntries>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

I am appreciating every hint that makes this library hit the road.

Cheers!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions