How to compile a java class created in a component definition | Community
Skip to main content
ramanareddy438
New Participant
October 16, 2015
Solved

How to compile a java class created in a component definition

  • October 16, 2015
  • 9 replies
  • 3284 views

Hi All,

How can I compile a java class created under a component definition. I am trying to use a WCMUse class in sightly to get an object from java class which I created under the component definition. I tried another way of creating a WCMUse java class in eclipse multi-module project but it is throwing "No use provider could resolve identifier: com.pro.eLearning.core.impl.servlets.CourseDisplay" error. Please help me.

Please do let me know if you need anymore information.

Best Regards

M. Ramana Reddy

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 Runal_Trivedi

@Reference will only work with your OSGI Component java files. you won't be able to use @Reference in your AEM component classes that is extending WCMUse.

To get OSGI Component reference in WCMUse class, do the following:

- Runal

9 replies

smacdonald2008
New Participant
October 16, 2015

See the following community article. It talks about how to create a Sightly component that compiles a Java class that uses com.adobe.cq.sightly.WCMUse.

See:

Creating your first Adobe Experience Manager Sightly component

ramanareddy438
New Participant
October 16, 2015

Thanks for the reply. Actually if the java file don't have any @Reference annotation. it is working correctly. But If add that annotation then it is giving a compilation error "

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

"

Is there anything wrong I am doing here??? please help me.

Runal_Trivedi
Runal_TrivediAccepted solution
New Participant
October 16, 2015

@Reference will only work with your OSGI Component java files. you won't be able to use @Reference in your AEM component classes that is extending WCMUse.

To get OSGI Component reference in WCMUse class, do the following:

- Runal

Lokesh_Shivalingaiah
New Participant
October 16, 2015

it means that the interface that you have used with @reference is not present. 

are you using your own service or CQ service with @Reference ?

ramanareddy438
New Participant
October 16, 2015

I am using Adobe API' @Reference annotation. This error is coming when I use my OSGi bundle class file also BSLOKI.

ramanareddy438
New Participant
October 16, 2015

Thanks for reply Runal. Sorry for the silly question. How can i get FullyClassifiedBundleComponentClassPath. Right now I am having a class in org.company.module.classname. I am trying to use like this.

SlingScriptHelper sling = getSlingScriptHelper(); <fully qualified classname> helloService = sling.getService(<fuly qualified class name>.class);

Correct me if I am wrong. Are the FullyclassifiedBundleComponentClassPath and fullyQualifiedClassPath different?

please help me. Thanks.

Runal_Trivedi
New Participant
October 16, 2015

Yup its fullyQualified and not classified :) that was the typo mistake thanks for correcting.

Glad it helped you.

- Runal

ramanareddy438
New Participant
October 16, 2015

Runal.Trivedi wrote...

Yup its fullyQualified and not classified :) that was the typo mistake thanks for correcting.

Glad it helped you.

- Runal

 

 

I have my custom method in the service interface and implemented that method in the implementation class. But It is throwing error like the custom method undefined for the service. Is there anything I have to do here. There is a method in the interface which was created while creating the project by the aem plugin. If I call that method it i working like a charm. But not the methods added by me. Is there any process for adding the methods to the service interface??

Your Patience and Help are much appreciated.

Feike_Visser1
Employee
October 16, 2015

If you create a Java-class at component level, make sure the package is like apps.yourproject.components.yourcomponents.

It must match the location of the Java-class.