无法将Quartz Scheduler绑定到RMI

时间:2019-12-24 02:18:08

标签: java spring rmi

我正在尝试为Quartzdesk创建SchedulerFactoryBean。当我使用JVM args启动应用程序时:出现以下错误。

    Caused by: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
        java.rmi.AccessException: Cannot modify this registry
Caused by: java.rmi.AccessException: Cannot modify this registry

这是我的Sping bean配置

@Bean
        public SchedulerFactoryBean scheduler(@Autowired DynamicPropUtil dynamicPropUtil,
                                              @Autowired @Qualifier("quartzDatasource") DataSource quartzDataSource) throws IOException {
            SchedulerFactoryBean schedulerFactory = new SchedulerFactoryBean();
            Resource policyFile = new ClassPathResource("quartz.properties");
            System.setProperty("java.security.policy", "file:///" + policyFile.getFile().getAbsolutePath());
            System.setSecurityManager(new SpringSecurityManager());
            schedulerFactory.setConfigLocation(new ClassPathResource("quartz.properties"));
            String schedulerName = dynamicPropUtil.getStr("org.quartz.scheduler.instanceName", "census-loader-scheduler");
            schedulerFactory.setSchedulerName(schedulerName);
            schedulerFactory.setDataSource(quartzDataSource);
            schedulerFactory.setTransactionManager(new DataSourceTransactionManager(quartzDataSource));
            schedulerFactory.setApplicationContextSchedulerContextKey("applicationContext");

            AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
            jobFactory.setApplicationContext(this.applicationContext);
            schedulerFactory.setJobFactory(jobFactory);
            schedulerFactory.setOverwriteExistingJobs(dynamicPropUtil.getBool("quartz.schedular.overwrite.jobs", false));
            schedulerFactory.setAutoStartup(dynamicPropUtil.getBool("quartz.scheduler.auto.start", true));
            schedulerFactory.setStartupDelay(dynamicPropUtil.getInt("quartz.scheduler.startup.delay", 30));
            schedulerFactory.setWaitForJobsToCompleteOnShutdown(dynamicPropUtil.getBool("quartz.scheduler.waitfor.shutdown", true));
            log.info("SchedulerFactoryBean : Created with name {}", schedulerName);

            return schedulerFactory;
        }

 JVM ARGS:
 -Dapp.environment=dev
 -Djava.rmi.server.hostname=localhost
 -Djavax.management.builder.initial=
 -Dcom.sun.management.jmxremote=true
 -Dcom.sun.management.jmxremote.port=1099
 -Dcom.sun.management.jmxremote.ssl=false
 -Dcom.sun.management.jmxremote.authenticate=false

0 个答案:

没有答案