Maven和GlassFish3示例出错

Maven和GlassFish3示例出错,maven,build,osgi,glassfish-3,apache-felix,Maven,Build,Osgi,Glassfish 3,Apache Felix,我对所有OSGi和Maven的东西都是新手,我正在学习Walid Gedeon的《OSGi和Apache Felix 3.0入门指南》一书中的“书架”教程 我遵循了书中的示例,到目前为止在部署代码时遇到了一个小问题 我收到以下错误消息: [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Boo

我对所有OSGi和Maven的东西都是新手,我正在学习Walid Gedeon的《OSGi和Apache Felix 3.0入门指南》一书中的“书架”教程

我遵循了书中的示例,到目前为止在部署代码时遇到了一个小问题

我收到以下错误消息:

[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>

4.0.0
com.packtpub.felix
com.packtpub.felix.bookshelf-inventory-api
1.5.0
捆
书架库存API
定义书架库存的API
org.apache.felix
maven捆绑插件
2.1.0
真的
样品
${artifactID}
com.packtpub.felix.bookshelf.inventory.api
回购关系
file:///C:/projects/felixbook/releases
maven编译器插件
真的
1.5
1.5
回购关系
file:///C:/projects/felixbook/releases

有什么想法吗

编辑:

据我所知,问题出在
包中

您应该尝试生成清单

<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>

org.apache.felix
maven捆绑插件
捆
战争
捆绑清单
进程类
显示
maven战争插件
${project.build.outputDirectory}/META-INF/MANIFEST.MF

引发异常,因为
Bundle SymbolicName
无效:pom.xml中的属性查找区分大小写(请参阅)。将其更改为以下内容:

<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
${artifactId}

你的清单是什么样子的?我不确定我有没有,这本书根本没有提到。