You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by 孙丰成 <fc...@163.com> on 2014/01/24 11:16:12 UTC

update bundle not work

Hi,
I am using karaf 3.0.0 to develop osgi application. Recently I encounted a problem.
1)compute bundle provide simple compute methods. such as add. The bundle export interface packages, and did not export interface impl package.
2)simple war bundle is a web project. It depends on compute bundle.
I used maven and obr to manage the deployment. I faced a problem like this:
when I changed one impl class, 
public long add(int a, int b) {
// TODO Auto-generated method stub
return a + b;
}


I changed this method to 
public long add(int a, int b) {
// TODO Auto-generated method stub
return a + 2*b;
}
after execute mvn install, the compute bundle is updated in maven repository. And I execute "update ${computebundleId}", the modified bundle didn't take effect.
simple war bundle pom configuration like this
<plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <version>2.4.0</version>
                 <extensions>true</extensions>
                 <configuration>
                     <supportedProjectTypes>
                         <supportedProjectType>jar</supportedProjectType>
                         <supportedProjectType>bundle</supportedProjectType>
                         <supportedProjectType>war</supportedProjectType>
                     </supportedProjectTypes>
                     <instructions>
                         <Import-Package>
                             org.springframework.web.context,
                             org.springframework.osgi.web.context.support,
                             com.sun.jersey.spi.spring.container.servlet,
                             *;
                             resolution:=optional
                         </Import-Package>
                         <Export-Package>com.hoo.unad.sample.*,!*</Export-Package>
                         <Bundle-Classpath>
                             WEB-INF/classes
                         </Bundle-Classpath>
                         <Web-ContextPath>sample</Web-ContextPath>
                         <Embed-Dependency>*; artifactId=!org.osgi.compendium;
                             scope=compile; type=!pom; inline=true</Embed-Dependency>
                         <Embed-Transitive>true</Embed-Transitive>
                         <_removeheaders>
                             Include-Resource,
                             Private-Package,
                             Embed-Dependency,
                             Embed-Transitive,
                             Ignore-Package
                         </_removeheaders>
                         <Include-Resource>src/main/resources</Include-Resource>
                     </instructions>
                 </configuration>
<executions>
                     <execution>
                         <id>generate-manifest</id>
                         <phase>process-classes</phase>
                         <goals>
                             <goal>manifest</goal>
                         </goals>
                     </execution>
                     <execution>
                         <id>index</id>
                         <goals>
                             <goal>index</goal>
                         </goals>
                         <phase>verify</phase>
                         <configuration>
                             <obrRepository>/home/sun/Repository/repository.xml</obrRepository>
                             <urlTemplate>maven</urlTemplate>
                         </configuration>
                     </execution>
 
                 </executions>
             </plugin>
             
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-war-plugin</artifactId>
                 <version>2.4</version>
                 <configuration>
                     <archive>
                         <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                     </archive>
                 </configuration>
             </plugin>
please give a help, Thanks very much.

RE: update bundle not work

Posted by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>.
Good to know :)


-----Message d'origine-----
De : Neil Bartlett [mailto:njbartlett@gmail.com] 
Envoyé : vendredi 24 janvier 2014 13:37
À : users
Objet : Re: update bundle not work

Actually you should *always* perform a refresh operation after any sequence of installs, updates and uninstalls.

This is necessary because bundle wiring is relatively static and expensive to calculate, therefore is not recalculated after every individual operation. The refresh is a signal to OSGi that you have finished a sequence or batch of operations and that it should go ahead and perform the rewiring.

Regards
Neil



On Fri, Jan 24, 2014 at 12:32 PM, CLEMENT Jean-Philippe < jean-philippe.clement@fr.thalesgroup.com> wrote:

