Org.apache.commons.lang is internal and is not available for export

I’m porting my plugin to Confluence 9.0 and I get this error on load. As suggested I did the command:

atlas-mvn dependency:tree -Dincludes=org.apache.commons:commons-lang

And the result is: [INFO] — dependency:3.7.0:tree (default-cli) @ ccac —

I think this means that this dependency is not included in my build. So why is the “internal” error displayed on load?

Btw my pom is:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>com.go2group</groupId>
  <artifactId>ccac</artifactId>
  <version>3.19.4</version>

  <packaging>atlassian-plugin</packaging>

  <name>Client Certificate Authenticator for Confluence</name>
  <description>CAC/PIV Authentication with Confluence</description>

  <organization>
    <name>Goldfinger Holdings</name>
    <url>http://www.goldfingerholdings.com/</url>
  </organization>

  <issueManagement>
    <system>Goldfinger Holdings JIRA Service Desk</system>
    <url>https://jira.goldfingerholdings.com/plugins/servlet/desk/portal/1</url>
  </issueManagement>

  <developers>
    <developer>
      <name>Timothy Chin</name>
      <email>tchin@goldfingerholdings.com</email>
      <roles></roles>
    </developer>
  </developers>

  <dependencies>
    <!-- Confluence Dependency -->
    <dependency>
      <groupId>com.atlassian.confluence</groupId>
      <artifactId>confluence</artifactId>
      <version>${confluence.version}</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-lang</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <!-- Confluence License Dependency -->
    <dependency>
      <groupId>com.atlassian.extras</groupId>
      <artifactId>atlassian-extras-core</artifactId>
      <version>3.3.0</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.atlassian.sal</groupId>
      <artifactId>sal-api</artifactId>
      <version>3.0.2</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.atlassian.plugin</groupId>
      <artifactId>atlassian-spring-scanner-annotation</artifactId>
      <version>${atlassian.spring.scanner.version}</version>
      <scope>provided</scope>
    </dependency>
    <!--
    <dependency>
      <groupId>com.atlassian.plugin</groupId>
      <artifactId>atlassian-spring-scanner-runtime</artifactId>
      <version>${atlassian.spring.scanner.version}</version>
      <scope>compile</scope>
    </dependency>
    -->
    <dependency>
      <groupId>javax.inject</groupId>
      <artifactId>javax.inject</artifactId>
      <version>1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>2.0.16</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>net.sf.opencsv</groupId>
      <artifactId>opencsv</artifactId>
      <version>2.3</version>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <scope>provided</scope>  <!--CCA-11 - Package in the jar per https://developer.atlassian.com/server/confluence/get-your-apps-ready-for-gray-api-removal/#runtime-changes-in-9-0-->
      <version>33.3.0-jre</version>
    </dependency>
    <!--<dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <scope>compile</scope>  &lt;!&ndash;CCA-11 - Package in the jar per https://developer.atlassian.com/server/confluence/get-your-apps-ready-for-gray-api-removal/#runtime-changes-in-9-0&ndash;&gt;
      <version>3.17.0</version>
    </dependency>-->
    <dependency>
      <groupId>com.atlassian.soy</groupId>
      <artifactId>soy-template-renderer-api</artifactId>
      <version>7.0.2</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>commons-fileupload</groupId>
    <artifactId>commons-fileupload</artifactId>
    <version>1.2.1</version>
    <scope>provided</scope>
  </dependency>
    <dependency>
      <groupId>com.atlassian.plugins.rest</groupId>
      <artifactId>atlassian-rest-common</artifactId>
      <version>1.0.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.4</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>javax.xml.bind</groupId>
      <artifactId>jaxb-api</artifactId>
      <version>2.1</version>
      <scope>compile</scope>
    </dependency>

    <!-- WIRED TEST RUNNER DEPENDENCIES -->
    <dependency>
      <groupId>com.atlassian.plugins</groupId>
      <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
      <version>${plugin.testrunner.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.ws.rs</groupId>
      <artifactId>jsr311-api</artifactId>
      <version>1.1.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.11.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-all</artifactId>
      <version>1.10.19</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>4.5.14</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <distributionManagement>
    <repository>
        <id>nexus</id>
        <url>https://repo.connectall.com/repository/maven-releases/</url>
        <layout>default</layout>
    </repository>
    <snapshotRepository>
        <id>nexus</id>
        <url>https://repo.connectall.com/repository/maven-snapshots/</url>
    </snapshotRepository>
  </distributionManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>confluence-maven-plugin</artifactId>
        <version>${amps.version}</version>
        <extensions>true</extensions>
        <configuration>
          <productVersion>${confluence.version}</productVersion>
          <productDataVersion>${confluence.data.version}</productDataVersion>
          <enableQuickReload>true</enableQuickReload>
          <allowGoogleTracking>false</allowGoogleTracking>
          <!-- See here for an explanation of default instructions: -->
          <!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
          <instructions>
            <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
            <!-- Add package to export here -->
            <!-- Add package import here -->
            <banningExcludes>
              <exclude>com.google.code.gson:gson</exclude>
              <exclude>commons-io:commons-io</exclude>
              <exclude>org.apache.commons:commons-lang</exclude>
            </banningExcludes>
            <Import-Package>
              org.springframework.osgi.*;resolution:="optional",
              org.eclipse.gemini.blueprint.*;resolution:="optional",
              com.atlassian.sal.api.*;resolution:="optional",
              com.atlassian.soy.*;resolution:="optional",
              com.atlassian.inject.*;resolution:="optional",
              sun.misc.*;resolution:="optional",
              au.com.bytecode.opencsv.*;resolution:="optional",
              com.sun.grizzly.*;resolution:="optional",
              com.sun.xml.*;resolution:="optional",
              javax.*;resolution:="optional",
              org.apache.tools.*;resolution:="optional",
              org.jvnet.*;resolution:="optional",
              org.slf4j.*;resolution:="optional",
              *
            </Import-Package>
            <!-- Ensure plugin is spring powered -->
            <Spring-Context>*</Spring-Context>
          </instructions>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.atlassian.plugin</groupId>
        <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
        <version>${atlassian.spring.scanner.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>atlassian-spring-scanner</goal>
            </goals>
            <phase>process-classes</phase>
          </execution>
        </executions>
        <configuration>
          <scannedDependencies>
            <dependency>
              <groupId>com.atlassian.plugin</groupId>
              <artifactId>atlassian-spring-scanner-external-jar</artifactId>
            </dependency>
          </scannedDependencies>
          <verbose>false</verbose>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.9</version>
        <configuration>
          <argLine>-Xmx256M --add-opens java.base/java.lang=ALL-UNNAMED</argLine>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <properties>
    <!--<atlassian.plugin.key>G2G-CAC-CONF</atlassian.plugin.key>
    <confluence.version>7.5.1</confluence.version>
    <amps.version>8.0.2</amps.version>
    <plugin.testrunner.version>2.0.1</plugin.testrunner.version>
    <atlassian.spring.scanner.version>2.1.7</atlassian.spring.scanner.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>-->
    <confluence.version>9.0.3</confluence.version>
    <confluence.data.version>8.5.4</confluence.data.version>
    <amps.version>9.0.2</amps.version>
    <plugin.testrunner.version>2.0.9</plugin.testrunner.version>
    <atlassian.spring.scanner.version>2.2.4</atlassian.spring.scanner.version>
    <!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
    <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>

    <debug.analytics>false</debug.analytics>
    <product.jvmArgs>-Xmx2048m -Datlassian.darkfeature.atlassian.authentication.include.stacktrace.in.error.messages=true -Datlassian.authentication.debug.analytics=${debug.analytics}</product.jvmArgs>
    <maven.javadoc.skip>true</maven.javadoc.skip>

    <gitlab.project.id>16618205</gitlab.project.id>
  </properties>
</project>

I don’t totally understand the question, but isn’t this true that P7 requires you to use “lang3” instead of “lang”?

Hello, we are currently facing an OSGI-related issue (similar to this) with our Jira v10.0.1 instance while developing a plugin. On previous JIRA versions it worked fine.

error:
Caused by: org.osgi.framework.BundleException: Unable to resolve com.sykorait.jira.plugins.USU-Service-Management-Connector [277](R 277.0): missing requirement [com.sykorait.jira.plugins.USU-Service-Management-Connector [277](R 277.0)] osgi.wiring.package; (osgi.wiring.package=org.apache.commons.lang) Unresolved requirements: [[com.sykorait.jira.plugins.USU-Service-Management-Connector [277](R 277.0)] osgi.wiring.package; (osgi.wiring.package=org.apache.commons.lang)]

In our plugin pom.xml, we have included the following dependency:

 <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <scope>compile</scope> 
      <!-- tried "provided" also -->
      <version>3.17.0</version>
</dependency>

and upon inspecting the OSGI browser, we can see that this package (org.apache.commons.lang, lang3) is indeed provided by the “System Bundle”.

Has anyone else faced this issue with OSGI package resolution in the newer Jira version? Would appreciate any guidance or suggestions for resolving this.

Thanks in advance!

Exports from the system bundle are no longer all available to apps, this change came in with Platform 7 and restrictions on “Grey APIs”

A package can be exported by the system bundle, but unavailable for import in apps, this is intentional with Platform 7.

When this happens, you’ll see a warning in the logs telling you.

I recommend reading the hundreds of replies in the threads relating to platform 7, which should get you up to speed.

For dependencies no longer available for import from the platform, you must bundle them within your app, using compile scope. Commons Lang 3 might be exported for apps, this is something you’d need to verify, and then swap usage if so.

2 Likes

Apps still using the old school <component> XML configuration will also have OSGi issues on Platform 7. Usually you need to port the app to use either Spring Scanner, or Spring Java Configuration.

You’ll see some commentary on this in the linked threads.

I found the solution!!

I added this dependency to my pom:

<dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.1</version>
      <scope>compile</scope>
    </dependency>

And to the <import-package> section I added this:

org.apache.commons.lang.*;resolution:="optional",