Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Unable to compile jsp importing bundle

Avatar

Level 1

Hi,

This is my first time working on Adobe AEM. I have followed some tutorials and created the osgi bundle which exposes a Service Component. The bundle installs and deploys without any errors, but when I test it out in one of the existing geometrix sites by importing the class and package. I am getting jsp compilation errors. Anything I am missing here.

 

Here is my code

 


package com.fca.service;

import org.apache.felix.scr.annotations.Service;
import org.apache.felix.scr.annotations.Component;

@Component
@Service
public class FCAServiceImpl implements FCAService {

    @Override
    public String sayHello(String val){

        return "FCA Service says: " +val ;
    }
}

serviceComponents.xml

 

<?xml version="1.0" encoding="UTF-8"?><components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
    <scr:component enabled="true" immediate="true" name="com.fca.service.FCAServiceImpl">
     <implementation class="com.fca.service.FCAServiceImpl"/>
        <service servicefactory="false">
                <provide interface="com.fca.service.FCAService"/>
        </service>
       
        <property name="service.pid" value="com.fca.service.FCAServiceImpl"/>
    </scr:component>
</components>

 

 

MANIFEST file

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: fcaservice
Bundle-SymbolicName: fcaservice
Bundle-Version: 1.0.0.SNAPSHOT
Bundle-Activator: com.fca.service.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: com.adobe.cq;uses:="org.slf4j,org.osgi.framework,org.osg
 i.service.component";version="1.0.0.SNAPSHOT"
Import-Package: org.osgi.framework;version="[1.5,2)",org.osgi.service.co
 mponent;version="[1.1,2)",org.slf4j;version="[1.5,2)"
Service-Component: OSGI-INF/serviceComponents.xml

 

my jsp code

 

<%@page session="false"%><%--

  ADOBE CONFIDENTIAL
  __________________

   Copyright 2011 Adobe Systems Incorporated
   All Rights Reserved.

  NOTICE:  All information contained herein is, and remains
  the property of Adobe Systems Incorporated and its suppliers,
  if any.  The intellectual and technical concepts contained
  herein are proprietary to Adobe Systems Incorporated and its
  suppliers and are protected by trade secret or copyright law.
  Dissemination of this information or reproduction of this material
  is strictly forbidden unless prior written permission is obtained
  from Adobe Systems Incorporated.
  --%><%
%><%@include file="/libs/foundation/global.jsp" %><%
%>
<sling:defineObjects />
<%@page import="java.util.Collections,
                  java.util.Comparator,
                  java.util.Iterator,
                  java.util.List,
                  java.util.LinkedList,
                  org.apache.sling.api.resource.ResourceResolver,
                  org.apache.sling.api.resource.ResourceUtil,
                  com.day.cq.wcm.webservicesupport.ConfigurationManager,
                  com.day.cq.wcm.webservicesupport.ServiceConstants,
                  com.day.cq.wcm.webservicesupport.Service,
                  com.day.cq.wcm.webservicesupport.ServiceLibFinder,
                com.fca.service.*"
%>
<%
                          com.fca.service.FCAService fca = sling.getService(com.fca.service.FCAService.class);
                            fca.sayHello("FCA");

ServiceLibFinder slf = sling.getService(ServiceLibFinder.class);
List<String> componentReferences = slf.getComponentReferences(pageProperties.getInherited("cq:cloudserviceconfigs", new String[] {}));
for ( String componentReference : componentReferences ) {
    %><cq:include path="cloudservice" resourceType="<%= componentReference %>"/><%
}%>

1 Accepted Solution

Avatar

Correct answer by
Level 10

I assume that FCAService is an interface you have defined? 

Try restarting AEM and see if a reboot helps AEM locate the bundle. 

Do you have other classes in the Java package. Try creating a new package and make it unique. Sometimes if a package is used a lot - this happens - a weird issue. 

View solution in original post

8 Replies

Avatar

Level 1


An error occurred at line: 35 in the jsp file: /libs/cq/cloudserviceconfigs/components/servicecomponents/servicecomponents.jsp
com.fca.service.FCAService cannot be resolved to a type
32:                 com.fca.service.*"
33: %>
34: <%
35:                           com.fca.service.FCAService fca = sling.getService(com.fca.service.FCAService.class);
36:                             fca.sayHello("FCA");
37: 
38: ServiceLibFinder slf = sling.getService(ServiceLibFinder.class);


