Uploaded image for project: 'EJB 3.0'
  1. EJB 3.0
  2. EJBTHREE-2131

timeout/ejb3-0 tests fails due to securityexception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • timeout
    • None
    • timeout:0.1.3

      When running the unit tests in ejb3-0 module of timeout, I see this SecurityException:

      java.security.AccessControlException: access denied (java.io.FilePermission /tmp/surefire8958002439537574919tmp read)
      at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
      at java.security.AccessController.checkPermission(AccessController.java:546)
      at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
      at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
      at java.io.File.exists(File.java:731)
      at org.apache.maven.surefire.booter.SurefireBooter.loadProperties(SurefireBooter.java:795)
      at org.apache.maven.surefire.booter.SurefireBooter.setSystemProperties(SurefireBooter.java:814)
      at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:915)
      access: access allowed (java.lang.RuntimePermission exitVM.1)

      The java.policy file (only the relevant section) is as follows:

      // for Maven
      grant codeBase "file:${maven.repo.local}/-" {
      permission java.security.AllPermission;
      };

      The maven.repo.local system property is set as follows in the timeout pom:

      <properties>
      <!-- per default maven.repo.local is null, so set up a sensible default -->
      <maven.repo.local>${user.home}/.m2/repository</maven.repo.local>
      </properties>

      and then used in surefire plugin as follows:

      <plugin>
      <artifactId>maven-surefire-plugin</artifactId>
      <configuration>
      <argLine>-Djava.security.manager -Djava.security.policy=${basedir}/src/test/resources/java.policy -Djava.security.debug=policy,failure,access -Dmaven.repo.local=${maven.repo.local}</argLine>
      </configuration>
      </plugin>

      On my system, the maven local repository is pointed to a custom path through settings.xml:

      <localRepository>/opt/maven/repository</localRepository>

      which causes this failure (since the codebase of the surefire jars doesn't match to $[user.home}/.m2/repository.

      Had a quick chat on #maven for a possible alternative to maven.repo.local which takes into account the settings.xml and found ${settings.localRepository}. Here's the relevant IRC discussion:

      (08:17:12 IST) Jaikiran: quick question about maven.repo.local system property that maven sets
      (08:17:18 IST) Jaikiran: i am using 2.0.9 maven
      (08:17:44 IST) Jaikiran: and in my settings.xml file i have set a custom value for localRepository element
      (08:18:02 IST) Jaikiran: i.e. instead of /home/me/.m2/repository i point it to /blah/maven/repo
      (08:18:17 IST) bsnyder left the room (quit: Ping timeout: 20 seconds).
      (08:18:17 IST) bsnyder_ is now known as bsnyder
      (08:18:38 IST) Jaikiran: but when i use ${maven.repo.local} property in surefire plugin configuration, i see that it passes /home/me/.m2/repository as the value
      (08:18:44 IST) Jaikiran: instead of the custom one
      (08:18:48 IST) Jaikiran: is this a known issue?
      (08:19:04 IST) bentmann: no, maven simply doesn't set maven.repo.local
      (08:19:12 IST) bentmann: it's a property the user may set
      (08:19:42 IST) Jaikiran: hmm, then i am confused
      (08:19:45 IST) Jaikiran: let me pastebin my config
      (08:20:24 IST) Jaikiran: line4 http://pastebin.com/Xbe67YDG
      (08:20:38 IST) Jaikiran: then in the testcase, i just do a system.getproperty for that prop
      (08:20:50 IST) Jaikiran: and i get /home/me/.m2/repository
      (08:22:56 IST) Jaikiran: bentmann: ignore me, in the parent pom i found this http://pastebin.com/Nr6qjTXn
      (08:23:03 IST) Jaikiran: sorry about the noise
      (08:23:32 IST) bentmann: you should try ${settings.localRepository}
      (08:23:43 IST) ***Jaikiran gives it a try
      (08:23:56 IST) bentmann: inside the surefire plugin config I mean
      (08:25:00 IST) tobrien left the room (quit: tobrien).
      benji bentmann
      (08:25:53 IST) Jaikiran: bentmann: excellent! that worked thanks
      (08:26:08 IST) Jaikiran: ~bentmann++
      (08:26:21 IST) bentmann: just be warned that ${settings.*} only works inside plugin configuration, not in the rest of the POM
      (08:27:01 IST) Jaikiran: i see.
      (08:27:12 IST) Jaikiran: luckily for me, that's where i want it

            jaikiran Jaikiran Pai (Inactive)
            jaikiran Jaikiran Pai (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: