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

issue using frameworkfactory

Avatar

Level 4
I am using hudson build , it throwns an error Compiler Error: cannot find symbol symbol  : method getBundleContext() location: interface org.osgi.framework.Bundle. Please let me know  how to fix it . I  am usign the below in pom
 
<dependency>
<groupId>org.osgi.core</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
 <dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>5.0.1</version>
<!-- You aren't compiling against Felix, just using it at runtime -->
<scope>runtime</scope>
</dependency>
 
 
Thanks
1 Accepted Solution

Avatar

Correct answer by
Level 10

Are you using Maven and Adobe Archetype as part of using this tool?  I have not heard of community using this tool. I am wondering if this is compatibility issues with this tool and OSGi libs. 

I would recommend using Maven and Adobe Archetype - there are no issues with these  OSGi libs. See: 

Creating your first AEM Service using an Adobe Maven Archetype project

View solution in original post

6 Replies

Avatar

Level 4

I am facing issue similar to http://stackoverflow.com/questions/32294587/what-maven-dependency-do-i-need-to-load-an-osgi-framewor...

 

but the solution mentioned is not working for me using hudson.

 

Please provide inputs

Avatar

Correct answer by
Level 10

Are you using Maven and Adobe Archetype as part of using this tool?  I have not heard of community using this tool. I am wondering if this is compatibility issues with this tool and OSGi libs. 

I would recommend using Maven and Adobe Archetype - there are no issues with these  OSGi libs. See: 

Creating your first AEM Service using an Adobe Maven Archetype project

Avatar

Level 4

I am using AEM5.6.1 and Maven with Adobe Archetype

I am using the below code see below issues coming up. It seems to be getting resolved in ecllispe but does not get resolved in Hudson build.I have added the required external jar in hudson still the issue is coming up

 

BundleContext bc= FrameworkUtil.getBundle(A.class).getBundleContext();

 

 

I tried using google with same problem but did solve the issue in Hudson.

https://www.google.co.in/?gfe_rd=cr&ei=ZSxyVqCmGYGHoAOI-augBw&gws_rd=ssl#q=annot+find+symbol+symbol+...

Avatar

Level 10

instead of using BundleContext you can load the context using @Reference

Avatar

Level 4

I tried using the below code.The code got complied but in the felix console i find that

the component is unstasified

Reference bundleContext    ["Unsatisfied","Service Name: org.osgi.framework.BundleContext","Multiple: single","Optional: mandatory","Policy: static","No Services bound"]

 

The exact code  i am using is. let me know if you have suggestions

 

public class A implements EventHandler, JobProcessor {
    
    @Reference
    private BundleContext bundleContext;
    
    Logger log = LoggerFactory.getLogger(this.getClass());
    
    @Override
    public void handleEvent(Event event) {
        if ((null != event && event.getTopic().equals(
                ReplicationAction.EVENT_TOPIC))) {
            // adopt the Sling's job model to guarantee execution
            if (EventUtil.isLocal(event)) {
                JobUtil.processJob(event, this);
            }
        }
    }

    @Override
    public boolean process(Event event) {
        //Bundle bundle=FrameworkUtil.getBundle(A.class);
        
        //BundleContext bundleContext = bundle.getBundleContext();
        String filter = "(process.label=testing)"; // the
                                                                                    
        @SuppressWarnings("rawtypes")
        ServiceReference[] serviceReferences = null;
        try {
            serviceReferences = bundleContext.getServiceReferences(
                    com.day.cq.workflow.exec.WorkflowProcess.class.getName(),
                    filter);
        } catch (Exception e) {
            log.debug("Exception in getting the service references: "
                    + e.getMessage());
        }

Avatar

Level 4

I tried using   the below instead of FrameworkUtil it sloved the issue.Please let me know  if the below code is correct ??
protected void activate(ComponentContext c) throws Exception {
        bundleContext = c.getBundleContext();
    }
    
    protected void deactivate(ComponentContext context) {
                
    }