Issue working with acscommons.io.jsonwebtoken - acscommons.io.jsonwebtoken in start level 20 but no bundle is exporting these for that start level. | Community
Skip to main content
Level 2
March 4, 2024
Solved

Issue working with acscommons.io.jsonwebtoken - acscommons.io.jsonwebtoken in start level 20 but no bundle is exporting these for that start level.

  • March 4, 2024
  • 2 replies
  • 4056 views

Hey guys,

I am working on AEMaaCS, trying to use acscommons.io.jsonwebtoken in a util located in core project.

In my uitl, I:

import acscommons.io.jsonwebtoken.Jwts;
import acscommons.io.jsonwebtoken.SignatureAlgorithm;

I am following the guide:

https://adobe-consulting-services.github.io/acs-aem-commons/pages/maven.html

In "all" project added:

<dependency>
<groupId>com.adobe.acs</groupId>
<artifactId>acs-aem-commons-content</artifactId>
<version>5.0.6</version>
<classifier>min</classifier>
<type>zip</type>
</dependency>

And

<embedded>
<groupId>com.adobe.acs</groupId>
<artifactId>acs-aem-commons-ui.apps</artifactId>
<type>zip</type>
<target>/apps/app-vendor-packages/application/install</target>
</embedded>
<embedded>
<groupId>com.adobe.acs</groupId>
<artifactId>acs-aem-commons-ui.content</artifactId>
<type>zip</type>
<target>/apps/app-vendor-packages/content/install</target>
</embedded>
<embedded>
<groupId>com.adobe.acs</groupId>
<artifactId>acs-aem-commons-all</artifactId>
<type>zip</type>
<target>/apps/app-vendor-packages/container/install</target>
<filter>true</filter>
<isAllVersionsFilter>true</isAllVersionsFilter>
</embedded>

In "core" project added:

<dependency>
<groupId>com.adobe.acs</groupId>
<artifactId>acs-aem-commons-bundle</artifactId>
<version>5.0.6</version>
<scope>provided</scope>
</dependency>

The project can be built locally, however, once deployed through the pipeline, it failed in Build Images phase, the log shows:

[api-regions-exportsimports] com.xxx:app-project.core:2024.304.1172654.0003818307: Bundle app-project.core:2024.304.1172654.0003818307 is importing package(s) acscommons.io.jsonwebtoken in start level 20 but no bundle is exporting these for that start level. (com.xxx:app-project.all:2024.304.1172654.0003818307)
[api-regions-exportsimports] com.xxx:app-project.core:2024.304.1172654.0003818307: Bundle app-project.core:2024.304.1172654.0003818307 is importing package(s) acscommons.io.jsonwebtoken in start level 20 but no bundle is exporting these for that start level. (com.xxx:app-project.all:2024.304.1172654.0003818307)
[api-regions-exportsimports] com.xxx:app-project.core:2024.304.1172654.0003818307: Bundle app-project.core:2024.304.1172654.0003818307 is importing package(s) acscommons.io.jsonwebtoken in start level 20 but no bundle is exporting these for that start level. (com.xxx:app-project.all:2024.304.1172654.0003818307)

 Am I missing something?

Thanks!

Best answer by HenryLiang

Found the solution for my project:

Add the following to all/pom.xml

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.2</version>
<scope>provided</scope>
</dependency>

And also:

<embedded>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<type>jar</type>
<target>/apps/xxx-vendor-packages/application/install</target>
</embedded>
<embedded>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<type>jar</type>
<target>/apps/xxx-vendor-packages/application/install</target>
</embedded>
<embedded>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<type>jar</type>
<target>/apps/xxx-vendor-packages/application/install</target>
</embedded>

In core/pom.xml:

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>

After all these, it built and worked well.

Thanks guys!

2 replies

SureshDhulipudi
Community Advisor
Community Advisor
March 4, 2024

The ACS AEM Commons library doesn't provide a acscommons.io.jsonwebtoken.SignatureAlgorithm class or package. If you're trying to work with JSON Web Tokens (JWTs) in AEM, you might want to use the Java JWT (JSON Web Token) library, also known as JJWT.

 

I don't see it here ; https://javadoc.io/doc/com.adobe.acs/acs-aem-commons-bundle/5.7.0/index.html

 

why don't you use

 

import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
 
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
Level 2
March 5, 2024

Hi I've tried this but jjwt seems to conflict with some libs and will lead to a server-side exception.

Is it possible to reuse:

acscommons.io.jsonwebtoken

 

 

Level 2
March 6, 2024

can you try explicit Export JAR statement in pom.xml

 

<executions>
<execution>
<id>bnd-process</id>
<goals>
<goal>bnd-process</goal>
</goals>
<configuration>
<bnd>
<![CDATA[
Import-Package: xxx
Export-Package :io.jsonwebtoken.*;target/dependency/jjwt-api-0.11.2.jar,target/dependency/jjwt-gson-0.11.2.jar,target/dependency/jjwt-impl-0.11.2.jar
]]>
</bnd>
</configuration>

</execution>
</executions>


Thanks Suresh,

May I know if this should be added to root pom.xml or core/pom.xml?

kautuk_sahni
Community Manager
Community Manager
March 7, 2024

@henryliang Did you find the suggestion helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni
HenryLiangAuthorAccepted solution
Level 2
March 7, 2024

Found the solution for my project:

Add the following to all/pom.xml

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.2</version>
<scope>provided</scope>
</dependency>

And also:

<embedded>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<type>jar</type>
<target>/apps/xxx-vendor-packages/application/install</target>
</embedded>
<embedded>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<type>jar</type>
<target>/apps/xxx-vendor-packages/application/install</target>
</embedded>
<embedded>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<type>jar</type>
<target>/apps/xxx-vendor-packages/application/install</target>
</embedded>

In core/pom.xml:

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>

After all these, it built and worked well.

Thanks guys!