2013-07-05 45 views
0

我是新來的所有這些OSGi和Maven的東西,我正在關注Walid Gedeon的書OSGi and Apache Felix 3.0 - Beginner's Guide中的「Bookshelf」教程。Maven和GlassFish3示例出現錯誤

我從書中跟着他們的例子,到目前爲止遇到了部署代碼的小問題。

我收到以下錯誤信息:

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

+0

您的清單看起來像什麼? – willome

+0

我不確定自己有沒有,書中根本沒有提到它。 – Lopina

回答

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

拋出異常,因爲Bundle-SymbolicName無效:在pom.xml中的屬性查找是大小寫敏感的(看看pom.xml reference)。將其更改爲如下所示:

<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName> 
相關問題