I\xe2\x80\x99m 尝试解析java.lang.ClassNotFoundException:jade.core.migration.InterPlatformMobilityService,当我为 \xe2\x80\x9cInter\xe2\x80\x9d 平台移动性安装添加包时,该问题发生在JADE(Java 代理开发框架)中,其中有一个名为 \xe2 的 JAR \x80\x9cmigration.jar\xe2\x80\x9d 其中包含InterPlatformMobilityService类。我需要这个额外的 JAR,以便在不同的计算机之间发送代理(代码和数据)。
这是我的输出,显示了错误:
\nINFO: Service jade.core.mobility.AgentMobility initialized\nSep 03, 2021 3:38:48 PM jade.core.AgentContainerImpl initAdditionalServices\nWARNING: Exception initializing service jade.core.migration.InterPlatformMobilityService\njade.core.ServiceException: An error occurred during service activation - Caused by: jade.core.migration.InterPlatformMobilityService\n at jade.core.AgentContainerImpl.startService(AgentContainerImpl.java:1169)\n at jade.core.AgentContainerImpl.initAdditionalServices(AgentContainerImpl.java:450)\n at jade.core.AgentContainerImpl.startNode(AgentContainerImpl.java:389)\n at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:502)\n at jade.core.Runtime.createMainContainer(Runtime.java:159)\n at abc.def.hgi.Setup.start(Setup.java:47)\n at abc.def.hgi.App.main(App.java:51)\nNested Exception:\njava.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService\n at java.net.URLClassLoader.findClass(URLClassLoader.java:382)\n at java.lang.ClassLoader.loadClass(ClassLoader.java:418)\n at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)\n at java.lang.ClassLoader.loadClass(ClassLoader.java:351)\n at java.lang.Class.forName0(Native Method)\n at java.lang.Class.forName(Class.java:264)\n at jade.core.AgentContainerImpl.startService(AgentContainerImpl.java:1153)\n at jade.core.AgentContainerImpl.initAdditionalServices(AgentContainerImpl.java:450)\n at jade.core.AgentContainerImpl.startNode(AgentContainerImpl.java:389)\n at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:502)\n at jade.core.Runtime.createMainContainer(Runtime.java:159)\n at abc.def.hgi.Setup.start(Setup.java:47)\n at abc.def.hgi.App.main(App.java:51)\nRun Code Online (Sandbox Code Playgroud)\n我的代码是纯 Java 并通过 Maven 构建,这是我的 pom:
\n <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\n <modelVersion>4.0.0</modelVersion>\n <groupId>abc.def.ghi</groupId>\n <artifactId>my_edge_ai</artifactId>\n <packaging>jar</packaging>\n <version>1.0-SNAPSHOT</version>\n <name>my_edge_ai</name>\n <url>http://maven.apache.org</url>\n <properties>\n <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n </properties>\n <repositories>\n <repository> \n <id>tilab</id> \n <url>https://jade.tilab.com/maven/</url> \n </repository>\n <repository>\n <id>jade-ipms</id>\n <url>file:${basedir}/add-ons/ipms/lib/migration.jar</url>\n </repository>\n <repository>\n <id>jade-ipms-harcoded</id>\n <url></url>\n </repository>\n </repositories>\n <dependencies>\n <dependency> \n <groupId>com.tilab.jade</groupId> \n <artifactId>jade</artifactId> \n <version>4.5.0</version> \n </dependency>\n <dependency> \n <groupId>com.tilab.jade</groupId> \n <artifactId>jade-misc</artifactId> \n <version>2.8.0</version> \n </dependency>\n <dependency> \n <groupId>com.tilab.jade</groupId> \n <artifactId>jade-test-suite</artifactId> \n <version>1.13.0</version> \n </dependency>\n <dependency> \n <groupId>com.tilab.jade</groupId> \n <artifactId>jade-wsdc</artifactId> \n <version>2.7.0</version> \n </dependency>\n \n <dependency> \n <groupId>com.tilab.jade</groupId> \n <artifactId>jade-xml-codec</artifactId> \n <version>1.11.0</version> \n </dependency>\n </dependencies>\n <build>\n <plugins>\n <plugin>\n <artifactId>maven-dependency-plugin</artifactId>\n <version>3.1.1</version>\n </plugin>\n <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-dependency-plugin</artifactId>\n <executions>\n <execution>\n <id>copy-dependencies</id>\n <phase>prepare-package</phase>\n <goals>\n <goal>copy-dependencies</goal>\n </goals>\n <configuration>\n <outputDirectory>\n ${project.build.directory}/libs\n </outputDirectory>\n </configuration>\n </execution>\n </executions>\n </plugin>\n <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-jar-plugin</artifactId>\n <configuration>\n <archive>\n <manifest>\n <addClasspath>true</addClasspath>\n <classpathPrefix>libs/</classpathPrefix>\n <mainClass>\n abc.def.ghi.App\n </mainClass>\n </manifest>\n </archive>\n </configuration>\n </plugin>\n </plugins>\n </build>\n </project>\nRun Code Online (Sandbox Code Playgroud)\n根据 JADE\xe2\x80\x99s ipms (InterPlatformMobilityService) 下载指南,我在我的<my_path>/jade/<extract_here>下提取了 \xe2\x80\x9cipmsAddOn-1.5.zp\xe2\x80\x9d ,同一级别<my_path>/jade/lib所在的位置 ,请参阅 \xe2\x80\x9cipms\xe2\x80\x9d 自述文件:\n https://jade.tilab.com/doc/tutorials/ipms/README
\n最后,我通过 \xe2\x80\x9cmvn clean install\xe2\x80\x9d 构建了我的项目,成功了,输出片段:
\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD SUCCESS\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time: 13.753 s\n[INFO] Finished at: 2021-09-03T15:22:24-07:00\n[INFO] ------------------------------------------------------------------------\nRun Code Online (Sandbox Code Playgroud)\n我通过以下方式运行了 \xe2\x80\x9cjar\xe2\x80\x9d:
\njava -jar ./target/my_edge_ai-1.0-SNAPSHOT.jar 1 main\nRun Code Online (Sandbox Code Playgroud)\njava 代码尝试使用InterPlatformMobilityServicevia 初始化 JADE(参考代码片段):\n启动 JADE,但有以下例外:
这引用自(Fabio Belllifemine 等人的 JADE Mobility Services 的使用):
\n\xe2\x80\x9c6.4.2 平台间移动服务 IPMS 未内置于平台中,必须作为附加组件安装。要安装该附加组件,必须将包分发文件解压缩到 JADE 文件夹中,在该文件夹中使用 ant lib 命令创建包含所有已编译类文件的 Jar 文件。要使用该服务,必须在命令行上显式指定,不要忘记首先包含平台内移动服务:\xe2\x80\x9d
\njava jade.Boot -services jade.core.mobility.AgentMobilityService;jade.core.migration. InterPlatformMobilityService\nRun Code Online (Sandbox Code Playgroud)\n我也得到了同样的结果java.lang.ClassNotFoundException当我尝试通过 Java 或命令行方法启动平台内移动服务时,
尝试 1(migration.jar 作为 pom.xml 的存储库):
\n<repositories>\n <repository> \n <id>tilab</id> \n <url>https://jade.tilab.com/maven/</url> \n </repository>\n <repository>\n <id>jade-ipms</id>\n <url>file:${basedir}/add-ons/ipms/lib/migration.jar</url>\n </repository>\n <repository>\n <id>jade-ipms-harcoded</id>\n <url>/root/my/my/jade/jade/add-ons/ipms/lib/migration.jar</url>\n </repository>\n </repositories>\nRun Code Online (Sandbox Code Playgroud)\n构建的项目没有错误,但是得到了与运行时相同的异常:java.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService.
尝试2(我将migration.jar手动复制到我的项目/lib):
\nroot@pc-064067:~/my/my/jade/jade/my_edge_ai/my_edge_ai/libs# ls\ncommons-codec-1.3.jar jade.jar migration.jar\nRun Code Online (Sandbox Code Playgroud)\n再次,构建的项目没有错误,但是得到了与运行时相同的异常:java.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService。
尝试#3,我将migration.jar添加到我的系统类路径中:
\nexport CLASSPATH=/root/my/my/jade/jade/my_edge_ai/my_edge_ai/libs/jade.jar:$CLASSPATH\nexport CLASSPATH=/root/my/my/jade/jade/my_edge_ai/my_edge_ai/libs/commons-codec-1.3.jar:$CLASSPATH\nexport CLASSPATH=/root/my/my /jade/jade/my_edge_ai/my_edge_ai/libs/migration.jar:$CLASSPATH\n\njava -jar ./target/my-1.0-SNAPSHOT.jar 1 main\nRun Code Online (Sandbox Code Playgroud)\n再次,构建的项目没有错误,但是得到了与运行时相同的异常:java.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService.
我使用 Java -cp 或 -classpath 标志也遇到了同样的错误。
\n最后,我打开了 migration.jar,以检查jade.core.migration.InterPlatformMobilityService 是否确实存在。
\n尝试#4)我做了一些令人讨厌的事情,我将migration.jar中的类直接复制到我的src/main/java下,但是再次出现同样的错误!
\njava.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService.
尝试5:
\n根据 StackOverflow 的反馈,我在本地安装了 JAR,如下所示:
\nmvn 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/
\n输出片段:
\n[INFO] ---------------------< abc.def.hgi:my_edge_ai >---------------------\n[INFO] Building my_edge_ai 1.0-SNAPSHOT\n[INFO] --------------------------------[ jar ]---------------------------------\n[INFO]\n[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ my_edge_ai ---\n[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\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD SUCCESS\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time: 0.893 s\n[INFO] Finished at: 2021-09-07T23:50:50Z\n[INFO] ------------------------------------------------------------------------\nRun Code Online (Sandbox Code Playgroud)\n构建项目:
\nsudo mvn clean install -DJadeAddOnsPath=/home/azureuser/xyz/my/multi_agents/my_edge_ai/JadeDownload/jade/add-ons/ipms/lib/
\n输出片段:
\n[INFO] --- maven-jar-plugin:3.1.1:jar (default-jar) @ my_edge_ai ---\n[INFO] Building jar: /home/azureuser/xyz/my/multi_agents/my_edge_ai/my_edge_ai/target/my_edge_ai-1.0-SNAPSHOT.jar\n[INFO]\n[INFO] --- maven-install-plugin:2.4:install (default-install) @ my_edge_ai ---\n[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\n[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\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD SUCCESS\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time: 1.609 s\n[INFO] Finished at: 2021-09-07T23:51:57Z\n[INFO] ------------------------------------------------------------------------\nRun Code Online (Sandbox Code Playgroud)\n但是同样的错误:
\nWARNING: Exception initializing service jade.core.migration.InterPlatformMobilityService\njade.core.ServiceException: An error occurred during service activation - Caused by: jade.core.migration.InterPlatformMobilityService\n at jade.core.AgentContainerImpl.startService(AgentContainerImpl.java:1169)\n at jade.core.AgentContainerImpl.initAdditionalServices(AgentContainerImpl.java:450)\n at jade.core.AgentContainerImpl.startNode(AgentContainerImpl.java:389)\n at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:502)\n at jade.core.Runtime.createMainContainer(Runtime.java:159)\n at abc.def.hgi.Setup.start(Setup.java:68)\n at abc.def.hgi.App.main(App.java:55)\nNested Exception:\njava.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService\n at java.net.URLClassLoader.findClass(URLClassLoader.java:382)\n at java.lang.ClassLoader.loadClass(ClassLoader.java:418)\n at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)\n at java.lang.ClassLoader.loadClass(ClassLoader.java:351)\n at java.lang.Class.forName0(Native Method)\n at java.lang.Class.forName(Class.java:264)\n at jade.core.AgentContainerImpl.startService(AgentContainerImpl.java:1153)\n at jade.core.AgentContainerImpl.initAdditionalServices(AgentContainerImpl.java:450)\n at jade.core.AgentContainerImpl.startNode(AgentContainerImpl.java:389)\n at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:502)\n at jade.core.Runtime.createMainContainer(Runtime.java:159)\n at abc.def.hgi.Setup.start(Setup.java:68)\n at abc.def.hgi.App.main(App.java:55)\nRun Code Online (Sandbox Code Playgroud)\n尝试#6(使用 jar -,基于 stackoverflow 反馈):
\n在实际 JAR 中搜索jade.core.migration.InterPlatformMobilityService,因此必须在jade/core/migration/InterPlatformMobilityService 下,即它所在的位置,请参见粗体部分。
\njar -tvf ./add-ons/ipms/lib/migration.jar \nRun Code Online (Sandbox Code Playgroud)\n输出片段:
\n0 Tue May 23 16:26:46 PDT 2017 META-INF/\n 103 Tue May 23 16:26:44 PDT 2017 META-INF/MANIFEST.MF\n 0 Tue May 23 16:26:44 PDT 2017 jade/\n 0 Tue May 23 16:26:44 PDT 2017 jade/core/\n 0 Tue May 23 16:26:46 PDT 2017 jade/core/migration/\n 0 Tue May 23 16:26:46 PDT 2017 jade/core/migration/analysis/\n 0 Tue May 23 16:26:46 PDT 2017 jade/core/migration/code/\n 0 Tue May 23 16:26:46 PDT 2017 jade/core/migration/ontology/\n 0 Tue May 23 16:26:46 PDT 2017 samples/\n 0 Tue May 23 16:26:46 PDT 2017 samples/mobilegui/\n 2739 Tue May 23 16:26:44 PDT 2017 jade/core/migration/AMSInitiator$PowerupRequest.class\n 8881 Tue May 23 16:26:44 PDT 2017 jade/core/migration/AMSInitiator.class\n 10918 Tue May 23 16:26:46 PDT 2017 jade/core/migration/AMSResponder.class\n 1003 Tue May 23 16:26:46 PDT 2017 jade/core/migration/InterPlatformMobilityHelper.class\n 2526 Tue May 23 16:26:46 PDT 2017 jade/core/migration/InterPlatformMobilityProxy.class\n 272 Tue May 23 16:26:46 PDT 2017 **jade/core/migration/InterPlatformMobilityService$1.class**\n 1687 Tue May 23 16:26:46 PDT 2017 jade/core/migration/InterPlatformMobilityService$CodeLocatorMonitor.class\n 6816 Tue May 23 16:26:46 PDT 2017 jade/core/migration/InterPlatformMobilityService$CommandOutgoingFilter.class\n\nI also checked the JAR manually by changing it to zip & jade.core.migration.InterPlatformMobilityService is where its suppose to be:\nRun Code Online (Sandbox Code Playgroud)\n\nroot:~/my/my/jade/jade/my_edge_ai/my_edge_ai# jar -tvf ./target/my_edge_ai-1.0-SNAPSHOT.jar \nRun Code Online (Sandbox Code Playgroud)\n输出:
\n401 Wed Sep 08 12:40:46 PDT 2021 META-INF/MANIFEST.MF\n 0 Wed Sep 08 12:40:46 PDT 2021 META-INF/\n 0 Wed Sep 08 12:40:40 PDT 2021 abc/\n 0 Wed Sep 08 12:40:40 PDT 2021 abc/def/\n 0 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/\n 0 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/yellowpages/\n 0 Wed Sep 08 12:40:46 PDT 2021 META-INF/maven/\n 0 Wed Sep 08 12:40:46 PDT 2021 META-INF/maven/abc.def.hgi/\n 0 Wed Sep 08 12:40:46 PDT 2021 META-INF/maven/abc.def.hgi/my_edge_ai/\n 1045 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/App.class\n 3438 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/ManagerAgent.class\n 2164 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/SearchForAudioAgent$1.class\n 3993 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/SearchForAudioAgent.class\n 2228 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/SearchForBiometricAgent$1.class\n 3024 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/SearchForBiometricAgent.class\n 3316 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/SearchForImageAnalysisAgent.class\n 1094 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/TestAgent$1.class\n 3555 Tue Sep 07 15:44:40 PDT 2021 META-INF/maven/abc.def.hgi/my_edge_ai/pom.xml\n 2703 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/AudioAnalysisRegisterAgent$InaCyclicBehavior.class\n 2264 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/SearchForImageAnalysisAgent$1.class\n 2669 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/Setup.class\n 1406 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/TestAgent.class\n 98 Wed Sep 08 12:40:46 PDT 2021 META-INF/maven/abc.def.hgi/my_edge_ai/pom.properties\n 4507 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/AudioAnalysisRegisterAgent.class\n 2313 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/yellowpages/DFRegisterAgent.class\n 2667 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/yellowpages/DFSubscribeAgent$1.class\n 2827 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/BiometricsRegisterAgent.class\n 2755 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/yellowpages/DFSearchAgent.class\n 1870 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/yellowpages/DFSubscribeAgent.class\n 284 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/HelloAgent.class\n 275 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/HiAgent.class\n 1891 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/ManagerAgent$1.class\n 2481 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/yellowpages/SubDF.class\n 2836 Wed Sep 08 12:40:40 PDT 2021 abc/def/hgi/ImageAnalyisRegisterAgent.class\nRun Code Online (Sandbox Code Playgroud)\n进一步调查:
\n构建Jar项目的MANIFEST.MF(./target/my-1.0-SNAPSHOT.jar):
\nManifest-Version: 1.0\nBuilt-By: root\nClass-Path: libs/jade-4.5.0.jar libs/commons-codec-1.3.jar libs/jade-m\n isc-2.8.0.jar libs/jade-test-suite-1.13.0.jar libs/jade-wsdc-2.7.0.ja\n r libs/axis-plus-1.4.0.jar libs/addressing-1.1.1.jar libs/wss4j-1.5.1\n .jar libs/xmlsec-1.3.0.jar libs/jade-xml-codec-1.11.0.jar\nCreated-By: Apache Maven 3.6.3\nBuild-Jdk: 1.8.0_292\nMain-Class: abc.def.ghi.App\nRun Code Online (Sandbox Code Playgroud)\n尝试#7(问题仅在本地计算机上解决):
\n解决了:
在远程 pom.xml 中,我更改了 InterPlatformMobilityService 依赖项以使用 maven 本地存储库,而不是指向实际文件:
jade.core.migration InterPlatformMobilityService 1.5 系统 ${JadeAddOnsPath}/migration.jar --> 感谢社区的支持和反馈!
| 归档时间: |
|
| 查看次数: |
515 次 |
| 最近记录: |