> In some cases update may fail. As far as I experienced this usually 
> happens when the API is changed in the code but the bundle keeps the 
> same version.
>
> In that case you can use the "refresh <bundleid>" command. Ultimately 
> you can use "refresh -f" (which will also shutdown Karaf).
>
> JP
>
> -----Message d'origine-----
> De : 孙丰成 [mailto:fcswhhit@163.com]
> Envoyé : vendredi 24 janvier 2014 11:16 À : users@felix.apache.org 
> Objet : update bundle not work
>
> Hi,
> I am using karaf 3.0.0 to develop osgi application. Recently I 
> encounted a problem.
> 1)compute bundle provide simple compute methods. such as add. The 
> bundle export interface packages, and did not export interface impl package.
> 2)simple war bundle is a web project. It depends on compute bundle.
> I used maven and obr to manage the deployment. I faced a problem like this:
> when I changed one impl class,
> public long add(int a, int b) {
> // TODO Auto-generated method stub
> return a + b;
> }
>
>
> I changed this method to
> public long add(int a, int b) {
> // TODO Auto-generated method stub
> return a + 2*b;
> }
> after execute mvn install, the compute bundle is updated in maven 
> repository. And I execute "update ${computebundleId}", the modified 
> bundle didn't take effect.
> simple war bundle pom configuration like this <plugin>
>                  <groupId>org.apache.felix</groupId>
>                  <artifactId>maven-bundle-plugin</artifactId>
>                  <version>2.4.0</version>
>                  <extensions>true</extensions>
>                  <configuration>
>                      <supportedProjectTypes>
>                          
> <supportedProjectType>jar</supportedProjectType>
>
>  <supportedProjectType>bundle</supportedProjectType>
>                          <supportedProjectType>war</supportedProjectType>
>                      </supportedProjectTypes>
>                      <instructions>
>                          <Import-Package>
>                              org.springframework.web.context,
>                              org.springframework.osgi.web.context.support,
>                              com.sun.jersey.spi.spring.container.servlet,
>                              *;
>                              resolution:=optional
>                          </Import-Package>
>
>  <Export-Package>com.hoo.unad.sample.*,!*</Export-Package>
>                          <Bundle-Classpath>
>                              WEB-INF/classes
>                          </Bundle-Classpath>
>                          <Web-ContextPath>sample</Web-ContextPath>
>                          <Embed-Dependency>*; 
> artifactId=!org.osgi.compendium;
>                              scope=compile; type=!pom; 
> inline=true</Embed-Dependency>
>                          <Embed-Transitive>true</Embed-Transitive>
>                          <_removeheaders>
>                              Include-Resource,
>                              Private-Package,
>                              Embed-Dependency,
>                              Embed-Transitive,
>                              Ignore-Package
>                          </_removeheaders>
>
>  <Include-Resource>src/main/resources</Include-Resource>
>                      </instructions>
>                  </configuration>
> <executions>
>                      <execution>
>                          <id>generate-manifest</id>
>                          <phase>process-classes</phase>
>                          <goals>
>                              <goal>manifest</goal>
>                          </goals>
>                      </execution>
>                      <execution>
>                          <id>index</id>
>                          <goals>
>                              <goal>index</goal>
>                          </goals>
>                          <phase>verify</phase>
>                          <configuration>
>
>  <obrRepository>/home/sun/Repository/repository.xml</obrRepository>
>                              <urlTemplate>maven</urlTemplate>
>                          </configuration>
>                      </execution>
>
>                  </executions>
>              </plugin>
>
>              <plugin>
>                  <groupId>org.apache.maven.plugins</groupId>
>                  <artifactId>maven-war-plugin</artifactId>
>                  <version>2.4</version>
>                  <configuration>
>                      <archive>
>
>  <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
>                      </archive>
>                  </configuration>
>              </plugin>
> please give a help, Thanks very much.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org

Re: update bundle not work

Posted by Neil Bartlett <nj...@gmail.com>.
Actually you should *always* perform a refresh operation after any sequence
of installs, updates and uninstalls.

This is necessary because bundle wiring is relatively static and expensive
to calculate, therefore is not recalculated after every individual
operation. The refresh is a signal to OSGi that you have finished a
sequence or batch of operations and that it should go ahead and perform the
rewiring.

Regards
Neil



On Fri, Jan 24, 2014 at 12:32 PM, CLEMENT Jean-Philippe <
jean-philippe.clement@fr.thalesgroup.com> wrote:

> In some cases update may fail. As far as I experienced this usually
> happens when the API is changed in the code but the bundle keeps the same
> version.
>
> In that case you can use the "refresh <bundleid>" command. Ultimately you
> can use "refresh -f" (which will also shutdown Karaf).
>
> JP
>
> -----Message d'origine-----
> De : 孙丰成 [mailto:fcswhhit@163.com]
> Envoyé : vendredi 24 janvier 2014 11:16
> À : users@felix.apache.org
> Objet : update bundle not work
>
> Hi,
> I am using karaf 3.0.0 to develop osgi application. Recently I encounted a
> problem.
> 1)compute bundle provide simple compute methods. such as add. The bundle
> export interface packages, and did not export interface impl package.
> 2)simple war bundle is a web project. It depends on compute bundle.
> I used maven and obr to manage the deployment. I faced a problem like this:
> when I changed one impl class,
> public long add(int a, int b) {
> // TODO Auto-generated method stub
> return a + b;
> }
>
>
> I changed this method to
> public long add(int a, int b) {
> // TODO Auto-generated method stub
> return a + 2*b;
> }
> after execute mvn install, the compute bundle is updated in maven
> repository. And I execute "update ${computebundleId}", the modified bundle
> didn't take effect.
> simple war bundle pom configuration like this
> <plugin>
>                  <groupId>org.apache.felix</groupId>
>                  <artifactId>maven-bundle-plugin</artifactId>
>                  <version>2.4.0</version>
>                  <extensions>true</extensions>
>                  <configuration>
>                      <supportedProjectTypes>
>                          <supportedProjectType>jar</supportedProjectType>
>
>  <supportedProjectType>bundle</supportedProjectType>
>                          <supportedProjectType>war</supportedProjectType>
>                      </supportedProjectTypes>
>                      <instructions>
>                          <Import-Package>
>                              org.springframework.web.context,
>                              org.springframework.osgi.web.context.support,
>                              com.sun.jersey.spi.spring.container.servlet,
>                              *;
>                              resolution:=optional
>                          </Import-Package>
>
>  <Export-Package>com.hoo.unad.sample.*,!*</Export-Package>
>                          <Bundle-Classpath>
>                              WEB-INF/classes
>                          </Bundle-Classpath>
>                          <Web-ContextPath>sample</Web-ContextPath>
>                          <Embed-Dependency>*;
> artifactId=!org.osgi.compendium;
>                              scope=compile; type=!pom;
> inline=true</Embed-Dependency>
>                          <Embed-Transitive>true</Embed-Transitive>
>                          <_removeheaders>
>                              Include-Resource,
>                              Private-Package,
>                              Embed-Dependency,
>                              Embed-Transitive,
>                              Ignore-Package
>                          </_removeheaders>
>
>  <Include-Resource>src/main/resources</Include-Resource>
>                      </instructions>
>                  </configuration>
> <executions>
>                      <execution>
>                          <id>generate-manifest</id>
>                          <phase>process-classes</phase>
>                          <goals>
>                              <goal>manifest</goal>
>                          </goals>
>                      </execution>
>                      <execution>
>                          <id>index</id>
>                          <goals>
>                              <goal>index</goal>
>                          </goals>
>                          <phase>verify</phase>
>                          <configuration>
>
>  <obrRepository>/home/sun/Repository/repository.xml</obrRepository>
>                              <urlTemplate>maven</urlTemplate>
>                          </configuration>
>                      </execution>
>
>                  </executions>
>              </plugin>
>
>              <plugin>
>                  <groupId>org.apache.maven.plugins</groupId>
>                  <artifactId>maven-war-plugin</artifactId>
>                  <version>2.4</version>
>                  <configuration>
>                      <archive>
>
>  <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
>                      </archive>
>                  </configuration>
>              </plugin>
> please give a help, Thanks very much.
>

