security.AccessControlException Error

2019-07-15 16:39发布

When i used quartz trigger in backend java i am getting this error:

java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:382)
    at java.security.AccessController.checkPermission(AccessController.java:572)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at com.google.apphosting.runtime.security.CustomSecurityManager.checkPermission(CustomSecurityManager.java:55)
    at com.google.apphosting.runtime.security.CustomSecurityManager.checkAccess(CustomSecurityManager.java:136)
    at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
    at java.lang.Thread.init(Thread.java:391)
    at java.lang.Thread.init(Thread.java:349)
    at java.lang.Thread.<init>(Thread.java:532)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.<init>(SimpleThreadPool.java:510)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.<init>(SimpleThreadPool.java:498)
    at org.quartz.simpl.SimpleThreadPool.createWorkerThreads(SimpleThreadPool.java:288)
    at org.quartz.simpl.SimpleThreadPool.initialize(SimpleThreadPool.java:277)
    at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1273)
    at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1502)
    at org.quartz.impl.StdSchedulerFactory.getDefaultScheduler(StdSchedulerFactory.java:1518)
    at com.tiyaFdManager.backend.SimpleTrigger.SimpleTriggerNotification(SimpleTrigger.java:31)
    at com.tiyaFdManager.backend.RegisterUserDetails.RegisterUserDetails(RegisterUserDetails.java:70)
    at org.apache.jsp.mainpage_jsp._jspService(mainpage_jsp.java:82)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:59)
    at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:49)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:37)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:50)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:260)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:78)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:148)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:468)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:439)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:446)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:256)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:310)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:302)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:443)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:235)
    at java.lang.Thread.run(Thread.java:745)
16:24:13.781
Uncaught exception from servlet
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:382)
    at java.security.AccessController.checkPermission(AccessController.java:572)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at com.google.apphosting.runtime.security.CustomSecurityManager.checkPermission(CustomSecurityManager.java:55)
    at com.google.apphosting.runtime.security.CustomSecurityManager.checkAccess(CustomSecurityManager.java:136)
    at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
    at java.lang.Thread.init(Thread.java:391)
    at java.lang.Thread.init(Thread.java:349)
    at java.lang.Thread.<init>(Thread.java:532)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.<init>(SimpleThreadPool.java:510)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.<init>(SimpleThreadPool.java:498)
    at org.quartz.simpl.SimpleThreadPool.createWorkerThreads(SimpleThreadPool.java:288)
    at org.quartz.simpl.SimpleThreadPool.initialize(SimpleThreadPool.java:277)
    at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1273)
    at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1502)
    at org.quartz.impl.StdSchedulerFactory.getDefaultScheduler(StdSchedulerFactory.java:1518)
    at com.tiyaFdManager.backend.SimpleTrigger.SimpleTriggerNotification(SimpleTrigger.java:31)
    at com.tiyaFdManager.backend.RegisterUserDetails.RegisterUserDetails(RegisterUserDetails.java:70)
    at org.apache.jsp.mainpage_jsp._jspService(mainpage_jsp.java:82)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:59)
    at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:49)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:37)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:50)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:260)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:78)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:148)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:468)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:439)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:446)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:256)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:310)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:302)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:443)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:235)
    at java.lang.Thread.run(Thread.java:745)

Can anyone help me???

My code:

package com.tiyaFdManager.backend;

import org.quartz.CronScheduleBuilder; import org.quartz.CronTrigger; import org.quartz.JobDetail; import org.quartz.Scheduler; import org.quartz.SchedulerException; import org.quartz.impl.StdSchedulerFactory;

import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger;

import static org.quartz.JobBuilder.newJob; import static org.quartz.TriggerBuilder.newTrigger;


/**  * Created by Coko Tiya on 4/20/2016.  */ public class SimpleTrigger {
    Date startDate, endDate;
    Logger log;
    public void SimpleTriggerNotification(String startDateStr, String endDateStr){
        Scheduler scheduler = null;
        log = Logger.getLogger(RegisterUserDetails.class.getName());
        log.setLevel(Level.INFO);
        try {
            scheduler = StdSchedulerFactory.getDefaultScheduler();


        JobDetail job = newJob(pushNotificationJob.class)
                .withIdentity("cronJob", "testJob")
                .build();

        String startDateStr1 = "20/04/2016 16:00:00.0";
        String endDateStr1 = "20/04/2016 17:00:00.0";


        try {
            startDate = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.S").parse(startDateStr1);
            endDate = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.S").parse(endDateStr1);
        } catch (ParseException e) {
            e.printStackTrace();
        }


        CronTrigger cronTrigger = newTrigger()
                .withIdentity("trigger1", "testJob")
                .startAt(startDate)
                .withSchedule(CronScheduleBuilder.cronSchedule("0 0 12 19 1/3 ? * ").withMisfireHandlingInstructionDoNothing())
                .endAt(endDate)
                .build();

        scheduler.scheduleJob(job, cronTrigger);
        scheduler.start();
        } catch (SchedulerException e) {
            e.printStackTrace();
            log.info("getMessage" + e.getMessage());

        }

    } }

and i am calling this as:

 SimpleTrigger mSimpleTrigger = new SimpleTrigger();
 mSimpleTrigger.SimpleTriggerNotification(dat,matdate);

please help i am stuck. I didn't understand the issue..what is this servelet issue??

1条回答
ら.Afraid
2楼-- · 2019-07-15 17:05

Appengine had first class support for cron, which runs in a distributed context. You should use that.

The reason this fails is that appengine has a whitelist of Java classes your app can access, and creating a thread (using the API Quartz is using) is not permitted.

A timed job running on a background thread won't work in this environment, instances can come up and down as they please, and importantly you can't know how many nodes are running at any point in time.

查看更多
登录 后发表回答