5

I’m trying to resolve java.lang.ClassNotFoundException:jade.core.migration.InterPlatformMobilityService, which occurs in the JADE (Java Agent Development Framework) when I install add package for “Inter” platform mobility, which has a JAR titled “migration.jar” which contains InterPlatformMobilityService class. I need this extra JAR, to send an agent (code & data) across different computers.

Here is my output that shows the error:

INFO: Service jade.core.mobility.AgentMobility initialized
Sep 03, 2021 3:38:48 PM jade.core.AgentContainerImpl initAdditionalServices
WARNING: Exception initializing service jade.core.migration.InterPlatformMobilityService
jade.core.ServiceException: An error occurred during service activation - Caused by:  jade.core.migration.InterPlatformMobilityService
        at jade.core.AgentContainerImpl.startService(AgentContainerImpl.java:1169)
        at jade.core.AgentContainerImpl.initAdditionalServices(AgentContainerImpl.java:450)
        at jade.core.AgentContainerImpl.startNode(AgentContainerImpl.java:389)
        at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:502)
        at jade.core.Runtime.createMainContainer(Runtime.java:159)
        at abc.def.hgi.Setup.start(Setup.java:47)
        at abc.def.hgi.App.main(App.java:51)
Nested Exception:
java.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at jade.core.AgentContainerImpl.startService(AgentContainerImpl.java:1153)
        at jade.core.AgentContainerImpl.initAdditionalServices(AgentContainerImpl.java:450)
        at jade.core.AgentContainerImpl.startNode(AgentContainerImpl.java:389)
        at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:502)
        at jade.core.Runtime.createMainContainer(Runtime.java:159)
        at abc.def.hgi.Setup.start(Setup.java:47)
        at abc.def.hgi.App.main(App.java:51)

My code is purely Java & built via Maven, here is my pom:

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>abc.def.ghi</groupId>
      <artifactId>my_edge_ai</artifactId>
      <packaging>jar</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>my_edge_ai</name>
      <url>http://maven.apache.org</url>
     <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>
        <repositories>
            <repository> 
                <id>tilab</id> 
                <url>https://jade.tilab.com/maven/</url> 
            </repository>
                <repository>
                    <id>jade-ipms</id>
                    <url>file:${basedir}/add-ons/ipms/lib/migration.jar</url>
                </repository>
                <repository>
                    <id>jade-ipms-harcoded</id>
                    <url></url>
                </repository>
        </repositories>
        <dependencies>
            <dependency>  
                <groupId>com.tilab.jade</groupId> 
                <artifactId>jade</artifactId> 
                <version>4.5.0</version>  
            </dependency>
            <dependency>  
                <groupId>com.tilab.jade</groupId> 
                <artifactId>jade-misc</artifactId> 
                <version>2.8.0</version>  
            </dependency>
            <dependency>  
                <groupId>com.tilab.jade</groupId> 
                <artifactId>jade-test-suite</artifactId> 
                <version>1.13.0</version>  
            </dependency>
            <dependency>  
                <groupId>com.tilab.jade</groupId> 
                <artifactId>jade-wsdc</artifactId> 
                <version>2.7.0</version>  
            </dependency>
    
            <dependency>  
                <groupId>com.tilab.jade</groupId> 
                <artifactId>jade-xml-codec</artifactId> 
                <version>1.11.0</version>  
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <id>copy-dependencies</id>
                <phase>prepare-package</phase>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                    <outputDirectory>
                        ${project.build.directory}/libs
                    </outputDirectory>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
            <archive>
                <manifest>
                    <addClasspath>true</addClasspath>
                    <classpathPrefix>libs/</classpathPrefix>
                    <mainClass>
                        abc.def.ghi.App
                    </mainClass>
                </manifest>
            </archive>
        </configuration>
    </plugin>
            </plugins>
        </build>
    </project>

Based the JADE’s ipms (InterPlatformMobilityService) download guide, I extracted “ipmsAddOn-1.5.zp” under the my <my_path>/jade/<extract_here> , the same level that <my_path>/jade/lib resides, see the “ipms” README: https://jade.tilab.com/doc/tutorials/ipms/README

