2017-03-27 3 views
0

NetBeans 8.2, Maven 3.3.9 및 선언적 서비스를 사용하여 Karaf 4.1.0 응용 프로그램을 개발하려고합니다. 정말 간단한 서비스가 작동하지만, 내가 막연하게 유용한 것을하려고하면, 두려운 osgi.component 요구 사항 오류가 발생합니다. 나는 @Reference을 주석 경우Karaf에서 선언적 서비스 사용하기 4.1.0

package net.winnall.enocean.bridge.sass.impl; 

import org.osgi.service.component.annotations.Activate; 
import org.osgi.service.component.annotations.Component; 
import org.osgi.service.component.annotations.Deactivate; 
import org.osgi.service.component.annotations.Reference; 
import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 
import net.winnall.enocean.bridge.sass.SASS; 
import org.osgi.service.http.HttpService; 

@Component(
     service = SASS.class 
) 
public class SASSImpl implements SASS { 

    @Reference 
    HttpService httpService; 

    @Activate 
    protected void activate() { 
    } 

    @Deactivate 
    } 
} 

구성 요소가 문제없이 생성 된 Karaf 어셈블리에로드 :

다음은 문제의 종류 나는 데를 보여줍니다.

Failed to execute goal org.apache.karaf.tooling:karaf-maven-plugin:4.1.0:assembly (default-assembly) on project EnOceanBridgeAdmin: Unable to build assembly: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=EnOceanBridgeSASSFeature; type=karaf.feature; version=0.99.99; filter:="(&(osgi.identity=EnOceanBridgeSASSFeature)(type=karaf.feature)(version>=0.99.99))" [caused by: Unable to resolve EnOceanBridgeSASSFeature/0.99.99: missing requirement [EnOceanBridgeSASSFeature/0.99.99] osgi.identity; osgi.identity=EnOceanBridgeSASS.Impl; type=osgi.bundle; version="[0.99.99,0.99.99]"; resolution:=mandatory [caused by: Unable to resolve EnOceanBridgeSASS.Impl/0.99.99: missing requirement [EnOceanBridgeSASS.Impl/0.99.99] osgi.extender; filter:="(&(osgi.extender=osgi.component)(version>=1.3.0)(!(version>=2.0.0)))"]] -> [Help 1]

This question 제안이 scr를 설치 : 구성 요소가합니다 (@Reference와 함께) 여기에 서 그러나 나는 다음과 같은 오류 얻을

feature:install scr 

그래서 난 추가 시도를 <feature>scr</featurekarat-maven-plugin<bootFeatures>에 있지만, 아무런 차이가 없습니다.

<dependencyManagement> 
    <dependencies> 
     <dependency> 
     <groupId>org.apache.felix</groupId> 
     <artifactId>org.apache.felix.configadmin</artifactId> 
     <version>1.8.14</version> 
     </dependency> 

     <dependency> 
     <groupId>org.apache.felix</groupId> 
     <artifactId>org.apache.felix.scr.ds-annotations</artifactId> 
     <version>1.2.8</version> 
     </dependency> 

     <dependency> 
     <groupId>org.ops4j.pax.logging</groupId> 
     <artifactId>pax-logging-service</artifactId> 
     <version>1.9.1</version> 
     </dependency> 

     <dependency> 
     <groupId>org.ops4j.pax.logging</groupId> 
     <artifactId>pax-logging-api</artifactId> 
     <version>1.9.1</version> 
     </dependency> 

     <dependency> 
     <groupId>org.ops4j.pax.logging</groupId> 
     <artifactId>pax-logging-log4j2</artifactId> 
     <version>1.9.1</version> 
     </dependency> 
    </dependencies> 
    </dependencyManagement> 

    <dependencies> 
    <dependency> 
     <groupId>org.apache.karaf.features</groupId> 
     <artifactId>framework</artifactId> 
     <version>4.1.0</version> 
     <type>kar</type> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.karaf.features</groupId> 
     <artifactId>standard</artifactId> 
     <version>4.1.0</version> 
     <type>xml</type> 
     <classifier>features</classifier> 
     <scope>runtime</scope> 
    </dependency> 
    </dependencies> 

    <build> 
    <pluginManagement> 
     <plugins> 
     <plugin> 
      <groupId>org.apache.karaf.tooling</groupId> 
      <artifactId>karaf-maven-plugin</artifactId> 
      <version>4.1.0</version> 
      <extensions>true</extensions> 
     </plugin> 
     </plugins> 
    </pluginManagement> 

    <plugins> 
     <plugin> 
     <groupId>org.apache.karaf.tooling</groupId> 
     <artifactId>karaf-maven-plugin</artifactId> 
     <version>4.1.0</version> 
     <extensions>true</extensions> 
     <configuration> 
      <installedFeatures></installedFeatures> 
      <startupFeatures></startupFeatures> 
      <bootFeatures> 
      <feature>minimal</feature> 
      <feature>scr</feature> 
      </bootFeatures> 
      <javase>1.8</javase> 
     </configuration> 
     </plugin> 

