You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Ga...@thomsonreuters.com on 2012/01/17 10:57:36 UTC

Problem building war

I'm new to the OSGI world and have been working through examples using
SCR and iPOJO annotations but I've been stumped when creating a war file
using maven plugins. The maven-ipojo-plugin consistently fails to
process the generated war with the following error message:
 
[ERROR] Failed to execute goal
org.apache.felix:maven-ipojo-plugin:1.8.2:ipojo-bundle (default) on
project tui-client-servlet1: Execution default of goal
org.apache.felix:maven-ipojo-plugin:1.8.2:ipojo-bundle failed: Path
'META-INF/MANIFEST.MF' do not start with 'WEB-INF/classes/' -> [Help 1]
 
This occurs in spite of the manifest being in WEB-INF/classes so the
error message doesn't quite make sense (as well as having a grammatical
error: 'does' not 'do').
The problem seems to be that the war plugin always puts a manifest in
the root as well so I question whether the maven-ipojo-plugin can ever
work with the maven-war-plugin.
 
Is it me or is there a bug?
 
Plugin configuration is as follows:
 
  <plugins>
   <plugin>
          <groupId>org.apache.felix</groupId>
          <artifactId>maven-scr-plugin</artifactId>
     <version>1.7.4</version>
            <executions>
                 <execution>
                     <id>generate-scr-scrdescriptor</id>
                     <goals>
                         <goal>scr</goal>
                     </goals>
                </execution>
            </executions>
      </plugin>
 
   <plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1.1</version>
    <configuration>
     <archive>
 
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</man
ifestFile>
     </archive>
     <failOnMissingWebXml>false</failOnMissingWebXml>
          <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
          <webResources>
 
<resource><directory>target/scr-plugin-generated</directory></resource>
          </webResources>
    </configuration>
   </plugin>
 
   <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.3.6</version>
    <extensions>true</extensions>
          <executions>
     <execution>
      <id>bundle-manifest</id>
      <phase>process-classes</phase>
      <goals>
       <goal>manifest</goal>
      </goals>
      <configuration>
              <instructions>
 
<Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
                <Bundle-Version>${project.version}</Bundle-Version>
                <Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath>
                <Export-Package>topOffice.ui.client</Export-Package>
                <Service-Component>*</Service-Component>
               </instructions>
           </configuration>
     </execution>
    </executions>
    <configuration>
     <supportedProjectTypes>
         <supportedProjectType>jar</supportedProjectType>
         <supportedProjectType>bundle</supportedProjectType>
         <supportedProjectType>war</supportedProjectType>
     </supportedProjectTypes>
         </configuration>
   </plugin>
 
   <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-ipojo-plugin</artifactId>
    <version>1.8.2</version>
          <executions>
            <execution>
                <goals>
                    <goal>ipojo-bundle</goal>
                </goals>
           </execution>
         </executions>
   </plugin>
  </plugins>
 
Regards,
Gary Howard
 

This email was sent to you by Thomson Reuters, the global news and information company. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.

Re: Problem building war

Posted by Felix Meschberger <fm...@adobe.com>.
Hi,

Am 17.01.2012 um 11:52 schrieb <Ga...@thomsonreuters.com>:

> Hi Felix,
> 
> I guess it's a combination of naivety on my part and the fact that I've
> also been trying to deploy to an Eclipse Virgo installation and I was
> thinking "Tomcat" rather than pure OSGi. I seem to be having trouble
> switching from the J2EE way to the OSGi way.

That's what I thought ;-)

