开发者社区> 问答> 正文

Elastic-job?报错

各位大神,刚学习使用elast-job,使用javacode启动没有问题,根据安装开发指南使用spring启动的时候报错如下:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler#0': Invocation of init method failed; nested exception is com.dangdang.ddframe.job.reg.exception.RegException: java.lang.IllegalArgumentException: Invalid path string "//config" caused by empty node name specified @1
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1512)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:633)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
	at com.qzg.scheduler.MainSpring.main(MainSpring.java:11)
Caused by: com.dangdang.ddframe.job.reg.exception.RegException: java.lang.IllegalArgumentException: Invalid path string "//config" caused by empty node name specified @1
	at com.dangdang.ddframe.job.reg.exception.RegExceptionHandler.handleException(RegExceptionHandler.java:52)
	at com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter.isExisted(ZookeeperRegistryCenter.java:209)
	at com.dangdang.ddframe.job.lite.internal.storage.JobNodeStorage.isJobNodeExisted(JobNodeStorage.java:62)
	at com.dangdang.ddframe.job.lite.internal.config.ConfigurationService.find(ConfigurationService.java:85)
	at com.dangdang.ddframe.job.lite.internal.config.ConfigurationService.checkConflictJob(ConfigurationService.java:77)
	at com.dangdang.ddframe.job.lite.internal.config.ConfigurationService.persist(ConfigurationService.java:70)
	at com.dangdang.ddframe.job.lite.internal.schedule.SchedulerFacade.updateJobConfiguration(SchedulerFacade.java:103)
	at com.dangdang.ddframe.job.lite.api.JobScheduler.init(JobScheduler.java:105)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1638)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1579)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
	... 12 more
Caused by: java.lang.IllegalArgumentException: Invalid path string "//config" caused by empty node name specified @1
	at org.apache.curator.utils.PathUtils.validatePath(PathUtils.java:102)
	at org.apache.curator.utils.PathUtils.validatePath(PathUtils.java:37)
	at org.apache.curator.utils.ZKPaths.fixForNamespace(ZKPaths.java:105)
	at org.apache.curator.framework.imps.NamespaceImpl.fixForNamespace(NamespaceImpl.java:104)
	at org.apache.curator.framework.imps.CuratorFrameworkImpl.fixForNamespace(CuratorFrameworkImpl.java:594)
	at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:151)
	at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:39)
	at com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter.isExisted(ZookeeperRegistryCenter.java:205)
	... 25 more

求帮忙看看

展开
收起
爱吃鱼的程序员 2020-06-08 13:28:46 2064 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    没遇到过,LZ可以参考下面的代码试试,只有1个分片的

     

    <reg:zookeeperid="regCenter"server-lists="${zookeeper.ip}:${zookeeper.port}"namespace="dd-job"base-sleep-time-milliseconds="1000"max-sleep-time-milliseconds="3000"max-retries="3"/><!--配置简单作业--><job:simpleid="elasticJobTask"class="com.maoshen.echo.task.ElasticJobTask"registry-center-ref="regCenter"cron="000/1**?"sharding-total-count="1"sharding-item-parameters="0=A"/>
    publicclassElasticJobTaskimplementsSimpleJob{privatestaticfinalLoggerLOGGER=LoggerFactory.getLogger(ElasticJobTask.class);@Overridepublicvoidexecute(ShardingContextcontext){LOGGER.info("{},shardingItem:{},totalCount:{}",context.getJobName(),context.getShardingItem(),context.getShardingTotalCount());LOGGER.info("{},{}",context.getJobName(),context.toString());switch(context.getShardingItem()){case0:LOGGER.info("ElasticJobTaskname:{}isstart",context.getJobName());default:break;}}}

     

    谢谢你我知道怎么回事了:<job:simple必须有id就是jobName

    谢谢,又有个新的疑问是,你那种方式是配置死的xml的job,我现在是动态的查询的job,使用代码动态生成的方式,但是有个地方卡住,就是在任务中@Autowired的时候不生效,求解决办法

    2020-06-08 13:29:02
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spark Cluster with Elasticsearch Inside 立即下载
Scaling Self Service Analytics with Databricks and Apache Spark 立即下载
Monitoring the Dynamic Resource Usage of Scala and Python Spark Jobs in Yarn 立即下载