Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Sling servlet project compilation error

Avatar

Level 2

Hi Team,

I'm doing below exercise. I created a new project and followed the steps given in below link and also created JSON bundle and installed it in AEM.

Adobe Experience Manager Help | Creating an AEM HTML Template Language Component that posts data usi...

However when I'm compiling/installing my project using Maven I'm getting below error.

[ERROR] core/servlets/SimpleServlet.java:[73,11] cannot find symbol

[ERROR] symbol:   class JSONObject

I have verified in system console that JSON bundle is active. And below is the Manifest file which I used to create and install JSON bundle.

Bundle-ManifestVersion: 2

Bundle-Name: SimpleJSON

Bundle-SymbolicName: simpleJSON

Bundle-Version: 1.0.0

Bundle-RequiredExecutionEnvironment: JavaSE-1.8

Import-Package: org.json.simple,org.json.simple.parser

Export-Package: org.json.simple,

org.json.simple.parser

To resolve this, I have added below dependency in POM file also but didn't worked out ( Removed this dependency in POM later).

<dependency>

<groupId>org.json</groupId>

<artifactId>json</artifactId>

<version>20180130</version>

</dependency>

However when I install the package "ajaxHTL.ui.apps-1.0-SNAPSHOT.zip" directly, i see the application works fine with servlet call successfully.

Also added this jar "json-simple-1.1.1.jar" to project build path in ecplise but still getting error when compiling or installing with Maven. ( Later removed this jar from build path)

So not sure what step I'm missing in my project.

Any help in resolving this compilation error and calling servlet?

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Level 2

I was able to resolve by adding below dependency in the POM file.

<dependency>

            <groupId>com.googlecode.json-simple</groupId>

            <artifactId>json-simple</artifactId>

            <version>1.1</version>

        </dependency>

however I couldn't install the bundle by running below Maven command. I had to install the bundle jar manually in the system console.

mvn -PautoInstallBundle clean install

View solution in original post

2 Replies

Avatar

Level 2

Any help in resolving this issue?

Avatar

Correct answer by
Level 2

I was able to resolve by adding below dependency in the POM file.

<dependency>

            <groupId>com.googlecode.json-simple</groupId>

            <artifactId>json-simple</artifactId>

            <version>1.1</version>

        </dependency>

however I couldn't install the bundle by running below Maven command. I had to install the bundle jar manually in the system console.

mvn -PautoInstallBundle clean install