2 Replies Latest reply on Jul 2, 2013 9:03 AM by anderson.nt

    Not generating OSGI-INF folder

    anderson.nt Level 1

      Hi,

       

      I am new to OSGI.I have been having trouble to get OSGI-INF folder in generated jar file. I need to have folder structure like as below

       

      • META-INF
      • OSGI-INF
      • Com.mine.cq

       

        I am using Eclipse and m2e plugin. When I run my project I am getting BUILD SUCCESS. And I am getting the below folder structure in the generated jar file. Jar does not have OSGI-INF folder.

       

      • META-INF
      • Com.mine.cq

       

      Here is my POM.xml

       

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

                <modelVersion>4.0.0</modelVersion>

       

       

                <groupId>com.mine.cq</groupId>

                <artifactId>mineCore</artifactId>

                <version>0.0.1-SNAPSHOT</version>

                <packaging>jar</packaging>

       

       

                <name>mineCore</name>

                <url>http://maven.apache.org</url>

       

       

                <properties>

                          <file.encoding>utf-8</file.encoding>

                </properties>

                <build>

              <defaultGoal>install</defaultGoal>

              <plugins>

                  <plugin>

                      <groupId>org.apache.maven.plugins</groupId>

                      <artifactId>maven-enforcer-plugin</artifactId>

                      <version>1.0-alpha-3</version>

                      <executions>

                          <execution>

                              <id>enforce-java</id>

                              <goals>

                                  <goal>enforce</goal>

                              </goals>

                              <configuration>

                                  <rules>

                                      <requireMavenVersion>

                                          <message>Maven 2.0.7 or higher</message>

                                          <version>2.0.7</version>

                                      </requireMavenVersion>

                                      <requireJavaVersion>

                                          <message>Java 5 or higher</message>

                                          <version>1.5.0</version>

                                      </requireJavaVersion>

                                  </rules>

                              </configuration>

                          </execution>

                      </executions>

                  </plugin>

                  <plugin>

                      <groupId>org.apache.felix</groupId>

                      <artifactId>maven-bundle-plugin</artifactId>

                      <version>1.4.3</version>

                      <extensions>true</extensions>

                      <configuration>

                          <instructions>

                              <Export-Package>

                                                                            com.mine.cq.mineCore.*

                              </Export-Package>

                              <Import-Package>

                                  *;resolution:=optional,

                                  javax.servlet;version=2.4,

                                  javax.servlet.http;version=2.4

                              </Import-Package>

                                                                  <Private-Package>

                                                                  </Private-Package>

                              <Embed-Dependency>  

                              </Embed-Dependency>

                          </instructions>

                      </configuration>

                  </plugin>

       

       

                  <plugin>

                      <groupId>org.apache.felix</groupId>

                      <artifactId>maven-scr-plugin</artifactId>

                      <version>1.9.0</version>

                      <executions>

                          <execution>

                              <id>generate-scr-scrdescriptor</id>

                              <goals>

                                  <goal>scr</goal>

                              </goals>

                          </execution>

                      </executions>

                  </plugin>

                  <plugin>

                      <groupId>org.apache.maven.plugins</groupId>

                      <artifactId>maven-scm-plugin</artifactId>

                      <version>1.0</version>

                      <configuration>

                          <goals>install</goals>

                      </configuration>

                  </plugin>

              </plugins>

              <extensions>

                  <extension>

                      <groupId>org.apache.maven.wagon</groupId>

                      <artifactId>wagon-webdav</artifactId>

                      <version>1.0-beta-2</version>

                  </extension>

                  <extension>

                      <groupId>org.apache.maven.wagon</groupId>

                      <artifactId>wagon-ssh</artifactId>

                      <version>1.0-beta-2</version>

                  </extension>

              </extensions>

          </build>

      <dependencies>

                          <dependency>

                                    <groupId>junit</groupId>

                                    <artifactId>junit</artifactId>

                                    <version>3.8.1</version>

                                    <scope>test</scope>

                          </dependency>

                </dependencies>

      </project>

       

       

      Why OSGI-INF folder is not in the .jar file? I need to set some property information in OSGO-INF folder since I have to register my component as a OSGI service. Please guide me to get it done.

       

      Thanks,

      Anderson

        • 1. Re: Not generating OSGI-INF folder
          rajavijaysingh Level 1

          can you try running with debug mode and check the log for scr

          • 2. Re: Not generating OSGI-INF folder
            anderson.nt Level 1

            Hi,

            It was problem with my pom.xml. Finally I have created OSGI bundle with maven-scr plugin J Now I have the correct folder structure (OSGI-INF folder). Actually I need to have a reference via sling.getService only. I have installed my osgi bundle in Felix console successfully. The status of the bundle is Active. But the component status is “registered” When I check it in component console. And there is no entry in my service console.

            Here is my java class

            package com.adobe.support.examples.com.adobe.support.examples.osgi.service;

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

            import org.apache.felix.scr.annotations.Properties;

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

            import org.apache.felix.scr.annotations.Property;

            @Component(immediate = true, metatype = true)

            @Service

            public class SampleServiceImpl implements SampleService {

            public String sayHello() {

                 return "Hello World!";

            }

            }

            Why component statis is 'registerd' instead of having 'active' Could you please tell me how to fix it?

            Thanks in advance

             

            Regards,

            Anderson