0

私はこの OSGi と Maven のすべてに不慣れで、OSGi and Apache Felix 3.0 - Beginner's GuideWalid Gedeon の本からの「Bookshelf」チュートリアルに従っています。

私は本から彼らの例に従いましたが、これまでのところ私のコードを展開する際に少し問題が発生しました。

次のエラー メッセージが表示されます。

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Bookshelf Inventory API
[INFO]    task-segment: [clean, deploy]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory C:\com.packtpub.felix.bookshelf-inventory-api\target
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 6 source files to C:\com.packtpub.felix.bookshelf-inventory-api\target\classes
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\com.packtpub.felix.bookshelf-inventory-api\src\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] [bundle:bundle {execution: default-bundle}]
[WARNING] Warning building bundle com.packtpub.felix:com.packtpub.felix.bookshelf-inventory-api:bundle:1.5.0 : Instructions in Private-Package, or -testpackages that are never used: \.
[INFO] [install:install {execution: default-install}]
[INFO] Installing C:\com.packtpub.felix.bookshelf-inventory-api\target\com.packtpub.felix.bookshelf-inventory-api-1.5.0.jar to C:\Users\eivaore\.m2\repository\com\packtpub\felix\com.packtpub.felix.bookshelf-inventory-api\1.5.0\com.packtpub.felix.bookshelf-inventory-api-1.5.0.jar
[INFO] [bundle:install {execution: default-install}]
[INFO] Installing com/packtpub/felix/com.packtpub.felix.bookshelf-inventory-api/1.5.0/com.packtpub.felix.bookshelf-inventory-api-1.5.0.jar
[WARNING] Exception while updating local OBR: The header cannot be an empty string.
java.lang.IllegalArgumentException: The header cannot be an empty string.
    at org.apache.felix.utils.manifest.Parser.parseHeader(Parser.java:37)
    at org.apache.felix.bundlerepository.impl.DataModelHelperImpl.getSymbolicName(DataModelHelperImpl.java:871)
    at org.apache.felix.bundlerepository.impl.DataModelHelperImpl.populate(DataModelHelperImpl.java:519)
    at org.apache.felix.bundlerepository.impl.DataModelHelperImpl.createResource(DataModelHelperImpl.java:513)
    at org.apache.felix.bundlerepository.impl.DataModelHelperImpl.createResource(DataModelHelperImpl.java:404)
    at org.apache.felix.obrplugin.ObrUpdate.updateRepository(ObrUpdate.java:170)
    at org.apache.felix.obrplugin.ObrInstall.updateLocalBundleMetadata(ObrInstall.java:183)
    at org.apache.felix.obrplugin.ObrInstall.execute(ObrInstall.java:142)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] [deploy:deploy {execution: default-deploy}]
Uploading: file:///C:/projects/felixbook/releases/com/packtpub/felix/com.packtpub.felix.bookshelf-inventory-api/1.5.0/com.packtpub.felix.bookshelf-inventory-api-1.5.0.jar
4/7K
7/7K
7K uploaded  (com.packtpub.felix.bookshelf-inventory-api-1.5.0.jar)
[INFO] Retrieving previous metadata from repo-rel
[INFO] Uploading repository metadata for: 'artifact com.packtpub.felix:com.packtpub.felix.bookshelf-inventory-api'
[INFO] Uploading project information for com.packtpub.felix.bookshelf-inventory-api 1.5.0
[INFO] [bundle:deploy {execution: default-deploy}]
[INFO] LOCK file:///C:/projects/felixbook/releases/repository.xml
[INFO] Downloading repository.xml
[INFO] Computed bundle uri: file:/C:/projects/felixbook/releases/com/packtpub/felix/com.packtpub.felix.bookshelf-inventory-api/1.5.0/com.packtpub.felix.bookshelf-inventory-api-1.5.0.jar
[INFO] Writing OBR metadata
[INFO] Deploying file:/C:/projects/felixbook/releases/com/packtpub/felix/com.packtpub.felix.bookshelf-inventory-api/1.5.0/com.packtpub.felix.bookshelf-inventory-api-1.5.0.jar
[WARNING] Exception while updating remote OBR: The header cannot be an empty string.
java.lang.IllegalArgumentException: The header cannot be an empty string.
    at org.apache.felix.utils.manifest.Parser.parseHeader(Parser.java:37)
    at org.apache.felix.bundlerepository.impl.DataModelHelperImpl.getSymbolicName(DataModelHelperImpl.java:871)
    at org.apache.felix.bundlerepository.impl.DataModelHelperImpl.populate(DataModelHelperImpl.java:519)
    at org.apache.felix.bundlerepository.impl.DataModelHelperImpl.createResource(DataModelHelperImpl.java:513)
    at org.apache.felix.bundlerepository.impl.DataModelHelperImpl.createResource(DataModelHelperImpl.java:404)
    at org.apache.felix.obrplugin.ObrUpdate.updateRepository(ObrUpdate.java:170)
    at org.apache.felix.obrplugin.ObrDeploy.updateRemoteBundleMetadata(ObrDeploy.java:351)
    at org.apache.felix.obrplugin.ObrDeploy.execute(ObrDeploy.java:253)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] UNLOCK file:///C:/projects/felixbook/releases/repository.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Fri Jul 05 09:23:06 CEST 2013
[INFO] Final Memory: 18M/169M
[INFO] ------------------------------------------------------------------------

これが私の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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.packtpub.felix</groupId>
<artifactId>com.packtpub.felix.bookshelf-inventory-api</artifactId>
<version>1.5.0</version>

<packaging>bundle</packaging>

<name>Bookshelf Inventory API</name>
<description>Defines the API for the Bookshelf inventory</description>

<dependencies></dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.1.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-Category>sample</Bundle-Category>
                    <Bundle-SymbolicName>${artifactID}</Bundle-SymbolicName>

                    <Export-Package>
                        com.packtpub.felix.bookshelf.inventory.api
                    </Export-Package>
                </instructions>

                <remoteOBR>repo-rel</remoteOBR>
                <prefixUrl>
                    file:///C:/projects/felixbook/releases
                </prefixUrl>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <inherited>true</inherited>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<distributionManagement>
    <!-- releases repo -->
    <repository>
        <id>repo-rel</id>
        <url>file:///C:/projects/felixbook/releases</url>
    </repository>
</distributionManagement>

何かご意見は?

編集:
私が気づいたことから、問題は<packaging>bundle</packaging>.

4

2 に答える 2

1

Bundle-SymbolicNameが無効であるため、例外がスローれます。次のように変更します。

<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
于 2014-10-16T15:22:17.710 に答える
1

マニフェストの生成を試みる必要があります

<plugin>
  <groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
  <configuration>
    <supportedProjectTypes>
      <supportedProjectType>bundle</supportedProjectType>
      <supportedProjectType>war</supportedProjectType>
    </supportedProjectTypes>
  </configuration>
  <executions>
    <execution>
      <id>bundle-manifest</id>
      <phase>process-classes</phase>
      <goals>
        <goal>manifest</goal>
      </goals>
      <configuration>
        <!-- config and instructions here -->
      </configuration>
    </execution>
  </executions>
</plugin>

<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <archive>
      <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
    </archive>
  </configuration>
</plugin>
于 2013-07-05T09:12:31.043 に答える