Open Supemelon opened 2 years ago
新建GULE(java)模式任务,传任务参数时报错,不传能执行成功;url为内部调用地址 public class DemoGlueJobHandler extends IJobHandler {
private RestTemplate restTemplate=new RestTemplate();
private String url="";
@Override
public void execute() throws Exception {
restTemplate.exchange(url, HttpMethod.GET, null, new ParameterizedTypeReference<String>() {
});
}
}
2022-08-23 16:05:08 [com.xxl.job.core.thread.JobThread#run]-[133]-[xxl-job, JobThread-5-1661241908084] ----------- xxl-job job execute start ----------- ----------- Param:1,163 2022-08-23 16:05:08 [com.xxl.job.core.handler.impl.GlueJobHandler#execute]-[25]-[xxl-job, JobThread-5-1661241908084] ----------- glue.version:1661241899000 ----------- 2022-08-23 16:05:08 [com.xxl.job.core.thread.JobThread#run]-[204]-[xxl-job, JobThread-5-1661241908084] ----------- JobThread Exception:groovy.lang.MissingPropertyException: No such property: jobParam for class: com.xxl.job.service.handler.DemoGlueJobHandler at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:65) at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:87) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:341) at com.xxl.job.service.handler.DemoGlueJobHandler.execute(Script_67a286cb7b850c33f26fbbde9d5f13b5.groovy:19) at com.xxl.job.core.handler.impl.GlueJobHandler.execute(GlueJobHandler.java:26) at com.xxl.job.core.thread.JobThread.run(JobThread.java:166)
----------- xxl-job job execute end(error) ----------- 2022-08-23 16:05:08 [com.xxl.job.core.thread.TriggerCallbackThread#callbackLog]-[197]-[xxl-job, executor TriggerCallbackThread] ----------- xxl-job job callback finish.
可以把代码脱敏后全部贴出来。我遇到过类似的情况,一般是由于代码里有没有import一些类导致的。可以自己在本地IDE中把所有import的内容全部贴到WEB IDE里。
可以把代码脱敏后全部贴出来。我遇到过类似的情况,一般是由于代码里有没有import一些类导致的。可以自己在本地IDE中把所有import的内容全部贴到WEB IDE里。
package com.xxl.job.service.handler;
import com.xxl.job.core.handler.IJobHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpMethod; import org.springframework.web.client.RestTemplate;
public class DemoGlueJobHandler extends IJobHandler {
private RestTemplate restTemplate=new RestTemplate();
private String url="";
@Override
public void execute() throws Exception {
restTemplate.exchange(url, HttpMethod.GET, null, new ParameterizedTypeReference<String>() {
});
}
}
@linziwei1997
这是我传参后的执行日志:
2022-08-24 20:28:17 [com.xxl.job.core.thread.JobThread#run]-[133]-[xxl-job, JobThread-2-1661344097245] ----------- xxl-job job execute start ----------- ----------- Param:1,163 2022-08-24 20:28:17 [com.xxl.job.core.handler.impl.GlueJobHandler#execute]-[25]-[xxl-job, JobThread-2-1661344097245] ----------- glue.version:1661343855000 ----------- 2022-08-24 20:28:17 [com.xxl.job.core.thread.JobThread#run]-[179]-[xxl-job, JobThread-2-1661344097245] ----------- xxl-job job execute end(finish) ----------- ----------- Result: handleCode=200, handleMsg = null 2022-08-24 20:28:17 [com.xxl.job.core.thread.TriggerCallbackThread#callbackLog]-[197]-[xxl-job, executor TriggerCallbackThread] ----------- xxl-job job callback finish.
代码原文: `package com.xxl.job.service.handler;
import com.xxl.job.core.handler.IJobHandler;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpMethod; import org.springframework.web.client.RestTemplate;
public class DemoGlueJobHandler extends IJobHandler {
private RestTemplate restTemplate = new RestTemplate();
private String url = "http://www.baidu.com";
@Override
public void execute() throws Exception {
restTemplate.exchange(url, HttpMethod.GET, null, new ParameterizedTypeReference<String>() {
});
}
} `
@zhangjinyang 刚试了下又可以了 也没改过啥突然就好了
Please answer some questions before submitting your issue. Thanks!
Which version of XXL-JOB do you using?
Expected behavior
Actual behavior
Steps to reproduce the behavior
Other information