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
New Participant
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
  • 5584 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
New Participant
April 14, 2016

edubey wrote...

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

 

The feature pack works in AEM 5.6.1. But I am trying to find a way to implement it without the feature pack. Any suggestion?

kai6novice
New Participant
April 14, 2016

The reason why I create a class that extends WCMUse not only because I want to trigger the Java class via sightly, but also because WCMUse allow me to use getPageManager() and getResourceResolver(), so the Java code can interact with Node in AEM. How do I do that without extending WCMUse in AEM 5.6.1?

Thanks,

Kai

smacdonald2008
New Participant
April 11, 2016

You do not need Sightly to invoke a backend Java Service from a component's JSP. WCMUse is only used for Sightly, not for Java services that can be invoked from JSP logic. 

Read this article, it will give you the basics:

com.adobe.cq.KeyService keyService = sling.getService(com.adobe.cq.KeyService.class);
keyService.setKey(10) ; 

See:

https://helpx.adobe.com/experience-manager/using/first-osgi.html

kai6novice
New Participant
April 11, 2016

If there is no way to use WCMUse in AEM5.6.1, what is the recommended way to implement custom code in AEM 5.6.1? Do I re-implement my Java code in JSP? Or is there other way to trigger Java code in AEM 5.6.1?

edubey
edubeyAccepted solution
New Participant
April 11, 2016

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