Finally, I built my project via “mvn clean install”, with success, output snippet:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  13.753 s
[INFO] Finished at: 2021-09-03T15:22:24-07:00
[INFO] ------------------------------------------------------------------------

I ran my “jar” via:

java -jar ./target/my_edge_ai-1.0-SNAPSHOT.jar 1 main

The java code attempts to initialize JADE with InterPlatformMobilityService via (refer snippet): Which start JADE, with this exception:

This is referenced from (Usage of the JADE Mobility Services, by Fabio Bellifemine etl al.):

“6.4.2 INTER-PLATFORM MOBILITY SERVICE The IPMS is not built into the platform and must be installed as an add-on. To install the add-on, the package distribution file must be unzipped inside the JADE folder from where the ant lib command is used to create a Jar file containing all compiled class files. To use the service, it must be explicitly specified on the command line, without forgetting to include the Intra-Platform Mobility Service first:”

java jade.Boot -services jade.core.mobility.AgentMobilityService;jade.core.migration. InterPlatformMobilityService

I was getting the same java.lang.ClassNotFoundException, when attempting to launch Intra-Platform Mobility Service via both Java or command-line approach.

Attempt 1 (migration.jar as repo to the pom.xml):

<repositories>
        <repository> 
            <id>tilab</id> 
            <url>https://jade.tilab.com/maven/</url> 
        </repository>
            <repository>
                <id>jade-ipms</id>
                <url>file:${basedir}/add-ons/ipms/lib/migration.jar</url>
            </repository>
            <repository>
                <id>jade-ipms-harcoded</id>
                <url>/root/my/my/jade/jade/add-ons/ipms/lib/migration.jar</url>
            </repository>
    </repositories>

Built project without errors, however got the same exception as runtime: java.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService.

Attempt 2 ( I copied the migration.jar, manually to my projects /lib):

root@pc-064067:~/my/my/jade/jade/my_edge_ai/my_edge_ai/libs# ls
commons-codec-1.3.jar  jade.jar  migration.jar

Again, built project without errors, however got the same exception as runtime: java.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService.

Attempt # 3, I added migration.jar, to my system class path:

export CLASSPATH=/root/my/my/jade/jade/my_edge_ai/my_edge_ai/libs/jade.jar:$CLASSPATH
export CLASSPATH=/root/my/my/jade/jade/my_edge_ai/my_edge_ai/libs/commons-codec-1.3.jar:$CLASSPATH
export CLASSPATH=/root/my/my /jade/jade/my_edge_ai/my_edge_ai/libs/migration.jar:$CLASSPATH

java -jar ./target/my-1.0-SNAPSHOT.jar 1 main

Again, built project without errors, however got the same exception as runtime: java.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService.

I got the same error also using Java -cp or -classpath flag.

I finally, opened up migration.jar in order to inspect if jade.core.migration.InterPlatformMobilityService was actually present which it was.

Attempt # 4) I did something nasty, I copied the classes in migration.jar directly under my src/main/java, however again the same error!

java.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService.

Attempt 5:

  1. Based on StackOverflow feedback, I installed the JAR locally like this:

    mvn install:install-file -Dfile=/home/azureuser/cyz/my/multi_agents/my_edge_ai/JadeDownload/jade/add-ons/ipms/lib/migration.jar -DgroupId=jade.core.migration -DartifactId=InterPlatformMobilityService -Dversion=1.5 -Dpackaging=jar -DJadeAddOnsPath=/home/azureuser/xyz/my/multi_agents/my_edge_ai/JadeDownload/jade/add-ons/ipms/lib/

Output snippet:

[INFO] ---------------------< abc.def.hgi:my_edge_ai >---------------------
[INFO] Building my_edge_ai 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ my_edge_ai ---
[INFO] Installing /home/azureuser/xyz/my/multi_agents/my_edge_ai/JadeDownload/jade/add-ons/ipms/lib/migration.jar to /home/azureuser/.m2/repository/jade/core/migration/InterPlatformMobilityService/1.5/InterPlatformMobilityService-1.5.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.893 s
[INFO] Finished at: 2021-09-07T23:50:50Z
[INFO] ------------------------------------------------------------------------
  1. Added this dependency block to the dependencies section:
