You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by to...@quarendon.net on 2017/06/13 07:52:18 UTC

Exception starting karaf custom distro "minimal example" from docs

I've attempted to build a simple custom Karaf distribution using the maven plugin and the karaf-assembly packaging.
I can build the assembly, but when I start the result I get an exception.

My pom configuration is currently very simple, just:

   <dependencies>
        <dependency>
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>framework</artifactId>
            <version>${karafVersion}</version>
            <type>kar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>standard</artifactId>
            <version>${karafVersion}</version>
            <classifier>features</classifier>
            <type>xml</type>
			<scope>compile</scope>
        </dependency>

   ...

            <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>karaf-maven-plugin</artifactId>
                <configuration>
                    <!-- <startupFeatures/> -->
                    <bootFeatures>
                        <!-- standard distribution -->
                        <feature>standard</feature>
                        <!-- minimal distribution -->
                        <!--<feature>minimal</feature>-->
                    </bootFeatures>
                    <javase>1.8</javase>
                </configuration>
            </plugin>


karafVersion is 4.1.1

So I'm just bundling karaf, I'm not including anything else. This is the "minimal example" in the karaf docs.

On startup I get the log here : https://gist.github.com/tomq42/47403ec44413fdc517c70dc3cccbf0cb

I get the same if I specify "minimal" in "bootFeatures". 
Am I doing something wrong here? 

Thanks.

Re: Exception starting karaf custom distro "minimal example" from docs

Posted by Achim Nierbeck <bc...@googlemail.com>.
regarding your "maven" confidence ... do you happen to have a "Proxy"
connected to your maven setup?
In rare cases, or flaky internet connections your bundles might not have
been a jar at all, but a http error code ;)
This happens in rare cases.
Best to do a mvn clean install -U for updating all dependencies.

regards, Achim


2017-06-13 15:26 GMT+02:00 <to...@quarendon.net>:

> > On 13 June 2017 at 12:32 Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
> >
> >
> > I don't understand why you have the pax-web feature.
> >
> > Do you have it defined in bootFeatures ? Or do you install it by hand ?
> >
> > I can confirm that I don't have pax-web feature on my custom distro.
>
> So I created a completely fresh directory, deleted the contents of my .m2
> maven repository cache, created a pom.xml file with your example contents
> in, and ran "mvn clean install".
>
> I ran target/assembly/bin/karaf.bat.
> feature:list then lists pax-http as "started".
>
> Interestingly though I have no exceptions in the log file.
>
> Well that's interesting.
> Worryingly, deleting my .m2 directory contents seems to have altered the
> behaviour. Going back to my original example, it now works closer to how I
> would expect.
> I admit my knowledge of Maven is low, but it's a cache isn't it?
> Re-downloading the dependencies ought not to have changed anything? That
> worries me.
>
> The good news is that this seems to have fixed things. I no longer have
> odd exceptions in the log.
>
> Confidence in Karaf has increased, confidence in maven lowered!
> Thanks for the help.
>



-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Re: Exception starting karaf custom distro "minimal example" from docs

Posted by to...@quarendon.net.
> On 13 June 2017 at 12:32 Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
> 
> 
> I don't understand why you have the pax-web feature.
> 
> Do you have it defined in bootFeatures ? Or do you install it by hand ?
> 
> I can confirm that I don't have pax-web feature on my custom distro.

So I created a completely fresh directory, deleted the contents of my .m2 maven repository cache, created a pom.xml file with your example contents in, and ran "mvn clean install".

I ran target/assembly/bin/karaf.bat.
feature:list then lists pax-http as "started".

Interestingly though I have no exceptions in the log file.

Well that's interesting. 
Worryingly, deleting my .m2 directory contents seems to have altered the behaviour. Going back to my original example, it now works closer to how I would expect. 
I admit my knowledge of Maven is low, but it's a cache isn't it? Re-downloading the dependencies ought not to have changed anything? That worries me.

The good news is that this seems to have fixed things. I no longer have odd exceptions in the log.

Confidence in Karaf has increased, confidence in maven lowered!
Thanks for the help.

Re: Exception starting karaf custom distro "minimal example" from docs

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
I don't understand why you have the pax-web feature.

Do you have it defined in bootFeatures ? Or do you install it by hand ?

