Hello World Component registration

42 views
Skip to first unread message

Alexander Schimpf

unread,
Jun 29, 2021, 8:02:07 PM6/29/21
to OpenMPF
Hello,

I am currently trying to get the Hello World Component registered and running on the workflow manager. when i run the command:
sudo docker run \
    --network openmpf_default \
    -v openmpf_shared_data:/opt/mpf/share \
    -e WFM_USER=admin \
    -e WFM_PASSWORD=mpfadm \
    hello world

I get an error regarding beans .BeansError.PNG
The component even though it gave errors registered itself to the workflow manager but when I run it, it stays at 0% and dosnt complete.

Any Idea on how to fix this issue?

Thanks,
Alex

Jeffrey Robble

unread,
Jun 29, 2021, 8:53:23 PM6/29/21
to OpenMPF
Hi Alex,

The applicationContext.xml file can't be found. That file should be at the top level inside of the component .jar.

I'm not sure what your component directory structure looks like, so I went ahead and took our example Java HelloWorldComponent and modified it to work in Docker. First, I had to change this line from "<format>tar.gz</format>" to " <format>dir</format>". Then I added a "Dockerfile" to the top-level HelloWorldComponent dir with this content:

FROM openmpf_java_component_build:latest as build_component

COPY pom.xml pom.xml

RUN mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:go-offline;

COPY . .

RUN mvn package -Dmpf.assembly.format=dir

RUN ls /home/mpf/component_src/target/plugin-packages/*

FROM ${BUILD_REGISTRY}openmpf_java_executor:latest as install_component

COPY --from=build_component /home/mpf/component_src/target/plugin-packages/JavaHelloWorldExample/JavaHelloWorldExample \
                            $PLUGINS_DIR/JavaHelloWorldExample

I was then able to build that by running the following command from within the top-level HelloWorldComponent dir:

docker build . -t openmpf_hello_world_component

And register it to an existing "docker-compose up" deployment with:

docker run --rm --network openmpf_default  -v openmpf_shared_data:/opt/mpf/share -e WFM_USER=admin -e WFM_PASSWORD=mpfadm <image-id>

I was then able to run a job with the "JAVAHELLOWORLD DETECTION PIPELINE" in the Workflow Manager web UI.

I hope this working example helps.

- Jeff

Jeffrey Robble

unread,
Jun 29, 2021, 8:56:28 PM6/29/21
to OpenMPF
Ignore the  "${BUILD_REGISTRY}" bit in the above Dockerfile. You can delete that.

Alexander Schimpf

unread,
Jun 30, 2021, 11:49:41 AM6/30/21
to OpenMPF
Jeff,

After fixing the Dockerfile I still have the same issue where the applicationContext.xml file is not found. My current file structure looks like: (I followed the structure from java executable README)

HelloWorldComponent
├── Dockerfile
├── assemblyDescriptor.xml
├── plugin-files
│   └── descriptor
│       └── descriptor.json
├── pom.xml
└── src
    ├──    main
    │  ├── java
    │  │   └── org/mitre/mpf/examples/hello
    │  │                   └── HelloWorldComponent.java
    │  └── resources
    │      └──   applicationContext.xml
    └──  Test
               └──  java
                    └── org/mitre/mpf/examples/hello
                           └── HelloWorldComponentTest.java

I have this all in one folder on my desktop. I run the docker build -t helloworld ~/Desktop/HelloWorldComponent and recieve no errors. then after starting up openmpf, i try to register it and recieve the error of the file not found. What do you mean by the file should be at the top level inside of the component .jar.

Thanks,
Alex

Jeffrey Robble

unread,
Jun 30, 2021, 12:01:26 PM6/30/21
to OpenMPF
You can run "unzip" on your component .jar to extract the contents:

[mpf@openmpf-master]$ docker run --rm -it --entrypoint bash openmpf_hello_world_component
[root@4a37b4142e81 /]# cd /opt/mpf/plugins/JavaHelloWorldExample/
[root@4a37b4142e81 JavaHelloWorldExample]# ls
descriptor  lib  mpf-helloworld-java-example-component-6.2.jar
[root@4a37b4142e81 JavaHelloWorldExample]# yum install unzip
[root@4a37b4142e81 JavaHelloWorldExample]# unzip mpf-helloworld-java-example-component-6.2.jar 
Archive:  mpf-helloworld-java-example-component-6.2.jar
   creating: META-INF/
  inflating: META-INF/MANIFEST.MF    
   creating: org/
   creating: org/mitre/
   creating: org/mitre/mpf/
   creating: org/mitre/mpf/examples/
   creating: org/mitre/mpf/examples/hello/
  inflating: applicationContext.xml

If you're still having issues, please share the contents of your Dockerfile.

- Jeff

Alexander Schimpf

unread,
Jun 30, 2021, 12:30:40 PM6/30/21
to OpenMPF
Jeff,

I was able to unziped the .jar file successfully.

Unzip.PNG

and then typed the command:
 sudo docker run \
    --network openmpf_default \
    -v openmpf_shared_data:/opt/mpf/share \
    -e WFM_USER=admin \
    -e WFM_PASSWORD=mpfadm \
    helloworld


I tried to start over and still got the same issue.
BeansError.PNG
Attached is my file that I am working with.

Thanks,
Alex
HelloWorld.zip

Jeffrey Robble

unread,
Jun 30, 2021, 3:03:44 PM6/30/21
to OpenMPF
In your descriptor.json you have:

  "batchLibrary": "mpf-helloworld-java-example-component-6.2.jar",


Change that to:

  "batchLibrary": "mpf-helloworld-example-component-6.2.jar",

That needs to match the name of your .jar file, exactly.

In the example component we provide we have "java" in the artifactId here. It seems that you removed that in your pom.xml.

- Jeff

Alexander Schimpf

unread,
Jul 1, 2021, 12:18:50 PM7/1/21
to OpenMPF
Jeff,

Thank you for you help. After renaming and unzipping the HelloWorld component was able to run after being registered. But a new problem came up, the program does not run unless the register command is also running.
Capture.PNG

as you can see, the program seems to run only when this runs. my question is how to run the program without having to re-register it every time?

Thanks,
-Alex

Jeffrey Robble

unread,
Jul 1, 2021, 12:43:33 PM7/1/21
to OpenMPF
The Docker entrypoint for that container will always attempt to register the component first. The Workflow Manager is designed to handle multiple registration attempts, and re-registration, so the behavior you see is what's expected.

- Jeff
Reply all
Reply to author
Forward
0 new messages