开发者社区> 问答> 正文

使用Pandora Boot开发时,无法启动

使用Pandora Boot开发HSF应用,自己写了一个小Demo,凡事一直无法运行,请教一下是什么原因,代码如下: 启动类

package com.qhcs.micro.service;

import com.taobao.pandora.boot.PandoraBootstrap;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class GoodsServiceApplication {
    public static void main(String[] args) {
        // 启动 Pandora Boot 用于加载 Pandora 容器
        PandoraBootstrap.run(args);
        SpringApplication.run(GoodsServiceApplication.class, args);
        // 标记服务启动完成,并设置线程 wait。防止用户业务代码运行完毕退出后,导致容器退出。
        PandoraBootstrap.markStartupAndWait();
    }
}

接口类

package com.qhcs.micro.service.api;

import com.baomidou.mybatisplus.extension.service.IService;
import com.qhcs.micro.service.entity.Brand;
import com.qhcs.micro.service.vo.BrandVO;

import java.util.List;
import java.util.Map;

public interface BrandService extends IService<Brand> {
    /**
     * 根据主键ID集合获取详情MAP
     * @param ids 主键集合
     */
    Map<Long, BrandVO> getMapByIds(List<Long> ids);
}

实现类

package com.qhcs.micro.service.impl;

import com.alibaba.boot.hsf.annotation.HSFProvider;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qhcs.micro.service.api.BrandService;
import com.qhcs.micro.service.common.tools.MapTools;
import com.qhcs.micro.service.entity.Brand;
import com.qhcs.micro.service.mapper.BrandMapper;
import com.qhcs.micro.service.vo.BrandVO;

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

@HSFProvider(serviceInterface = BrandService.class)
public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements BrandService {
    @Override
    public Map<Long, BrandVO> getMapByIds(List<Long> ids) {
        List<Brand> list = listByIds(ids);
        List<BrandVO> voList = new ArrayList<>();
        list.forEach(a -> voList.add(new BrandVO(a)));
        return MapTools.listToMap(voList);
    }
}

错误

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'brandServiceImpl#HSFProvider': Invocation of init method failed; nested exception is java.lang.RuntimeException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
	at com.qhcs.micro.service.GoodsServiceApplication.main(GoodsServiceApplication.java:13) [classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_202]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_202]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_202]
	at com.taobao.pandora.boot.loader.LaunchRunner.run(LaunchRunner.java:38) [pandora-boot-loader-2.1.11.7.jar:2.1.11.7]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_202]
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException
	at com.taobao.hsf.app.api.util.HSFApiProviderBean.publish(HSFApiProviderBean.java:552) ~[hsf-app-api-2.2.8.2.jar!/:na]
	at com.taobao.hsf.app.spring.util.HSFSpringProviderBean.doPublish(HSFSpringProviderBean.java:83) ~[hsf-app-spring-2.2.8.2.jar!/:na]
	at com.taobao.hsf.app.spring.util.HSFSpringProviderBean.init(HSFSpringProviderBean.java:77) ~[hsf-app-spring-2.2.8.2.jar!/:na]
	at com.taobao.hsf.app.spring.util.HSFSpringProviderBean.afterPropertiesSet(HSFSpringProviderBean.java:65) ~[hsf-app-spring-2.2.8.2.jar!/:na]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
	... 22 common frames omitted
Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException
	at com.taobao.hsf.model.metadata.ServiceMetadata.exportSync(ServiceMetadata.java:376) ~[hsf-core-2.2.8.2.jar!/:na]
	at com.taobao.hsf.app.api.util.HSFApiProviderBean.publish(HSFApiProviderBean.java:550) ~[hsf-app-api-2.2.8.2.jar!/:na]
	... 27 common frames omitted
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException
	at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:1.8.0_202]
	at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[na:1.8.0_202]
	at com.taobao.hsf.threadpool.impl.SingleThreadScheduledExecutor$RunnableScheduleFutureDecorator.get(SingleThreadScheduledExecutor.java:184) ~[hsf-core-2.2.8.2.jar!/:na]
	at com.taobao.hsf.model.metadata.ServiceMetadata.exportSync(ServiceMetadata.java:366) ~[hsf-core-2.2.8.2.jar!/:na]
	... 28 common frames omitted
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
	at com.taobao.hsf.model.metadata.ServiceMetadata.export(ServiceMetadata.java:340) ~[hsf-core-2.2.8.2.jar!/:na]
	at com.taobao.hsf.model.metadata.ServiceMetadata$1.call(ServiceMetadata.java:361) ~[hsf-core-2.2.8.2.jar!/:na]
	at com.taobao.hsf.model.metadata.ServiceMetadata$1.call(ServiceMetadata.java:358) ~[hsf-core-2.2.8.2.jar!/:na]
	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) ~[na:1.8.0_202]
	at java.util.concurrent.FutureTask.run(FutureTask.java) ~[na:1.8.0_202]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_202]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[na:1.8.0_202]
	at com.taobao.hsf.threadpool.impl.SingleThreadScheduledExecutor$RunnableScheduleFutureDecorator.run(SingleThreadScheduledExecutor.java:155) ~[hsf-core-2.2.8.2.jar!/:na]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_202]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_202]
	... 1 common frames omitted