jade.core.migration migration 1.5 system ${JadeAddOnsPath}/migration.jar
  1. Built the project :

    sudo mvn clean install -DJadeAddOnsPath=/home/azureuser/xyz/my/multi_agents/my_edge_ai/JadeDownload/jade/add-ons/ipms/lib/

Output snippet:

[INFO] --- maven-jar-plugin:3.1.1:jar (default-jar) @ my_edge_ai ---
[INFO] Building jar: /home/azureuser/xyz/my/multi_agents/my_edge_ai/my_edge_ai/target/my_edge_ai-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ my_edge_ai ---
[INFO] Installing /home/azureuser/xyz/my/multi_agents/my_edge_ai/my_edge_ai/target/my_edge_ai-1.0-SNAPSHOT.jar to /root/.m2/repository/abc/def/hgi/my_edge_ai/1.0-SNAPSHOT/my_edge_ai-1.0-SNAPSHOT.jar
[INFO] Installing /home/azureuser/xyz/my/multi_agents/my_edge_ai/my_edge_ai/pom.xml to /root/.m2/repository/abc/def/hgi/my_edge_ai/1.0-SNAPSHOT/my_edge_ai-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.609 s
[INFO] Finished at: 2021-09-07T23:51:57Z
[INFO] ------------------------------------------------------------------------

However same error:

WARNING: Exception initializing service jade.core.migration.InterPlatformMobilityService
jade.core.ServiceException: An error occurred during service activation - Caused by:  jade.core.migration.InterPlatformMobilityService
        at jade.core.AgentContainerImpl.startService(AgentContainerImpl.java:1169)
        at jade.core.AgentContainerImpl.initAdditionalServices(AgentContainerImpl.java:450)
        at jade.core.AgentContainerImpl.startNode(AgentContainerImpl.java:389)
        at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:502)
        at jade.core.Runtime.createMainContainer(Runtime.java:159)
        at abc.def.hgi.Setup.start(Setup.java:68)
        at abc.def.hgi.App.main(App.java:55)
Nested Exception:
java.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at jade.core.AgentContainerImpl.startService(AgentContainerImpl.java:1153)
        at jade.core.AgentContainerImpl.initAdditionalServices(AgentContainerImpl.java:450)
        at jade.core.AgentContainerImpl.startNode(AgentContainerImpl.java:389)
        at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:502)
        at jade.core.Runtime.createMainContainer(Runtime.java:159)
        at abc.def.hgi.Setup.start(Setup.java:68)
        at abc.def.hgi.App.main(App.java:55)

Attempt #6 (use jar -, based on stackoverflow feedback):

Searching for jade.core.migration.InterPlatformMobilityService in the atual JAR, therefore MUST be under jade/core/migration/InterPlatformMobilityService, which it is, see bold section.

jar -tvf ./add-ons/ipms/lib/migration.jar 

Output snippet:

0 Tue May 23 16:26:46 PDT 2017 META-INF/
   103 Tue May 23 16:26:44 PDT 2017 META-INF/MANIFEST.MF
     0 Tue May 23 16:26:44 PDT 2017 jade/
     0 Tue May 23 16:26:44 PDT 2017 jade/core/
     0 Tue May 23 16:26:46 PDT 2017 jade/core/migration/
     0 Tue May 23 16:26:46 PDT 2017 jade/core/migration/analysis/
     0 Tue May 23 16:26:46 PDT 2017 jade/core/migration/code/
     0 Tue May 23 16:26:46 PDT 2017 jade/core/migration/ontology/
     0 Tue May 23 16:26:46 PDT 2017 samples/
     0 Tue May 23 16:26:46 PDT 2017 samples/mobilegui/
  2739 Tue May 23 16:26:44 PDT 2017 jade/core/migration/AMSInitiator$PowerupRequest.class
  8881 Tue May 23 16:26:44 PDT 2017 jade/core/migration/AMSInitiator.class
 10918 Tue May 23 16:26:46 PDT 2017 jade/core/migration/AMSResponder.class
  1003 Tue May 23 16:26:46 PDT 2017 jade/core/migration/InterPlatformMobilityHelper.class
  2526 Tue May 23 16:26:46 PDT 2017 jade/core/migration/InterPlatformMobilityProxy.class
   272 Tue May 23 16:26:46 PDT 2017 **jade/core/migration/InterPlatformMobilityService$1.class**
  1687 Tue May 23 16:26:46 PDT 2017 jade/core/migration/InterPlatformMobilityService$CodeLocatorMonitor.class
  6816 Tue May 23 16:26:46 PDT 2017 jade/core/migration/InterPlatformMobilityService$CommandOutgoingFilter.class

