[halo-dev/halo]本地以源码方式启动插件项目时,出现PluginWrapper为空的情况

2023-12-15 868 views
3
是什么版本出现了此问题?

2.0.0

使用的什么数据库?

H2

使用的哪种方式部署?

Fat Jar

发生了什么?

本地以源码方式启动Halo时,出现PluginWrapper为空的情况

相关日志输出
`2022-12-05 17:03:43.224 WARN  run.halo.app.plugin.HaloPluginManager Line:390 - Unable to find plugin descriptor file: plugin.yaml
org.pf4j.PluginRuntimeException: Unable to find plugin descriptor file: plugin.yaml
    at run.halo.app.plugin.YamlPluginFinder.getManifestPath(YamlPluginFinder.java:109)
    at run.halo.app.plugin.YamlPluginFinder.readPluginDescriptor(YamlPluginFinder.java:74)
    at run.halo.app.plugin.YamlPluginFinder.find(YamlPluginFinder.java:64)
    at run.halo.app.plugin.YamlPluginDescriptorFinder.find(YamlPluginDescriptorFinder.java:42)
    at org.pf4j.AbstractPluginManager.loadPluginFromPath(AbstractPluginManager.java:829)
    at org.pf4j.DefaultPluginManager.loadPluginFromPath(DefaultPluginManager.java:139)
    at run.halo.app.plugin.HaloPluginManager.loadPluginFromPath(HaloPluginManager.java:385)
    at org.pf4j.AbstractPluginManager.loadPlugin(AbstractPluginManager.java:201)
    at run.halo.app.plugin.PluginDevelopmentInitializer.createFixedPluginIfNecessary(PluginDevelopmentInitializer.java:46)
    at run.halo.app.plugin.PluginDevelopmentInitializer.onApplicationEvent(PluginDevelopmentInitializer.java:37)
    at run.halo.app.plugin.PluginDevelopmentInitializer.onApplicationEvent(PluginDevelopmentInitializer.java:16)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:413)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:370)
    at org.springframework.boot.context.event.EventPublishingRunListener.ready(EventPublishingRunListener.java:109)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$ready$6(SpringApplicationRunListeners.java:80)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
    at org.springframework.boot.SpringApplicationRunListeners.ready(SpringApplicationRunListeners.java:80)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291)
    at run.halo.app.Application.main(Application.java:25)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:95)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
2022-12-05 17:03:43.227 DEBUG org.pf4j.DependencyResolver Line:66  - Graph: 
2022-12-05 17:03:43.227 DEBUG org.pf4j.DependencyResolver Line:70  - Plugins order: []
2022-12-05 17:03:43.243 ERROR org.springframework.boot.SpringApplication Line:820 - Application run failed
java.lang.NullPointerException: Cannot invoke "org.pf4j.PluginWrapper.getDescriptor()" because "pluginWrapper" is null
    at org.pf4j.AbstractPluginManager.loadPlugin(AbstractPluginManager.java:206)
    at run.halo.app.plugin.PluginDevelopmentInitializer.createFixedPluginIfNecessary(PluginDevelopmentInitializer.java:46)
    at run.halo.app.plugin.PluginDevelopmentInitializer.onApplicationEvent(PluginDevelopmentInitializer.java:37)
    at run.halo.app.plugin.PluginDevelopmentInitializer.onApplicationEvent(PluginDevelopmentInitializer.java:16)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:413)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:370)
    at org.springframework.boot.context.event.EventPublishingRunListener.ready(EventPublishingRunListener.java:109)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$ready$6(SpringApplicationRunListeners.java:80)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112)
    at org.springframework.boot.SpringApplicationRunListeners.ready(SpringApplicationRunListeners.java:80)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291)
    at run.halo.app.Application.main(Application.java:25)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:95)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)`

回答

3

/triage needs-information

根据以上信息无法复现这个错误。建议提供一下详细的复现步骤。

0

我使用的https://github.com/halo-sigs/plugin-unsplash 这个项目 以haloServer的方式在 gradle中启动 然后把当前halo v2.0.0 分支代码编译完成的产物放到 项目的 workspace下面和 lib下面

halo-2.0.0-SNAPSHOT.jar halo-2.0.0-SNAPSHOT-plain.jar

启动插件项目就出现了这个情况

0

如果想要以开发模式启动插件只需要做如下配置:

halo:
  plugin:
    runtime-mode: development # 此为开发模式
    plugins-root: ${halo.work-dir}/plugins
    fixed-plugin-path:
      # 替换为 plugin-unsplash 项目路径
      - /path/to/plugin/plugin-unsplash

然后 gradle build 一下 plugin-unsplash 在启动 halo 即可