Sling servlet project compilation error | Community
Skip to main content
Level 2
April 11, 2018
Solved

Sling servlet project compilation error

  • April 11, 2018
  • 2 replies
  • 2320 views

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 using AJAX

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Antony679

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

2 replies

Antony679Author
Level 2
April 11, 2018

Any help in resolving this issue?

Antony679AuthorAccepted solution
Level 2
April 11, 2018

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