Search code examples
nexussonatypenexus3

Does Nexus accept Groovy strings in script?


After running a groovy script as task to create a role with:

security.addRole(// id
                 roleDeveloper, 
                 // name
                 roleDeveloper, 
                 // description
                 "A developer on ${repoCap} group",
                 // privileges
                 ["nx-repository-view-maven2-${repo}-dependencies-browse",
                  "nx-repository-view-maven2-${repo}-dependencies-read"],
                 // roles
                 ["dw-all-public-repos"])

I can't access to the roles menu. I get the following error:

com.orientechnologies.orient.core.exception.ODatabaseException: Error on deserialization of Serializable DB name="security"
[...]
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.GStringImpl
  at java.net.URLClassLoader.findClass(URLClassLoader.java:381) [na:1.8.0_91]
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424) [na:1.8.0_91]
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [na:1.8.0_91]
  at org.apache.felix.framework.BundleWiringImpl.doImplicitBootDelegation(BundleWiringImpl.java:1782) [na:na]
  at org.apache.felix.framework.BundleWiringImpl.searchDynamicImports(BundleWiringImpl.java:1717) [na:na]
  at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1552) [na:na]
  at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79) [na:na]
  at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018) [na:na]

After running several tests (with and without String interpolations) on several version of Nexus (3.x) it looks like String interpolations are supported for some parameters but not for privileges parameter.

Is it a known issue ?

Now that my Roles menu is inaccessible due to this above error is there a way to fix it ? (I tried to remove it with a script but it failed because delete perform a load first)


Solution

  • Sorry for the problems Alexandre. It looks like you'll have to connect to the database directly in order to fix the problematic records. Instructions for how to do this with Nexus offline are here: https://support.sonatype.com/hc/en-us/articles/115002930827-Accessing-the-OrientDB-Console

    In particular the database you're looking to connect to is 'security':

    connect plocal:data/db/security admin admin
    

    And the tables you will need to inspect/delete from are 'privilege' and 'role'. I'll keep an eye out here in case you run into problems or have any followup questions.