나는 그것이 Karaf 어셈블리에 알리기 위해 사용하는 기능은 다음과 같습니다 :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="EnOceanBridgeSASS.Impl"> 
    <feature name="EnOceanBridgeSASS.Impl" description="EnOceanBridge SASS Impl" version="0.99.99"> 
     <details>Karaf :: Declarative Services :: Service :: EnOceanBridge SASS Implementation</details> 
     <bundle start-level="80">mvn:net.winnall.enocean.service.api/EnOceanBridgeSASS.API/0.99.99</bundle> 
     <bundle start-level="80">mvn:org.apache.felix/org.apache.felix.configadmin/1.8.14</bundle> 
     <bundle start-level="80">mvn:org.ops4j.pax.logging/pax-logging-api/1.9.1</bundle> 
     <bundle start-level="80">mvn:org.ops4j.pax.logging/pax-logging-service/1.9.1</bundle> 
    </feature> 
</features> 

그리고 Karaf 조립의 유효 다음

이 구성 요소에 대한 유효 POM에서 추출물 나는이 확률값을 인터넷 검색을 주말을 보냈어요

<dependencyManagement> 
    <dependencies> 
     <dependency> 
     <groupId>org.apache.felix</groupId> 
     <artifactId>org.apache.felix.configadmin</artifactId> 
     <version>1.8.14</version> 
     </dependency> 

     <dependency> 
     <groupId>org.apache.felix</groupId> 
     <artifactId>org.apache.felix.scr.ds-annotations</artifactId> 
     <version>1.2.8</version> 
     </dependency> 

     <dependency> 
     <groupId>org.ops4j.pax.logging</groupId> 
     <artifactId>pax-logging-service</artifactId> 
     <version>1.9.1</version> 
     </dependency> 

     <dependency> 
     <groupId>org.ops4j.pax.logging</groupId> 
     <artifactId>pax-logging-api</artifactId> 
     <version>1.9.1</version> 
     </dependency> 

     <dependency> 
     <groupId>org.ops4j.pax.logging</groupId> 
     <artifactId>pax-logging-log4j2</artifactId> 
     <version>1.9.1</version> 
     </dependency> 
    </dependencies> 
    </dependencyManagement> 

    <dependencies> 
    <dependency> 
     <groupId>net.winnall.enocean.feature</groupId> 
     <artifactId>EnOceanBridgeSettingsFeature</artifactId> 
     <version>0.99.99</version> 
     <type>xml</type> 
     <classifier>features</classifier> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>net.winnall.enocean.feature</groupId> 
     <artifactId>EnOceanBridgeSASSFeature</artifactId> 
     <version>0.99.99</version> 
     <type>xml</type> 
     <classifier>features</classifier> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>net.winnall.enocean.feature</groupId> 
     <artifactId>EnOceanBridgePersistenceFeature</artifactId> 
     <version>0.99.99</version> 
     <type>xml</type> 
     <classifier>features</classifier> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.karaf.features</groupId> 
     <artifactId>framework</artifactId> 
     <version>4.1.0</version> 
     <type>kar</type> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.karaf.features</groupId> 
     <artifactId>standard</artifactId> 
     <version>4.1.0</version> 
     <type>xml</type> 
     <classifier>features</classifier> 
     <scope>runtime</scope> 
    </dependency> 
    </dependencies> 

    <build> 
    <pluginManagement> 
     <plugins> 
     <plugin> 
      <groupId>org.apache.karaf.tooling</groupId> 
      <artifactId>karaf-maven-plugin</artifactId> 
      <version>4.1.0</version> 
      <extensions>true</extensions> 
     </plugin> 

     <plugin> 
      <artifactId>maven-archetype-plugin</artifactId> 
      <version>3.0.0</version> 
     </plugin> 

     <plugin> 
      <groupId>com.github.ferstl</groupId> 
      <artifactId>depgraph-maven-plugin</artifactId> 
      <version>2.1.0</version> 
     </plugin> 

     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>exec-maven-plugin</artifactId> 
      <version>1.6.0</version> 
     </plugin> 

     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>license-maven-plugin</artifactId> 
      <version>1.12</version> 
     </plugin> 

     <plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <version>1.8</version> 
     </plugin> 

     <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.2-beta-5</version> 
     </plugin> 

     <plugin> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.1</version> 
     </plugin> 

     <plugin> 
      <artifactId>maven-release-plugin</artifactId> 
      <version>2.0</version> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.felix</groupId> 
      <artifactId>maven-bundle-plugin</artifactId> 
      <version>3.3.0</version> 
     </plugin> 

     <plugin> 
      <artifactId>maven-resources-plugin</artifactId> 
      <version>3.0.2</version> 
     </plugin> 
     </plugins> 
    </pluginManagement> 

    <plugins> 
     <plugin> 
     <groupId>com.github.ferstl</groupId> 
     <artifactId>depgraph-maven-plugin</artifactId> 
     <version>2.1.0</version> 
     </plugin> 

     <plugin> 
     <artifactId>maven-resources-plugin</artifactId> 
     <version>3.0.2</version> 
     <executions> 
      <execution> 
      <id>default-resources</id> 
      <phase>process-resources</phase> 
      <goals> 
       <goal>resources</goal> 
      </goals> 
      </execution> 
      <execution> 
      <id>process-resources</id> 
      <goals> 
       <goal>resources</goal> 
      </goals> 
      </execution> 
     </executions> 
     </plugin> 

     <plugin> 
     <groupId>org.apache.karaf.tooling</groupId> 
     <artifactId>karaf-maven-plugin</artifactId> 
     <version>4.1.0</version> 
     <extensions>true</extensions> 
     <executions> 
      <execution> 
      <id>default-archive</id> 
      <phase>package</phase> 
      <goals> 
       <goal>archive</goal> 
      </goals> 
      <configuration> 
       <installedFeatures></installedFeatures> 
       <startupFeatures></startupFeatures> 
       <bootFeatures> 
       <feature>minimal</feature> 
       <feature>scr</feature> 
       </bootFeatures> 
       <javase>1.8</javase> 
      </configuration> 
      </execution> 

      <execution> 
      <id>default-assembly</id> 
      <phase>process-resources</phase> 
      <goals> 
       <goal>assembly</goal> 
      </goals> 
      <configuration> 
       <installedFeatures></installedFeatures> 
       <startupFeatures></startupFeatures> 
       <bootFeatures> 
       <feature>minimal</feature> 
       <feature>scr</feature> 
       </bootFeatures> 
       <javase>1.8</javase> 
      </configuration> 
      </execution> 
     </executions> 

     <configuration> 
      <installedFeatures></installedFeatures> 
      <startupFeatures></startupFeatures> 
      <bootFeatures> 
      <feature>standard</feature> 
      <feature>scr</feature> 
      </bootFeatures> 
      <javase>1.8</javase> 
     </configuration> 
     </plugin> 