Caused by: java.lang.NullPointerException: null
	at com.taobao.hsf.unit.service.impl.UnitProtocolInterceptor.export(UnitProtocolInterceptor.java:28) ~[hsf-feature-unit-2.2.8.2.jar!/:na]
	at com.taobao.hsf.protocol.AbstractDelegateProtocolInterceptor.export(AbstractDelegateProtocolInterceptor.java:26) ~[hsf-core-2.2.8.2.jar!/:na]
	at com.taobao.hsf.region.service.impl.RegionProtocolInterceptor.export(RegionProtocolInterceptor.java:33) ~[hsf-feature-region-2.2.8.2.jar!/:na]
	at com.taobao.hsf.plugins.eagleeye.protocol.EagleEyeProtocolInterceptor.export(EagleEyeProtocolInterceptor.java:37) ~[hsf-feature-eagleeye-2.2.8.2.jar!/:na]
	at com.taobao.hsf.process.component.CodeployProtocolInterceptor.export(CodeployProtocolInterceptor.java:31) ~[hsf-feature-codeploy-2.2.8.2.jar!/:na]
	at com.taobao.hsf.feature.optimized.hessian.protocolinterceptor.OptimizedHessianProtocolInterceptor.export(OptimizedHessianProtocolInterceptor.java:29) ~[hsf-feature-optimized-hessian-2.2.8.2.jar!/:na]
	at com.taobao.hsf.protocol.AbstractDelegateProtocolInterceptor.export(AbstractDelegatejava.lang.reflect.InvocationTargetException
ProtocolInterceptor.java:26) ~[hsf-core-2.2.8.2.jar!/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at com.taobao.hsf.plugins.spas.SpasProtocolInterceptor.export(SpasProtocolInterceptor.java:21) ~[hsf-feature-spas-2.2.8.2.jar!/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at com.taobao.hsf.protocol.DelayPublishProtocolInterceptor.export(DelayPublishProtocolInterceptor.java:26) ~[hsf-feature-default-2.2.8.2.jar!/:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at com.taobao.hsf.metadata.store.MetadataReportProtocolInterceptor.export(MetadataReportProtocolInterceptor.java:46) ~[hsf-feature-metadata-report-2.2.8.2.jar!/:na]
	at com.taobao.hsf.model.metadata.ServiceMetadata.export(ServiceMetadata.java:335) ~[hsf-core-2.2.8.2.jar!/:na]
	at java.lang.reflect.Method.invoke(Method.java:498)
	... 10 common frames omitted

	at com.taobao.pandora.boot.loader.LaunchRunner.run(LaunchRunner.java:38)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'brandServiceImpl#HSFProvider': Invocation of init method failed; nested exception is java.lang.RuntimeException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)
	at com.qhcs.micro.service.GoodsServiceApplication.main(GoodsServiceApplication.java:13)
	... 6 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException
	at com.taobao.hsf.app.api.util.HSFApiProviderBean.publish(HSFApiProviderBean.java:552)
	at com.taobao.hsf.app.spring.util.HSFSpringProviderBean.doPublish(HSFSpringProviderBean.java:83)
	at com.taobao.hsf.app.spring.util.HSFSpringProviderBean.init(HSFSpringProviderBean.java:77)
	at com.taobao.hsf.app.spring.util.HSFSpringProviderBean.afterPropertiesSet(HSFSpringProviderBean.java:65)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
	... 22 more
Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException
	at com.taobao.hsf.model.metadata.ServiceMetadata.exportSync(ServiceMetadata.java:376)
	at com.taobao.hsf.app.api.util.HSFApiProviderBean.publish(HSFApiProviderBean.java:550)
	... 27 more
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.NullPointerException
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at com.taobao.hsf.threadpool.impl.SingleThreadScheduledExecutor$RunnableScheduleFutureDecorator.get(SingleThreadScheduledExecutor.java:184)
	at com.taobao.hsf.model.metadata.ServiceMetadata.exportSync(ServiceMetadata.java:366)
	... 28 more
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
	at com.taobao.hsf.model.metadata.ServiceMetadata.export(ServiceMetadata.java:340)
	at com.taobao.hsf.model.metadata.ServiceMetadata$1.call(ServiceMetadata.java:361)
	at com.taobao.hsf.model.metadata.ServiceMetadata$1.call(ServiceMetadata.java:358)
	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
	at java.util.concurrent.FutureTask.run(FutureTask.java)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at com.taobao.hsf.threadpool.impl.SingleThreadScheduledExecutor$RunnableScheduleFutureDecorator.run(SingleThreadScheduledExecutor.java:155)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	... 1 more
Caused by: java.lang.NullPointerException
	at com.taobao.hsf.unit.service.impl.UnitProtocolInterceptor.export(UnitProtocolInterceptor.java:28)
	at com.taobao.hsf.protocol.AbstractDelegateProtocolInterceptor.export(AbstractDelegateProtocolInterceptor.java:26)
	at com.taobao.hsf.region.service.impl.RegionProtocolInterceptor.export(RegionProtocolInterceptor.java:33)
	at com.taobao.hsf.plugins.eagleeye.protocol.EagleEyeProtocolInterceptor.export(EagleEyeProtocolInterceptor.java:37)
	at com.taobao.hsf.process.component.CodeployProtocolInterceptor.export(CodeployProtocolInterceptor.java:31)
	at com.taobao.hsf.feature.optimized.hessian.protocolinterceptor.OptimizedHessianProtocolInterceptor.export(OptimizedHessianProtocolInterceptor.java:29)
	at com.taobao.hsf.protocol.AbstractDelegateProtocolInterceptor.export(AbstractDelegateProtocolInterceptor.java:26)
	at com.taobao.hsf.plugins.spas.SpasProtocolInterceptor.export(SpasProtocolInterceptor.java:21)
	at com.taobao.hsf.protocol.DelayPublishProtocolInterceptor.export(DelayPublishProtocolInterceptor.java:26)
	at com.taobao.hsf.metadata.store.MetadataReportProtocolInterceptor.export(MetadataReportProtocolInterceptor.java:46)
	at com.taobao.hsf.model.metadata.ServiceMetadata.export(ServiceMetadata.java:335)
	... 10 more
Stopping available components

其中使用了MyBatis-Plus作为持久层和Service的扩展,但是我直接在页面上下载的Demo也是运行不起来,错误是一样的

展开
收起
迷雾晨光 2020-11-12 10:26:21 3421 0
4 条回答
写回答
取消 提交回答
  • 启动参数要加-Dhsf.server.ip=127.0.0.1 手册和demo里都没说到这点,我也是折腾了好久才发现的 另外,如果taobao-hsf.sar用的dev-SNAPSHOT版本,也不用加这个选项 只能吐槽一句飘忽不定

    2022-06-22 16:49:16
    赞同 1 展开评论 打赏
  • 大佬,问题解决了吗?

    2022-04-07 09:29:48
    赞同 展开评论 打赏
  • 我想问下大兄弟,问题解决了没

    2022-03-19 23:56:44
    赞同 展开评论 打赏
  • 同样问题,即使是官方demo也是一样的异常。有解决的不?

    2020-12-22 12:28:44
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Java Spring Boot开发实战系列课程(第17讲):Spring Boot 2.0实战Docker容器Linux 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载