I can confirm that I don't have pax-web feature on my custom distro.

Regards
JB

On 06/13/2017 11:13 AM, tom@quarendon.net wrote:
> 
>> On 13 June 2017 at 09:08 Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
>>
>>
>> Hi Tom,
>>
>> Here's a pom.xml to do what you want:
> 
> As far as I can see that's the same as the "minimal example" in the docs.
> If I use your example, I still get errors:
> 
> 2017-06-13T09:46:01,692 | ERROR | FelixDispatchQueue | pax-web-extender-whiteboard      | 118 - org.ops4j.pax.web.pax-web-extender-whiteboard - 6.0.3 | FrameworkEvent ERROR - org.ops4j.pax.web.pax-web-extender-whiteboard
> org.osgi.framework.BundleException: Activator start error in bundle org.ops4j.pax.web.pax-web-extender-whiteboard [118].
> 	at org.apache.felix.framework.Felix.activateBundle(Felix.java:2288) [?:?]
> 	at org.apache.felix.framework.Felix.startBundle(Felix.java:2144) [?:?]
> 	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371) [?:?]
> 	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308) [?:?]
> 	at java.lang.Thread.run(Thread.java:745) [?:?]
> Caused by: java.lang.ClassCastException: org.apache.felix.httplite.osgi.HttpServiceImpl cannot be cast to org.osgi.service.http.HttpService
> 
> and
> 2017-06-13T09:50:23,076 | ERROR | paxweb-config-2-thread-1 | Felix                            |  -  -  | Bundle org.apache.felix.inventory [36] EventDispatcher: Error during dispatch. (java.lang.ClassCastException: org.apache.felix.httplite.osgi.HttpServiceImpl cannot be cast to org.osgi.service.http.HttpService)
> 
> and
> 
> 2017-06-13T09:50:23,076 | ERROR | FelixDispatchQueue | inventory                        | 36 - org.apache.felix.inventory - 1.0.4 | FrameworkEvent ERROR - org.apache.felix.inventory
> java.lang.ClassCastException: org.apache.felix.httplite.osgi.HttpServiceImpl cannot be cast to org.osgi.service.http.HttpService
> 
> etc.
> 
> The "javax.servlet two chains" issue has gone. However that comes back if I specify "enterprise" instead of "standard" in my "bootFeatures" (investigating I had a "org.apache.karaf.features.cfg" file that specified some things that I had inherited from another example -- deleted that now).
> 
> 
> This clearly indicates to be that there are just some incompatible bundles there. org.ops4j.pax.web.pax-web-extender-whiteboard is expecting org.apache.felix.httplite.osgi.HttpServiceImpl to be a org.osgi.service.http.HttpService when it's not, or at least not the same org.osgi.service.http.HttpService class.
> 
> 
> Closing Karaf down and then starting it up again though, it still just hangs with no output of any kind, no logging.
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Exception starting karaf custom distro "minimal example" from docs

Posted by to...@quarendon.net.
> On 13 June 2017 at 09:08 Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
> 
> 
> Hi Tom,
> 
> Here's a pom.xml to do what you want:

As far as I can see that's the same as the "minimal example" in the docs. 
If I use your example, I still get errors:

2017-06-13T09:46:01,692 | ERROR | FelixDispatchQueue | pax-web-extender-whiteboard      | 118 - org.ops4j.pax.web.pax-web-extender-whiteboard - 6.0.3 | FrameworkEvent ERROR - org.ops4j.pax.web.pax-web-extender-whiteboard
org.osgi.framework.BundleException: Activator start error in bundle org.ops4j.pax.web.pax-web-extender-whiteboard [118].
	at org.apache.felix.framework.Felix.activateBundle(Felix.java:2288) [?:?]
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2144) [?:?]
	at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1371) [?:?]
	at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308) [?:?]
	at java.lang.Thread.run(Thread.java:745) [?:?]
Caused by: java.lang.ClassCastException: org.apache.felix.httplite.osgi.HttpServiceImpl cannot be cast to org.osgi.service.http.HttpService

and
2017-06-13T09:50:23,076 | ERROR | paxweb-config-2-thread-1 | Felix                            |  -  -  | Bundle org.apache.felix.inventory [36] EventDispatcher: Error during dispatch. (java.lang.ClassCastException: org.apache.felix.httplite.osgi.HttpServiceImpl cannot be cast to org.osgi.service.http.HttpService)