> 
> From your comment I assume that I just need to create a bundle that
> handles an HTTP Service and I will effectively have OSGI servlets (if
> that's not mixing metaphors too much). Still not quite sure how I
> configure stuff like the servlet URL.

Yes, you just create a bundle.

Your servlet will effectively be registered with the OSGi Http Service. One of the registration parameters is an alias which is like the path to the servlet.

For example: Consider the Http Service is operating in the root context and you register a servlet like this:

  httpService.registerServle("/myservlet", servlet, null, null);

your servlet will respond to everything at and below http://host:port/myservlet.

> 
> Ultimately I would like to have OSGi WebServices as well. Do you know of
> any good references on how to create OSGi Servlets/WebServices?

Well, to be honest, I stay away as far as possible from WebServices.

But creating a servlet is really straight forward:

 * Create the class
 * Use whatever technology to instantiate the class; for example I prefer
   Declarative Services, you might also consider iPojo or even Blueprint.
 * Considering Declarative Services for now: The servlet component is setup
   to get a reference to the HttpService service. In the activate method
   you call registerServlet to register yourself and in the deactivate
   method you call unregister to unregister the servlet.

You might want to look at the Web Console project for a Servlet being registered (though this uses a straight BundleActivator instead of Declarative Services).

Regards¨
Felix

> 
> Regards,
> Gary
> 
> 
> -----Original Message-----
> From: Felix Meschberger [mailto:fmeschbe@adobe.com] 
> Sent: 17 January 2012 10:23
> To: users@felix.apache.org
> Subject: Re: Problem building war
> 
> Hi,
> 
> I wonder, why you want to build a WAR file ?
> 
> Generally an OSGi bundle is just a plain JAR file with some more
> Manifest attributes (we call them headers) and maybe leveraging OSGi
> functionality. This bundle is then directly deployed into an OSGi
> framework.
> 
> This all has nothing to do with WAR files and Servlet Containers etc.
> 
> Regards
> Felix
> 
> 
> 
> This email was sent to you by Thomson Reuters, the global news and information company. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


RE: Problem building war

Posted by Ga...@thomsonreuters.com.
Hi Felix,

I guess it's a combination of naivety on my part and the fact that I've
also been trying to deploy to an Eclipse Virgo installation and I was
thinking "Tomcat" rather than pure OSGi. I seem to be having trouble
switching from the J2EE way to the OSGi way.

>From your comment I assume that I just need to create a bundle that
handles an HTTP Service and I will effectively have OSGI servlets (if
that's not mixing metaphors too much). Still not quite sure how I
configure stuff like the servlet URL.

Ultimately I would like to have OSGi WebServices as well. Do you know of
any good references on how to create OSGi Servlets/WebServices?

Regards,
Gary


-----Original Message-----
From: Felix Meschberger [mailto:fmeschbe@adobe.com] 
Sent: 17 January 2012 10:23
To: users@felix.apache.org
Subject: Re: Problem building war

Hi,

I wonder, why you want to build a WAR file ?

Generally an OSGi bundle is just a plain JAR file with some more
Manifest attributes (we call them headers) and maybe leveraging OSGi
functionality. This bundle is then directly deployed into an OSGi
framework.

This all has nothing to do with WAR files and Servlet Containers etc.

Regards
Felix



This email was sent to you by Thomson Reuters, the global news and information company. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.

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


Re: Problem building war

Posted by Felix Meschberger <fm...@adobe.com>.
Hi,

I wonder, why you want to build a WAR file ?

Generally an OSGi bundle is just a plain JAR file with some more Manifest attributes (we call them headers) and maybe leveraging OSGi functionality. This bundle is then directly deployed into an OSGi framework.

This all has nothing to do with WAR files and Servlet Containers etc.

Regards
Felix



Am 17.01.2012 um 10:57 schrieb <Ga...@thomsonreuters.com>:

> I'm new to the OSGI world and have been working through examples using
> SCR and iPOJO annotations but I've been stumped when creating a war file
> using maven plugins. The maven-ipojo-plugin consistently fails to
> process the generated war with the following error message:
> 
> [ERROR] Failed to execute goal
> org.apache.felix:maven-ipojo-plugin:1.8.2:ipojo-bundle (default) on
> project tui-client-servlet1: Execution default of goal
> org.apache.felix:maven-ipojo-plugin:1.8.2:ipojo-bundle failed: Path
> 'META-INF/MANIFEST.MF' do not start with 'WEB-INF/classes/' -> [Help 1]
> 
> This occurs in spite of the manifest being in WEB-INF/classes so the
> error message doesn't quite make sense (as well as having a grammatical
> error: 'does' not 'do').
> The problem seems to be that the war plugin always puts a manifest in
> the root as well so I question whether the maven-ipojo-plugin can ever
> work with the maven-war-plugin.
> 
> Is it me or is there a bug?
> 
> Plugin configuration is as follows:
> 
>  <plugins>
>   <plugin>
>          <groupId>org.apache.felix</groupId>
>          <artifactId>maven-scr-plugin</artifactId>
>     <version>1.7.4</version>
>            <executions>
>                 <execution>
>                     <id>generate-scr-scrdescriptor</id>
>                     <goals>
>                         <goal>scr</goal>
>                     </goals>
>                </execution>
>            </executions>
>      </plugin>
> 
>   <plugin>
>    <artifactId>maven-war-plugin</artifactId>
>    <version>2.1.1</version>
>    <configuration>
>     <archive>
> 
> <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</man
> ifestFile>
>     </archive>
>     <failOnMissingWebXml>false</failOnMissingWebXml>
>          <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
>          <webResources>
> 
> <resource><directory>target/scr-plugin-generated</directory></resource>
>          </webResources>
>    </configuration>
>   </plugin>
> 
>   <plugin>
>    <groupId>org.apache.felix</groupId>
>    <artifactId>maven-bundle-plugin</artifactId>
>    <version>2.3.6</version>
>    <extensions>true</extensions>
>          <executions>
>     <execution>
>      <id>bundle-manifest</id>
>      <phase>process-classes</phase>
>      <goals>
>       <goal>manifest</goal>
>      </goals>
>      <configuration>
>              <instructions>
> 
> <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
>                <Bundle-Version>${project.version}</Bundle-Version>
>                <Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath>
>                <Export-Package>topOffice.ui.client</Export-Package>
>                <Service-Component>*</Service-Component>
>               </instructions>
>           </configuration>
>     </execution>
>    </executions>
>    <configuration>
>     <supportedProjectTypes>
>         <supportedProjectType>jar</supportedProjectType>
>         <supportedProjectType>bundle</supportedProjectType>
>         <supportedProjectType>war</supportedProjectType>
>     </supportedProjectTypes>
>         </configuration>
>   </plugin>
> 
>   <plugin>
>    <groupId>org.apache.felix</groupId>
>    <artifactId>maven-ipojo-plugin</artifactId>
>    <version>1.8.2</version>
>          <executions>
>            <execution>
>                <goals>
>                    <goal>ipojo-bundle</goal>
>                </goals>
>           </execution>
>         </executions>
>   </plugin>
>  </plugins>
> 
> Regards,
> Gary Howard
> 
> 
> This email was sent to you by Thomson Reuters, the global news and information company. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.


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