RE: update bundle not work

Posted by CLEMENT Jean-Philippe <je...@fr.thalesgroup.com>.
In some cases update may fail. As far as I experienced this usually happens when the API is changed in the code but the bundle keeps the same version.

In that case you can use the "refresh <bundleid>" command. Ultimately you can use "refresh -f" (which will also shutdown Karaf).

JP

-----Message d'origine-----
De : 孙丰成 [mailto:fcswhhit@163.com] 
Envoyé : vendredi 24 janvier 2014 11:16
À : users@felix.apache.org
Objet : update bundle not work

Hi,
I am using karaf 3.0.0 to develop osgi application. Recently I encounted a problem.
1)compute bundle provide simple compute methods. such as add. The bundle export interface packages, and did not export interface impl package.
2)simple war bundle is a web project. It depends on compute bundle.
I used maven and obr to manage the deployment. I faced a problem like this:
when I changed one impl class, 
public long add(int a, int b) {
// TODO Auto-generated method stub
return a + b;
}


I changed this method to 
public long add(int a, int b) {
// TODO Auto-generated method stub
return a + 2*b;
}
after execute mvn install, the compute bundle is updated in maven repository. And I execute "update ${computebundleId}", the modified bundle didn't take effect.
simple war bundle pom configuration like this
<plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <version>2.4.0</version>
                 <extensions>true</extensions>
                 <configuration>
                     <supportedProjectTypes>
                         <supportedProjectType>jar</supportedProjectType>
                         <supportedProjectType>bundle</supportedProjectType>
                         <supportedProjectType>war</supportedProjectType>
                     </supportedProjectTypes>
                     <instructions>
                         <Import-Package>
                             org.springframework.web.context,
                             org.springframework.osgi.web.context.support,
                             com.sun.jersey.spi.spring.container.servlet,
                             *;
                             resolution:=optional
                         </Import-Package>
                         <Export-Package>com.hoo.unad.sample.*,!*</Export-Package>
                         <Bundle-Classpath>
                             WEB-INF/classes
                         </Bundle-Classpath>
                         <Web-ContextPath>sample</Web-ContextPath>
                         <Embed-Dependency>*; artifactId=!org.osgi.compendium;
                             scope=compile; type=!pom; inline=true</Embed-Dependency>
                         <Embed-Transitive>true</Embed-Transitive>
                         <_removeheaders>
                             Include-Resource,
                             Private-Package,
                             Embed-Dependency,
                             Embed-Transitive,
                             Ignore-Package
                         </_removeheaders>
                         <Include-Resource>src/main/resources</Include-Resource>
                     </instructions>
                 </configuration>
<executions>
                     <execution>
                         <id>generate-manifest</id>
                         <phase>process-classes</phase>
                         <goals>
                             <goal>manifest</goal>
                         </goals>
                     </execution>
                     <execution>
                         <id>index</id>
                         <goals>
                             <goal>index</goal>
                         </goals>
                         <phase>verify</phase>
                         <configuration>
                             <obrRepository>/home/sun/Repository/repository.xml</obrRepository>
                             <urlTemplate>maven</urlTemplate>
                         </configuration>
                     </execution>
 
                 </executions>
             </plugin>
             
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-war-plugin</artifactId>
                 <version>2.4</version>
                 <configuration>
                     <archive>
                         <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                     </archive>
                 </configuration>
             </plugin>
please give a help, Thanks very much.