An error occurred at line: 35 in the jsp file: /libs/cq/cloudserviceconfigs/components/servicecomponents/servicecomponents.jsp
com.fca.service.FCAService cannot be resolved to a type
32:                 com.fca.service.*"
33: %>
34: <%
35:                           com.fca.service.FCAService fca = sling.getService(com.fca.service.FCAService.class);
36:                             fca.sayHello("FCA");
37: 
38: ServiceLibFinder slf = sling.getService(ServiceLibFinder.class);

    at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:388)
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:171)
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:463)
    at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:533)
    at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:44)
    at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:77)
    at com.day.cq.personalization.impl.TargetComponentFilter.doFilter(TargetComponentFilter.java:96)
    at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68)
    at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilterWithErrorHandling(WCMDebugFilter.java:182)
    at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:149)
    at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68)
    at com.day.cq.wcm.core.impl.WCMComponentFilter.doFilter(WCMComponentFilter.java:259)
    at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68)
    at com.day.cq.wcm.core.impl.WCMDeveloperModeFilter.doFilterWithErrorHandling(WCMDeveloperModeFilter.java:162)
    at com.day.cq.wcm.core.impl.WCMDeveloperModeFilter.doFilter(WCMDeveloperModeFilter.java:133)
    at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68)
    at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:282)
    at org.apache.sling.engine.impl.SlingRequestProcessorImpl.dispatchRequest(SlingRequestProcessorImpl.java:322)

Avatar

Level 10

Is FCAService listed in your bundle ?

If you goto /system/console/bundle and expand your bundle do you see a serviceId for this Service ??

Also, I dont see 'com.fca.service' package listed in the Export-Package in a manifest file. It has to be present in order to be available to be referred by any external places.

Avatar

Level 1

Yes I do see the Id. Just added in the export package as well. Still see the same error

 

                                             
Symbolic Namefcaservice
Version1.0.0.SNAPSHOT
Bundle Locationinputstream:fca-service-1-SNAPSHOT.jar
Last ModificationFri Apr 01 18:43:02 CDT 2016
Start Level20
Exported Packagescom.adobe.cq,version=0.0.0
com.fca.service,version=1.0.0.SNAPSHOT
Imported Packagesorg.osgi.framework,version=1.8.0 from org.apache.felix.framework (0)
org.osgi.service.component,version=1.3.0 from org.apache.felix.scr (31)
org.slf4j,version=1.7.6 from slf4j.api (22)
Service ID 3510Types: com.fca.service.FCAService
Service PID: com.fca.service.FCAServiceImpl
Component Name: com.fca.service.FCAServiceImpl
Component ID: 2651
Manifest HeadersBundle-Activator: com.fca.service.Activator
Bundle-ManifestVersion: 2
Bundle-Name: fcaservice
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: fcaservice
Bundle-Version: 1.0.0.SNAPSHOT
Export-Package: com.adobe.cq, com.fca.service; uses:="org.slf4j, org.osgi.framework, org.osgi.service.component"; version="1.0.0.SNAPSHOT"
Import-Package: org.osgi.framework; version="[1.5, 2)", org.osgi.service.component; version="[1.1, 2)", org.slf4j; version="[1.5, 2)"
Manifest-Version: 1.0
Service-Component: OSGI-INF/serviceComponents.xml
Used Services
Declarative Service Components

Avatar

Correct answer by
Level 10

I assume that FCAService is an interface you have defined? 

Try restarting AEM and see if a reboot helps AEM locate the bundle. 

Do you have other classes in the Java package. Try creating a new package and make it unique. Sometimes if a package is used a lot - this happens - a weird issue. 

Avatar

Level 1

Thanks for all the help. The issue is resolved.

Avatar

Level 1

Hey! Can you tell me how was the problem resolved? I am facing the same issue.

Avatar

Level 1

Hey! I am facing the same issue and cannot find any solution in the replies. Can you tell me how did you resolve it?