Skip to main content
kai6novice
Level 2
Apr 11, 2016 3:59 PM UTC
Solved

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

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.
edubey
edubeyAccepted solution
Level 10
Apr 11, 2016 4:06 PM UTC

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

edubey
edubeyAccepted solution
Level 10
Apr 11, 2016 4:06 PM UTC

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

Translate
kai6novice
Level 2
Apr 11, 2016 4:24 PM UTC

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?

Translate
smacdonald2008
Level 10
Apr 11, 2016 4:56 PM UTC

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

Translate
kai6novice
Level 2
Apr 14, 2016 3:02 PM UTC

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

Translate
kai6novice
Level 2
Apr 14, 2016 3:03 PM UTC

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?

Translate
edubey
Level 10
Apr 14, 2016 3:26 PM UTC

As I mentioned earlier sighlty was introduced 6.0 onwards

Sightly API which u are using (WCMUse) will not be available in 5.6.1 and thus you cannot use

You have to use AEM 6+

Translate
kai6novice
Level 2
Apr 14, 2016 3:30 PM UTC

I understand that, my question is, how do custom Java class interact with AEM node (read, write) prior to AEM 6?

Translate
edubey
Level 10
Apr 14, 2016 3:36 PM UTC

You can write osgi service to read data or java  class

For osgi service alot of articles are available there, do check

http://blogs.adobe.com/kmossman/2012/04/osgi-sling-service-example.html

Translate
kai6novice
Level 2
Apr 14, 2016 3:49 PM UTC

Can you share an example of Java class creating new node or reading existing node in AEM?

Translate