Getting "Cannot be resolved to a type" error on java files | Community
Skip to main content
New Participant
May 10, 2019

Getting "Cannot be resolved to a type" error on java files

  • May 10, 2019
  • 1 reply
  • 17905 views

Hi,

I'm upgrading to aem6.4 and r7 annotations in project.  We are getting below common error on difference java files on different applications.

the bold lines are the common error that we are getting in different files across difference applications.  The line no. 39 has below line only,

Page page = currentPage;

In every application wherever we use currentPage object it throws a error "cannot be resolved to a type".

Below is the java file where i'm facing error,

Environment : AEM 6.4.4

Any suggestion on this would be more helpful.

Thanks,

Velu

1 reply

Radha_Krishna_N
New Participant
May 15, 2019

Add the package containing your java class to the bundle plugin configuration in the pom file.

Apache Felix - Apache Felix Maven Bundle Plugin (BND)

<plugin>

    <groupId>org.apache.felix</groupId>

    <artifactId>maven-bundle-plugin</artifactId>

    <extensions>true</extensions>

    <configuration>

        <exportScr>true</exportScr>

        <instructions>

            ...

            <Export-Package>

                com.myProject.myProjectchat.global.*

            </Export-Package>

            ...

        </instructions>

    </configuration>

    ...

</plugin>

New Participant
July 23, 2022

Hi guys i am facing below error pls help me 

 

New Participant
October 2, 2023

You are importing the wrong package. 

 

One of your Java Classes is likely importing ...

import jdk.internal.loader.Resource

... instead, import

import org.apache.sling.api.resource.Resource;