I also checked the JAR manually by changing it to zip & jade.core.migration.InterPlatformMobilityService is where its suppose to be:

enter image description here

root:~/my/my/jade/jade/my_edge_ai/my_edge_ai# jar -tvf ./target/my_edge_ai-1.0-SNAPSHOT.jar   

Output:

401 Wed Sep 08 12:40:46 PDT 2021 META-INF/MANIFEST.MF
     0 Wed Sep 08 12:40:46 PDT 2021 META-INF/
     0 Wed Sep 08 12:40:40 PDT 2021 abc/
     0 Wed Sep 08 12:40:40 PDT 2021 abc/def/
     0 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/
     0 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/yellowpages/
     0 Wed Sep 08 12:40:46 PDT 2021 META-INF/maven/
     0 Wed Sep 08 12:40:46 PDT 2021 META-INF/maven/abc.def.hgi/
     0 Wed Sep 08 12:40:46 PDT 2021 META-INF/maven/abc.def.hgi/my_edge_ai/
  1045 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/App.class
  3438 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/ManagerAgent.class
  2164 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/SearchForAudioAgent$1.class
  3993 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/SearchForAudioAgent.class
  2228 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/SearchForBiometricAgent$1.class
  3024 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/SearchForBiometricAgent.class
  3316 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/SearchForImageAnalysisAgent.class
  1094 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/TestAgent$1.class
  3555 Tue Sep 07 15:44:40 PDT 2021 META-INF/maven/abc.def.hgi/my_edge_ai/pom.xml
  2703 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/AudioAnalysisRegisterAgent$InaCyclicBehavior.class
  2264 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/SearchForImageAnalysisAgent$1.class
  2669 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/Setup.class
  1406 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/TestAgent.class
    98 Wed Sep 08 12:40:46 PDT 2021 META-INF/maven/abc.def.hgi/my_edge_ai/pom.properties
  4507 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/AudioAnalysisRegisterAgent.class
  2313 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/yellowpages/DFRegisterAgent.class
  2667 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/yellowpages/DFSubscribeAgent$1.class
  2827 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/BiometricsRegisterAgent.class
  2755 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/yellowpages/DFSearchAgent.class
  1870 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/yellowpages/DFSubscribeAgent.class
   284 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/HelloAgent.class
   275 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/HiAgent.class
  1891 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/ManagerAgent$1.class
  2481 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/yellowpages/SubDF.class
  2836 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/ImageAnalyisRegisterAgent.class

Further investigations:

MANIFEST.MF of the projects built Jar(./target/my-1.0-SNAPSHOT.jar):

Manifest-Version: 1.0
Built-By: root
Class-Path: libs/jade-4.5.0.jar libs/commons-codec-1.3.jar libs/jade-m
 isc-2.8.0.jar libs/jade-test-suite-1.13.0.jar libs/jade-wsdc-2.7.0.ja
 r libs/axis-plus-1.4.0.jar libs/addressing-1.1.1.jar libs/wss4j-1.5.1
 .jar libs/xmlsec-1.3.0.jar libs/jade-xml-codec-1.11.0.jar
Created-By: Apache Maven 3.6.3
Build-Jdk: 1.8.0_292
Main-Class: abc.def.ghi.App