and 

2017-06-13T09:50:23,076 | ERROR | FelixDispatchQueue | inventory                        | 36 - org.apache.felix.inventory - 1.0.4 | FrameworkEvent ERROR - org.apache.felix.inventory
java.lang.ClassCastException: org.apache.felix.httplite.osgi.HttpServiceImpl cannot be cast to org.osgi.service.http.HttpService

etc.

The "javax.servlet two chains" issue has gone. However that comes back if I specify "enterprise" instead of "standard" in my "bootFeatures" (investigating I had a "org.apache.karaf.features.cfg" file that specified some things that I had inherited from another example -- deleted that now).


This clearly indicates to be that there are just some incompatible bundles there. org.ops4j.pax.web.pax-web-extender-whiteboard is expecting org.apache.felix.httplite.osgi.HttpServiceImpl to be a org.osgi.service.http.HttpService when it's not, or at least not the same org.osgi.service.http.HttpService class.


Closing Karaf down and then starting it up again though, it still just hangs with no output of any kind, no logging.

Re: Exception starting karaf custom distro "minimal example" from docs

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Tom,

Here's a pom.xml to do what you want:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">

   <modelVersion>4.0.0</modelVersion>

   <groupId>example</groupId>
   <artifactId>my-karaf</artifactId>
   <version>1.0.0-SNAPSHOT</version>
   <packaging>karaf-assembly</packaging>

   <dependencies>
     <dependency>
       <groupId>org.apache.karaf.features</groupId>
       <artifactId>framework</artifactId>
       <version>4.1.1</version>
       <type>kar</type>
     </dependency>
     <dependency>
       <groupId>org.apache.karaf.features</groupId>
       <artifactId>standard</artifactId>
       <version>4.1.1</version>
       <classifier>features</classifier>
       <type>xml</type>
     </dependency>
   </dependencies>


   <build>
     <plugins>
       <plugin>
         <groupId>org.apache.karaf.tooling</groupId>
         <artifactId>karaf-maven-plugin</artifactId>
         <version>4.1.1</version>
         <extensions>true</extensions>
         <configuration>
           <bootFeatures>
             <feature>standard</feature>
           </bootFeatures>
           <javase>1.8</javase>
         </configuration>
       </plugin>
     </plugins>
   </build>

</project>

It's what I used during ApacheCon to build a custom distribution of Karaf 
embedding Cellar (I removed the Cellar part for you).

Regards
JB

On 06/13/2017 09:52 AM, tom@quarendon.net wrote:
> I've attempted to build a simple custom Karaf distribution using the maven plugin and the karaf-assembly packaging.
> I can build the assembly, but when I start the result I get an exception.
> 
> My pom configuration is currently very simple, just:
> 
>     <dependencies>
>          <dependency>
>              <groupId>org.apache.karaf.features</groupId>
>              <artifactId>framework</artifactId>
>              <version>${karafVersion}</version>
>              <type>kar</type>
>          </dependency>
>          <dependency>
>              <groupId>org.apache.karaf.features</groupId>
>              <artifactId>standard</artifactId>
>              <version>${karafVersion}</version>
>              <classifier>features</classifier>
>              <type>xml</type>
> 			<scope>compile</scope>
>          </dependency>
> 
>     ...
> 
>              <plugin>
>                  <groupId>org.apache.karaf.tooling</groupId>
>                  <artifactId>karaf-maven-plugin</artifactId>
>                  <configuration>
>                      <!-- <startupFeatures/> -->
>                      <bootFeatures>
>                          <!-- standard distribution -->
>                          <feature>standard</feature>
>                          <!-- minimal distribution -->
>                          <!--<feature>minimal</feature>-->
>                      </bootFeatures>
>                      <javase>1.8</javase>
>                  </configuration>
>              </plugin>
> 
> 
> karafVersion is 4.1.1
> 
> So I'm just bundling karaf, I'm not including anything else. This is the "minimal example" in the karaf docs.
> 
> On startup I get the log here : https://gist.github.com/tomq42/47403ec44413fdc517c70dc3cccbf0cb
> 
> I get the same if I specify "minimal" in "bootFeatures".
> Am I doing something wrong here?
> 
> Thanks.
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com