Return-Path: X-Original-To: apmail-ant-user-archive@www.apache.org Delivered-To: apmail-ant-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 28D1ED850 for ; Sat, 1 Sep 2012 22:33:24 +0000 (UTC) Received: (qmail 58545 invoked by uid 500); 1 Sep 2012 22:33:23 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 58410 invoked by uid 500); 1 Sep 2012 22:33:22 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 58399 invoked by uid 99); 1 Sep 2012 22:33:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Sep 2012 22:33:22 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FSL_RCVD_USER,HTML_FONT_LOW_CONTRAST,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mperdikeas@gmail.com designates 209.85.214.45 as permitted sender) Received: from [209.85.214.45] (HELO mail-bk0-f45.google.com) (209.85.214.45) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Sep 2012 22:33:12 +0000 Received: by bkcji1 with SMTP id ji1so1692503bkc.4 for ; Sat, 01 Sep 2012 15:32:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=YTStuGfyjM2CRHSUt8UPqagQYd+yolWrmg1kYw/7pSg=; b=CVF/19t1UfGC7WfExcuavd7rhuCgNcgEuWByjxrRX2oV5s+0X/aghSAeyzLZMvHIau fgq+kx9rA04Rq+4m2CMjoeUehxuk48MiptTEWLUuyck9MkXl6ZXfJAoW6SYwRGkZWcJa uUULKXUkF1uEPQ5HzA5EZZOmeWcMVZa79hCpA/vGozrujntYIVilOJ5fAukrdy91A1zz ODKlFgQjidT3yck29eiFP/A1X+2xV82C3xo4fBcf+TjVMRTOO3COaABIWayJk3jU+c4x 3dxB4DJvtMjvZFlBocmgHGplJM2z1IIaHnAb7AKkrqDA84nMVrVU73P6jLUZS/MhbB6L NZjg== MIME-Version: 1.0 Received: by 10.204.154.151 with SMTP id o23mr5608699bkw.77.1346538772054; Sat, 01 Sep 2012 15:32:52 -0700 (PDT) Received: by 10.204.64.65 with HTTP; Sat, 1 Sep 2012 15:32:51 -0700 (PDT) Date: Sun, 2 Sep 2012 01:32:51 +0300 Message-ID: Subject: java.security.AccessControlException when using Ant, but runs ok when invoking java from console From: Menelaos Perdikeas To: user@ant.apache.org Content-Type: multipart/alternative; boundary=0015175d03942f44a304c8ab7d50 --0015175d03942f44a304c8ab7d50 Content-Type: text/plain; charset=UTF-8 I have the following *Ant < java >* task: When I run *Ant* the execution of the **task fails (see trace below my signature). When I copy-paste the echoed classpath and run my code from the command line with *java -classpath ..* the execution succeeds! I was advised that apparently I had to add some permissions to the Ant task and so I have as you can see above, but the problem persists. In both cases the same version of *java* is used. I have the book "Ant in Action" (Manning Press) but there's no mention about any Security Managers with Ant. So my questions are: [1] Why should Ant's task even bother with permissions and Security Managers? It is a long-established convention that running Java from the command line never sets any Security Managers. [2] How can I disable Ant's Security Manager or grant permissions that would ensure my Ant runs are the same as executing the code from the command line ? Menelaos. [java] java.lang.ExceptionInInitializerError [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194) [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:771) [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221) [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135) [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108) [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) [java] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [java] at java.lang.reflect.Method.invoke(Method.java:601) [java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) [java] at org.apache.tools.ant.Task.perform(Task.java:348) [java] at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) [java] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [java] at java.lang.reflect.Method.invoke(Method.java:601) [java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) [java] at org.apache.tools.ant.Task.perform(Task.java:348) [java] at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398) [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) [java] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [java] at java.lang.reflect.Method.invoke(Method.java:601) [java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) [java] at org.apache.tools.ant.Task.perform(Task.java:348) [java] at org.apache.tools.ant.Target.execute(Target.java:390) [java] at org.apache.tools.ant.Target.performTasks(Target.java:411) [java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399) [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1368) [java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1251) [java] at org.apache.tools.ant.Main.runBuild(Main.java:809) [java] at org.apache.tools.ant.Main.startAnt(Main.java:217) [java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) [java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109) [java] Caused by: java.lang.ExceptionInInitializerError [java] at TranslationClient.main(TranslationClient.java:5) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [java] at java.lang.reflect.Method.invoke(Method.java:601) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152) [java] ... 34 more [java] Caused by: net.sf.ehcache.CacheException: java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register") [java] at net.sf.ehcache.management.sampled.SampledMBeanRegistrationProvider.initialize(SampledMBeanRegistrationProvider.java:98) [java] at net.sf.ehcache.management.provider.MBeanRegistrationProviderImpl.initialize(MBeanRegistrationProviderImpl.java:63) [java] at net.sf.ehcache.CacheManager.doInit(CacheManager.java:454) [java] at net.sf.ehcache.CacheManager.init(CacheManager.java:374) [java] at net.sf.ehcache.CacheManager.(CacheManager.java:356) [java] at TranslationCache.(TranslationCache.java:10) [java] ... 41 more [java] Caused by: java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register") [java] at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366) [java] at java.lang.SecurityManager.checkPermission(SecurityManager.java:585) [java] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1848) [java] at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:322) [java] at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:512) [java] at net.sf.ehcache.management.sampled.SampledMBeanRegistrationProvider.registerCacheManagerMBean(SampledMBeanRegistrationProvider.java:118) [java] at net.sf.ehcache.management.sampled.SampledMBeanRegistrationProvider.initialize(SampledMBeanRegistrationProvider.java:95) [java] ... 46 more --0015175d03942f44a304c8ab7d50--