issue using frameworkfactory | Community
Skip to main content
Level 4
December 16, 2015
Solved

issue using frameworkfactory

  • December 16, 2015
  • 6 replies
  • 1674 views
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
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 smacdonald2008

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

6 replies

Level 4
December 16, 2015

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

 

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

 

Please provide inputs

smacdonald2008
smacdonald2008Accepted solution
Level 10
December 16, 2015

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

Level 4
December 17, 2015

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++:+method+getBundleContext()+location:+interface+org.osgi.framework.Bundle

Lokesh_Shivalingaiah
Level 10
December 17, 2015

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

Level 4
December 17, 2015

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());
        }

Level 4
December 17, 2015

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) {
                
    }