Attempt # 7 (Issue only solved on local machine) :

  1. I decided to build a "fat JAR" that includes all libraries (http://tutorials.jenkov.com/maven/maven-build-fat-jar.html) inside the JAR itself.

  2. I updated the pom.xml by adding this fat JAR plugin:

    org.apache.maven.plugins maven-assembly-plugin 3.1.1
                 <configuration>
                     <descriptorRefs>
                         <descriptorRef>jar-with-dependencies</descriptorRef>
                     </descriptorRefs>
                     <archive>
                         <manifest>
                             <addClasspath>true</addClasspath>
                             <classpathPrefix>libs/</classpathPrefix>
                             <mainClass>abc.def.ghi.App</mainClass>
                         </manifest>
                     </archive>
                 </configuration>
                 <executions>
                     <execution>
                         <id>make-assembly</id>
                         <phase>package</phase>
                         <goals>
                             <goal>single</goal>
                         </goals>
                     </execution>
                 </executions>
             </plugin>
    
  3. Further fixed incorrect pom.xml artifactId, based the artifactID in (~/.m2/repository/jade/core/migration/InterPlatformMobilityService/1.5/InterPlatformMobilityService-1.5.pom)

    jade.core.migration InterPlatformMobilityService 1.5 system ${JadeAddOnsPath}/migration.jar

4) Final commands, were:

mvn install:install-file -Dfile=/root/my/,y/jade/jade/add-ons/ipms/lib/migration.jar -DgroupId=jade.core.migration -DartifactId=InterPlatformMobilityService -Dversion=1.5 -Dpackaging=jar

output snippet:

[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ carna_edge_ai ---
[INFO] Installing /root/my/my/jade/jade/add-ons/ipms/lib/migration.jar to /root/.m2/repository/jade/core/migration/InterPlatformMobilityService/1.5/InterPlatformMobilityService-1.5.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.409 s
[INFO] Finished at: 2021-09-09T14:42:31-07:00
[INFO] ------------------------------------------------------------------------

Then build & package JAR:

sudo mvn clean package -DJadeAddOnsPath=/home/azureuser/xyz/my/multi_agents/my_edge_ai/JadeDownload/jade/add-ons/ipms/lib/

output snippet:

[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ my_edge_ai ---
[INFO] Building jar: /root/my/my/jade/jade/my_edge_ai/my_edge_ai/target/my_edge_ai-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-assembly-plugin:3.1.1:single (make-assembly) @ my_edge_ai ---
[INFO] Building jar: /root/my/my/jade/jade/my_edge_ai/my_edge_ai/target/my_edge_ai-1.0-SNAPSHOT-jar-with-dependencies.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  24.332 s
[INFO] Finished at: 2021-09-09T14:55:00-07:00
[INFO] ------------------------------------------------------------------------

Final run:

 java -jar ./target/my_edge_ai-1.0-SNAPSHOT-jar-with-dependencies.jar 1 main

The program started with no errors or exceptions.

However repeating the same exact steps on the azure Ubuntu server & triple checking paths, again yields:

java.lang.ClassNotFoundException:jade.core.migration.InterPlatformMobilityService

I even tried run the jar using -classpath flag:

sudo java -classpath "/home/azureuser/xyz/my/multi_agents/my_edge_ai/JadeDownload/jade/lib/jade.jar;/home/azureuser/xyz/my/multi_agents/my_edge_ai/JadeDownload/jade/lib/commons-codec/commons-codec-1.3.jar;/home/azureuser/xyz/my/multi_agents/my_edge_ai/JadeDownload/jade/add-ons/ipms/lib/migration.jar" -jar ./target/my_edge_ai-1.0-SNAPSHOT-jar-with-dependencies.jar 1 main

However again (only on remote now):

java.lang.ClassNotFoundException:jade.core.migration.InterPlatformMobilityService

The smoking gun! Finally I checked the contents of the fat JAR,maven is NOT including jade.core.migration.InterPlatformMobilityService in the fat JAR built on remote Ubuntu, but it's including it on local Ubuntu.

SOLVED:

In the remote pom.xml, I changed the InterPlatformMobilityService dependency to use maven local repo rather than pointing to actual file:

jade.core.migration InterPlatformMobilityService 1.5 system ${JadeAddOnsPath}/migration.jar -->

Thanks for community support & feedback!

Any more solutions?

Thoughts?

Appreciated

cyber101
  • 2,822
  • 14
  • 50
  • 93
  • maybe `migeration.jar` should be `migration.jar`? – tgdavies Sep 04 '21 at 02:01
  • @tgdavies, thanks for catching that. The spelling mistake could cause the same error, however I corrected the spelling & built the project, however I'm getting again the same `java.lang.ClassNotFoundException`. – cyber101 Sep 07 '21 at 20:14
  • 1
    You can't add a local dependency by defining a repository the way you've done. See https://stackoverflow.com/questions/30347310/adding-a-system-dependency-to-maven – tgdavies Sep 07 '21 at 20:47
  • +1 to using system dependency as the "right way" to do what you're currently trying to do (point maven at a specific file on your file system); alternatively, host your migration.jar in your own org's repository. That has the advantage of working on any system going forward, not just machines that have been pre-configured with the magic file in place – Gus Sep 07 '21 at 21:15
  • @tgdavies, I tried adding install the JAR locally. See the new attempt #5, the original post is updated. However the same error. – cyber101 Sep 08 '21 at 00:00
  • If you run `jar -tvf ` what do you get? And what's the contents of the manifest? – tgdavies Sep 08 '21 at 00:04
  • @tgdavies, I ran the command that you suggested & the class in present under right structure, see updated post. – cyber101 Sep 08 '21 at 19:18
  • Seems like nested classes of `jade.core.migration.InterPlatformMobilityService` are present but `jade.core.migration.InterPlatformMobilityService` itself is not. – dan1st Sep 08 '21 at 19:39
  • Sorry, I wasn't clear: run `jar -tvf` on *your jar*, that is, `my-1.0-SNAPSHOT.jar`. That is the jar we are running. Also, please add the contents of `META-INF/MANIFEST.MF` *from that jar* to your question. – tgdavies Sep 08 '21 at 20:43
  • @dan1st, that was a bad screenshot. The class `jade.core.migration.InterPlatformMobilityService` is present see the new screenshot. – cyber101 Sep 08 '21 at 21:30
  • @tgdavies, I posted the jar -tvf against the project's actual JAR & its manifest file. – cyber101 Sep 08 '21 at 21:44
  • This is the correct answer: https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven The dependency plugin and jar plugin configuration is not required. – tgdavies Sep 08 '21 at 23:20
  • Did you try to add the migration.jar into MANIFEST.MF file (should move it up a little bit)? I think the issue is due to JVM class loader load classes based on orders, and there's a conflict in package/class that you want to use causing the loader just load the other jar file, not the migration.jar file. – Thinhbk Sep 09 '21 at 14:04
  • @Thinhbk, how would you do that? – cyber101 Sep 09 '21 at 16:46
  • @tgdavies, what specific part of this post that you mentioned is the "correct answer": https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven. Im not having trouble with maven , and the project builds & executable jar is created. The "jade.jar" and other dependencies are a;ll included in the final jar except "migration.jar" , so the only mystery us "migration.jar". – cyber101 Sep 09 '21 at 19:35
  • @tgdavies, I solved the issue on my local machine by 1# creating fat jar (http://tutorials.jenkov.com/maven/maven-build-fat-jar.html) 2# updated the POM.xml to refer to correct artifactId based the artifactId that was created in `~/.m2/repository/jade/core/migration/InterPlatformMobilityService/1.5/InterPlatformMobilityService-1.5.pom`. However using the same method & after triple checking paths Im still getting `java.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService' on remote Azure Ubuntu. Refer to updated post, Attempt #7 . Thank you. – cyber101 Sep 09 '21 at 21:32
  • @tgdavies, solved refer to post. – cyber101 Sep 09 '21 at 22:25
  • Are you sure that your problem is really a maven problem? If, when you execute your program outside maven, it fails with ClassNotFound, then you should check if migration.jar is really read at all. In the JADE link your mention, the JAR is found here : jade/add-ons/.../ipms/doc/lib/migration.jar . Is that the case in what you package ? – NoDataFound Sep 09 '21 at 22:37
  • Note: you can add an answer to your own question (and even accept said answer). The question box in this page is for, err... the question. Only the question. Not for the answer. That is what the "Your Answer" part is for. – VonC Sep 10 '21 at 05:41

1 Answers1

1

SOLVED:

In the remote pom.xml, I changed the InterPlatformMobilityService dependency to use maven local repo rather than pointing to actual file:

jade.core.migration InterPlatformMobilityService 1.5 system ${JadeAddOnsPath}/migration.jar --> Thanks for community support & feedback!

cyber101
  • 2,822
  • 14
  • 50
  • 93