Java class extends WCMUse compile error (Only a type can be imported com.adobe.sightly.WCMUse resolves to a pakcage) | Community
Skip to main content
kai6novice
Level 2
April 11, 2016
Solved

Java class extends WCMUse compile error (Only a type can be imported com.adobe.sightly.WCMUse resolves to a pakcage)

  • April 11, 2016
  • 15 replies
  • 5590 views

Hi all,

    I wrote a Java class which extends WCMUse in AEM6. It compiles fine on AEM6. However, when I move my code to AEM5.6.1, and compile the code, I got the following error message:

"Only a type can be imported com.adobe.cq.sightly.WCMUse resolves to a package"

"WCMUse cannot be resolved to a type"

I thought maybe my local instance of AEM 5.6.1 doesn't have the necessary service pack. So I installed both security pack 1 and service pack 2 on my local instance of AEM 5.6.1. Restart the server, and I still got the same compiler error when I click Tools > Compile within crx/de in AEM 5.6.1.

Please let me know if you know how to resolve this issue.

Thanks,

Kai

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 edubey

These are sightly APIs which were introduced from 6.x onwards.

Although there is feature pack of sightly available in 5.6.1 but that is just to see sightly preview and wont support sightly apis completely

To get code working you need to use AEM 6+, Check release notes here https://docs.adobe.com/docs/en/aem/6-0/release-notes.html

15 replies

kai6novice
Level 2
April 14, 2016

Thanks for the link. I found this line on the article:

Note:

Calling jcrUtils.getRepository() is used from an external Java application. If you are using the JCR API from within an OSGi bundle, do not use this method. For information about using the JCR API from within an OSGi bundle, see Querying Adobe Experience Manager Data using the JCR API.

 

I believe the link I need is this one. 

http://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html

smacdonald2008
Level 10
April 14, 2016

You want to use JCR API within an OSGi bundle to do this use case. See this community artilce - where both read and write operations occur: 

http://scottsdigitalcommunity.blogspot.ca/2013/02/querying-adobe-experience-manager-data.html

Hope this helps clear up your doubts. 

smacdonald2008
Level 10
April 14, 2016

You are correct - i referenced same artilce

kai6novice
Level 2
April 14, 2016

On the article, it started the project with Maven, POM, Eclipse. However, I would like to do everything within CRX/DE. I don't seems to be able to get the @Reference (Apache Felix SCR annotation) to work if I simply code it in CRX/DE.

The "import org.apache.felix.scr.annotations.Reference;" give a compiler error:

  "Only a type can be imported org.apache.felix.scr.annotations.Reference resolves to a package"

If I remove the import line,  then I get the following compiler error on "@Reference":

Reference cannot be resolved to a type

If I remove the @Reference, then I get a NullPointerException error because resolverFactory is never defined.

Can I resolve all these problems in CRX/DE without transferring my work to Maven,Eclipse,POM.xml?

edubey
Level 10
April 15, 2016

Its not recommended to use crxde for java files or osgi bundle

You have to write code in any IDE ( can use eclispe or Intelj) where you will have all api and IDE auto completion and then deploy to AEM as an osgi bundle.