: POM이 포함 lem : Karaf에서 선언적 서비스를 사용하는 것에 관한 인터넷상의 문서는 거의 없다고 생각됩니다.

아무도 내 문제를 해결하는 방법에 대한 팁을 줄 수 있습니까?

스티브

+0

나는 위의 오류 메시지를 보면서 싫증이났다. 아무도 그것이 무엇을 의미하는지 말할 수 있습니까? –

답변

0

나는 결국 오류를 없앴습니다. 솔직히 말해서 나는 그것을 고치기 위해 무엇을했는지 모르겠습니다. 일을하게 만든 마지막 편집은 처음 문제를보고했을 때 전혀 없었던 위에 나열된 피쳐 파일에서 무언가를 제거하는 것이 었습니다 (<repository /><feature /> 참조였습니다. 강제로 HttpService 설치 ...).

더 나은 세상 (예 :여기서 나는 4 일간의 문제를 놓치지 않는다.) :

  1. OSGi 오류 메시지는 프로그래머가 오류를 격리하는 데 도움이된다.
  2. 내가 선언적 서비스의 최신 화신 (예 : 주석 기반 및 원시 BND 또는 XML 파일)에만 관심이 있다는 것을 Google에 알리는 방법.
  3. 깨끗한 주석 기반 DS 문서 Eclipse에서 사용하는 방법에 대한 일러스트레이션. Eclipse를 사용하지 않으므로 원하지 않습니다.
  4. Karaf에서 DS를 사용하는 방법에 대한 더 간단한 문서.
  5. 카라프 IDE (Karaf Boot는 무엇입니까?).

나는 Karaf와 DS가 둘 다 작동하는 멋진 방법이라고 생각합니다. 나는 그것이 더 쉬웠 으면 좋겠다.

+0

끝내기 : 오류가 내 POM 중 하나에 있다고 생각하지만 잘 모르겠습니다. –

0

당신은 HTTP 서비스에 대한 참조를 얻으려고 노력하고 있지만 전혀 그 기능을 설치 한 경우 명시하지 않습니다.

또한 @Reference를 사용하는 OSGi의 버전에 따라 속성이 작동하지 않을 수 있으며 getter/setter (바인드/바인드 해제) 메소드를 사용해야 할 수도 있습니다.

(이 큰 튜토리얼 덕분에 라스 보글.) http://blog.vogella.com/2016/06/21/getting-started-with-osgi-declarative-services/ 제 7 장 DS 주석 을 참조하십시오은 OSGi로 시작하는 경우

enroute 프로젝트도 좋은 장소입니다.

+0

나는 하루 종일이 힌트를 추구했지만, 나는 금요일보다 더 이상은 아니야. 문제는 DS가 아니라 카라프에 대한 나의 이해와 관련이 있다고 생각합니다. 나는 Karaf의 모든 요점이 당신에게'HttpService'와 같은 서비스를 제공했다고 생각 했습니까? 'pax-web'을 통해? 'http'를 통해? 하지만 어떤 기능을 찾을 수 없습니다. –

관련 문제