You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Martin Zukal <ma...@stabilit.ch> on 2022/09/05 15:10:41 UTC

RE: Aspectj in Apache Karaf 4.4.1

Hello everyone!

I am sorry to reply to my own email but I would really like to know whether there is somebody who was able to get aspectj and load-time weaving running with Apache Karaf.

I am really stuck on this so any hint would be hihgly appreciated!

Best Regards

Martin Zukal

 

 

From: Martin Zukal <ma...@stabilit.ch> 
Sent: Saturday, August 27, 2022 11:42 AM
To: 'user@karaf.apache.org' <us...@karaf.apache.org>
Subject: Aspectj in Apache Karaf 4.4.1

 

Hello everyone!

I am trying to enable aspectj in Apache Karaf version 4.4.1 and I am unable to get it to work. I have a project based on Spring which I want to run in Apache Karaf. This project contains the aspects and includes the following lines in the configuration:

<context:load-time-weaver aspectj-weaving="on" />

<aop:aspectj-autoproxy />

Which is why I need aspectj in the runtime.

What I should probably also mention is that the project uses Gemini Blueprint version 3.0.0.M01 to publish the Spring services into the OSGi context.

 

I was not able to find any recent tutorial how to enable aspects in Apache Karaf so I followed this blog post: http://dywicki.pl/2011/11/running-aspects-under-osgi-4-2-with-karaf/ and adapted the procedure slightly. What I did so far is:

*	Changed the framework from felix to equinox
*	Placed the three bundles (org.eclipse.equinox.weaving.aspectj, org.eclipse.equinox.weaving.caching and org.eclipse.equinox.weaving.hook) into the system directory
*	Added entries for the above mentioned bundles to startup.properties

Apache karaf starts fine with the above described configuration and I can see all weaving bundles as active in the console (org.eclipse.equinox.weaving.hook is a fragment so there it says fragment).

 

However, when I try to deploy the bundle with my Spring project I get the following exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.config.internalAspectJWeavingEnabler': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadTimeWeaver': Initialization of bean failed; nested exception is java.lang.IllegalStateException: ClassLoader [org.eclipse.gemini.blueprint.util.BundleDelegatingClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:spring-instrument-{version}.jar

I tried to start Apache Karaf with the -javaagent option but it did not help.

I am coming from Eclipse Virgo and the aspects were working there quite fine. One of the settings which was needed to add was 

osgi.framework.extensions = org.eclipse.equinox.weaving.hook. 

Is there a possibility how to add this setting to Apache Karaf?

 

Is there any recent tutorial how to get aspects working in Apache Karaf? I would really appreciate any help with this topic!

Best Regards

Martin Zukal




Re: startupFeatures vs. bootFeatures when building custom karaf distribution

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

Generally speaking, I would recommend bootFeatures (startupFeatures
are more for Karaf internals or specific use cases).

Regards
JB

On Wed, Nov 9, 2022 at 11:24 AM Martin Zukal via user
<us...@karaf.apache.org> wrote:
>
> Hi,
> Thanks for pointing me to the right documentation.
> So the best practice is to use:
> bootFeatures with runtime scope dependencies (features)
> or
> startupFeatures with compile scope dependencies (features)
> is that right?
> I currently use startupFeatures with runtime scope dependencies which is apparently wrong (but it produces the same result as if bootFeatures are used).
> Regards
> Martin Zukal
>
>
> -----Original Message-----
> From: Jean-Baptiste Onofré <jb...@nanthrax.net>
> Sent: Sunday, November 6, 2022 11:32 AM
> To: user@karaf.apache.org
> Cc: Martin Zukal <ma...@stabilit.ch>
> Subject: Re: startupFeatures vs. bootFeatures when building custom karaf distribution
>
> Hi,
>
> As reminder, it's documented here:
> https://karaf.apache.org/manual/latest/#_instances_and_distributions_goals
>
> Especially you can see:
>
> startupFeatures | List<String> | List of features from compile-scope features XML files and KARs to be installed into system repo and listed in etc/startup.properties.
> bootFeatures | List<String> | List of features from runtime-scope features XML files and KARs to be installed into system repo and listed in featuresBoot property in etc/org.apache.karaf.features.cfg
>
> Regards
> JB
>
> On Thu, Nov 3, 2022 at 12:47 PM Grzegorz Grzybek <gr...@gmail.com> wrote:
> >
> > Hello
> >
> >> When I tried to replace the <startupFeatures> with <bootFeatures> Karaf failed to start (the log file is completely empty).
> >
> >
> > In previous email I didn't explain enough about the difference. What I said could be confusing, though it's true:
> >
> > compile scoped dependencies and/or features declared in
> > <startupFeatures> are effectively replaced by a list of bundles and
> > put into etc/startup.properties runtime scoped dependencies and/or
> > features declared in <bootFeatures> are declared in "featuresBoot"
> > property in etc/org.apache.karaf.features.cfg
> >
> > In both cases, you get your dependencies in "system/" directory of your custom distro.
> >
> > What I didn't mention is that you actually need _some_ features to be startupFeatures - most importantly the "feature" feature ;) The point is that in order to install features (from etc/org.apache.karaf.features.cfg) you need a bundle running that reads this file, so this bundle (org.apache.karaf.features.core) needs to be installed directly - from etc/startup.properties.
> >
> > Please have a look at the configuration of karaf-maven-plugin of the
> > Apache Karaf distro itself:
> > https://github.com/apache/karaf/blob/karaf-4.4.2/assemblies/apache-kar
> > af/pom.xml While "feature" feature is not a startup feature, there's
> > compile-scoped dependency:
> >
> >         <dependency>
> >             <groupId>org.apache.karaf.features</groupId>
> >             <artifactId>framework</artifactId>
> >             <type>kar</type>
> >         </dependency>
> >
> > it (through a bit complex stages) installs a startup feature called "framework" which includes the org.apache.karaf.features.core bundle as startup bundle.
> > You're using "framework-logback" variant of this feature and it has to be kept as startupFeature.
> >
> > regards
> > Grzegorz Grzybek
> >
> > czw., 3 lis 2022 o 12:35 Martin Zukal via user <us...@karaf.apache.org> napisał(a):
> >>
> >> Hello,
> >>
> >> To be honest I am confused about the <startupFeatures> and
> >> <bootFeatures>. I followed the documentation here:
> >> https://svn.apache.org/repos/asf/karaf/site/production/manual/latest/
> >> custom-distribution.html#_plugin_configuration but it did not work
> >> the way I expected. I am trying to build a custom Karaf distribution
> >> which should resolve all artifacts locally (not in the maven
> >> repository). The idea is to have all artifacts needed by Karaf itself
> >> in the <KARAF_HOME>/system directory and all artifacts required by my
> >> application in a new directory <KARAF_HOME>/repository. I firstly
> >> build the „bare“ karaf and then I add the repository directory (which
> >> is generated using karaf-maven-plugin but using the
> >> <goal>features-add-to-repository</goal> based on my feature.xml file
> >> )
> >>
> >> I created the following 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/xsd/maven-4.0.0.xsd>
> >>
> >>                 <modelVersion>4.0.0</modelVersion>
> >>
> >>
> >>
> >>
> >>
> >>                 <groupId>ch.stabilit</groupId>
> >>
> >>                 <artifactId>apache-karaf-STABILIT</artifactId>
> >>
> >>                 <version>4.4.1</version>
> >>
> >>                 <name>Apache Karaf distribution</name>
> >>
> >>                 <packaging>karaf-assembly</packaging>
> >>
> >>
> >>
> >>
> >>
> >>                 <properties>
> >>
> >>                                <karaf.version>4.4.1</karaf.version>
> >>
> >>                 </properties>
> >>
> >>
> >>
> >>                 <dependencies>
> >>
> >>                                <dependency>
> >>
> >>
> >> <groupId>org.apache.karaf.features</groupId>
> >>
> >>
> >> <artifactId>framework</artifactId>
> >>
> >>
> >> <version>${karaf.version}</version>
> >>
> >>                                                <type>kar</type>
> >>
> >>                                </dependency>
> >>
> >>                                <dependency>
> >>
> >>
> >> <groupId>org.apache.karaf.features</groupId>
> >>
> >>
> >> <artifactId>framework</artifactId>
> >>
> >>
> >> <version>${karaf.version}</version>
> >>
> >>
> >> <classifier>features</classifier>
> >>
> >>                                                <type>xml</type>
> >>
> >>                                                <scope>runtime</scope>
> >>
> >>                                </dependency>
> >>
> >>                                <dependency>
> >>
> >>
> >> <groupId>org.apache.karaf.features</groupId>
> >>
> >>
> >> <artifactId>standard</artifactId>
> >>
> >>
> >> <version>${karaf.version}</version>
> >>
> >>
> >> <classifier>features</classifier>
> >>
> >>                                                <type>xml</type>
> >>
> >>                                                <scope>runtime</scope>
> >>
> >>                                </dependency>
> >>
> >>                 </dependencies>
> >>
> >>
> >>
> >>                 <build>
> >>
> >>                                <plugins>
> >>
> >>                                                <plugin>
> >>
> >>
> >> <groupId>org.apache.karaf.tooling</groupId>
> >>
> >>
> >> <artifactId>karaf-maven-plugin</artifactId>
> >>
> >>
> >> <version>${karaf.version}</version>
> >>
> >>
> >> <extensions>true</extensions>
> >>
> >>
> >> <executions>
> >>
> >>
> >> <execution>
> >>
> >>
> >> <id>assembly</id>
> >>
> >>
> >> <phase>prepare-package</phase>
> >>
> >>
> >> <goals>
> >>
> >>
> >> <goal>assembly</goal>
> >>
> >>
> >> </goals>
> >>
> >>
> >> </execution>
> >>
> >>
> >> </executions>
> >>
> >>
> >> <configuration>
> >>
> >>
> >> <bootRepositories>
> >>
> >>
> >> <bootRepository>mvn:org.apache.karaf.features/spring/${karaf.version}
> >> /xml/features</bootRepository>
> >>
> >>
> >> <bootRepository>mvn:org.apache.karaf.features/specs/${karaf.version}/
> >> xml/features</bootRepository>
> >>
> >>
> >> <bootRepository>mvn:org.apache.karaf.features/enterprise/${karaf.vers
> >> ion}/xml/features</bootRepository>
> >>
> >>
> >> </bootRepositories>
> >>
> >>
> >> <startupFeatures>
> >>
> >>
> >> <startupFeature>framework-logback</startupFeature>
> >>
> >>
> >> <startupFeature>instance</startupFeature>
> >>
> >>
> >> <startupFeature>package</startupFeature>
> >>
> >>
> >> <startupFeature>log</startupFeature>
> >>
> >>
> >> <startupFeature>ssh</startupFeature>
> >>
> >>
> >> <startupFeature>system</startupFeature>
> >>
> >>
> >> <startupFeature>feature</startupFeature>
> >>
> >>
> >> <startupFeature>shell</startupFeature>
> >>
> >>
> >> <startupFeature>management</startupFeature>
> >>
> >>
> >> <startupFeature>service</startupFeature>
> >>
> >>
> >> <startupFeature>jaas</startupFeature>
> >>
> >>
> >> <startupFeature>deployer</startupFeature>
> >>
> >>
> >> <startupFeature>diagnostic</startupFeature>
> >>
> >>
> >> <startupFeature>wrap</startupFeature>
> >>
> >>
> >> <startupFeature>bundle</startupFeature>
> >>
> >>
> >> <startupFeature>config</startupFeature>
> >>
> >>
> >> <startupFeature>webconsole</startupFeature>
> >>
> >>
> >> <startupFeature>pax-web-http-tomcat</startupFeature>
> >>
> >>
> >> </startupFeatures>
> >>
> >>
> >> <useReferenceUrls>true</useReferenceUrls>
> >>
> >>
> >> <installAllFeaturesByDefault>false</installAllFeaturesByDefault>
> >>
> >>
> >> <framework>framework-logback</framework>
> >>
> >>
> >> <archiveTarGz>false</archiveTarGz>
> >>
> >>
> >> <propertyEdits>
> >>
> >>
> >> <edits>
> >>
> >>
> >> <edit>
> >>
> >>
> >> <file>config.properties</file>
> >>
> >>
> >> <operation>
> >>
> >>
> >> <operation>put</operation>
> >>
> >>
> >> </operation>
> >>
> >>
> >> <key>karaf.framework</key>
> >>
> >>
> >> <value>equinox</value>
> >>
> >>
> >> </edit>
> >>
> >>
> >> <edit>
> >>
> >>
> >> <file>config.properties</file>
> >>
> >>
> >> <operation>
> >>
> >>
> >> <operation>extend</operation>
> >>
> >>
> >> </operation>
> >>
> >>
> >> <key>org.osgi.framework.system.packages</key>
> >>
> >>
> >> <value>com.sun.jndi.ldap</value>
> >>
> >>
> >> </edit>
> >>
> >>
> >> <edit>
> >>
> >>
> >> <file>config.properties</file>
> >>
> >>
> >> <operation>
> >>
> >>
> >> <operation>extend</operation>
> >>
> >>
> >> </operation>
> >>
> >>
> >> <key>org.osgi.framework.system.packages</key>
> >>
> >>
> >> <value>com.sun.jndi.url.ldap</value>
> >>
> >>
> >> </edit>
> >>
> >>
> >> <edit>
> >>
> >>
> >> <file>config.properties</file>
> >>
> >>
> >> <operation>
> >>
> >>
> >> <operation>extend</operation>
> >>
> >>
> >> </operation>
> >>
> >>
> >> <key>org.osgi.framework.bootdelegation</key>
> >>
> >>
> >> <value> com.sun.jndi.ldap.*</value>
> >>
> >>
> >> </edit>
> >>
> >>
> >> <edit>
> >>
> >>
> >> <file>users.properties</file>
> >>
> >>
> >> <operation>
> >>
> >>
> >> <operation>put</operation>
> >>
> >>
> >> </operation>
> >>
> >>
> >> <key>_g_:admingroup</key>
> >>
> >>
> >> <value>group,admin,manager,viewer,systembundles,ssh</value>
> >>
> >>
> >> </edit>
> >>
> >>
> >> <edit>
> >>
> >>
> >> <file>users.properties</file>
> >>
> >>
> >> <operation>
> >>
> >>
> >> <operation>put</operation>
> >>
> >>
> >> </operation>
> >>
> >>
> >> <key>karaf</key>
> >>
> >>
> >> <value>karaf,_g_:admingroup</value>
> >>
> >>
> >> </edit>
> >>
> >>
> >> <edit>
> >>
> >>
> >> <file>org.ops4j.pax.logging.cfg</file>
> >>
> >>
> >> <operation>
> >>
> >>
> >> <operation>put</operation>
> >>
> >>
> >> </operation>
> >>
> >>
> >> <key>org.ops4j.pax.logging.logback.config.file</key>
> >>
> >>
> >> <value>${karaf.base}/configuration/serviceability.xml</value>
> >>
> >>
> >> </edit>
> >>
> >>
> >> <edit>
> >>
> >>
> >> <file>system.properties</file>
> >>
> >>
> >> <operation>
> >>
> >>
> >> <operation>put</operation>
> >>
> >>
> >> </operation>
> >>
> >>
> >> <key>karaf.clean.all</key>
> >>
> >>
> >> <value>true</value>
> >>
> >>
> >> </edit>
> >>
> >>
> >> <edit>
> >>
> >>
> >> <file>org.ops4j.pax.web.cfg</file>
> >>
> >>
> >> <operation>
> >>
> >>
> >> <operation>put</operation>
> >>
> >>
> >> </operation>
> >>
> >>
> >> <key>org.osgi.service.http.port</key>
> >>
> >>
> >> <value>8080</value>
> >>
> >>
> >> </edit>
> >>
> >>
> >> <edit>
> >>
> >>
> >> <file>org.ops4j.pax.url.mvn.cfg</file>
> >>
> >>
> >> <operation>
> >>
> >>
> >> <operation>put</operation>
> >>
> >>
> >> </operation>
> >>
> >>
> >> <key>org.ops4j.pax.url.mvn.localRepository</key>
> >>
> >>
> >> <value>${karaf.base}/repository</value>
> >>
> >>
> >> </edit>
> >>
> >>
> >> <edit>
> >>
> >>
> >> <file>org.ops4j.pax.url.mvn.cfg</file>
> >>
> >>
> >> <operation>
> >>
> >>
> >> <operation>put</operation>
> >>
> >>
> >> </operation>
> >>
> >>
> >> <key>org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote</key>
> >>
> >>
> >> <value>true</value>
> >>
> >>
> >> </edit>
> >>
> >>
> >> <edit>
> >>
> >>
> >> <file>org.ops4j.pax.url.mvn.cfg</file>
> >>
> >>
> >> <operation>
> >>
> >>
> >> <operation>put</operation>
> >>
> >>
> >> </operation>
> >>
> >>
> >> <key>org.ops4j.pax.url.mvn.repositories</key>
> >>
> >>
> >> <value>${karaf.home.uri}repository@id=local.repository@snapshots</val
> >> ue>
> >>
> >>
> >> </edit>
> >>
> >>
> >> </edits>
> >>
> >>
> >> </propertyEdits>
> >>
> >>
> >> </configuration>
> >>
> >>
> >>
> >>                                                </plugin>
> >>
> >>                                </plugins>
> >>
> >>                 </build>
> >>
> >> </project>
> >>
> >>
> >>
> >> With which I am able to build Karaf distribution which satisfies all my requirements.
> >>
> >>
> >>
> >> You wrote that using startupFeatures will create a large startup.properties file. This is something I don’t observe. My startup.properties looks like this:
> >>
> >> # Bundles to be started on startup, with startlevel
> >>
> >> reference\:file\:org/apache/karaf/features/org.apache.karaf.features.
> >> extension/4.4.1/org.apache.karaf.features.extension-4.4.1.jar = 1
> >>
> >> reference\:file\:org/ops4j/pax/url/pax-url-aether/2.6.11/pax-url-aeth
> >> er-2.6.11.jar = 5
> >>
> >> reference\:file\:org/ops4j/pax/logging/pax-logging-logback/2.1.3/pax-
> >> logging-logback-2.1.3.jar = 8
> >>
> >> reference\:file\:org/ops4j/pax/logging/pax-logging-api/2.1.3/pax-logg
> >> ing-api-2.1.3.jar = 8
> >>
> >> reference\:file\:org/osgi/org.osgi.util.function/1.2.0/org.osgi.util.
> >> function-1.2.0.jar = 9
> >>
> >> reference\:file\:org/osgi/org.osgi.util.promise/1.2.0/org.osgi.util.p
> >> romise-1.2.0.jar = 9
> >>
> >> reference\:file\:org/apache/felix/org.apache.felix.coordinator/1.0.2/
> >> org.apache.felix.coordinator-1.0.2.jar = 9
> >>
> >> reference\:file\:org/apache/felix/org.apache.felix.converter/1.0.14/o
> >> rg.apache.felix.converter-1.0.14.jar = 9
> >>
> >> reference\:file\:org/apache/felix/org.apache.felix.configadmin/1.9.24
> >> /org.apache.felix.configadmin-1.9.24.jar = 10
> >>
> >> reference\:file\:org/apache/felix/org.apache.felix.configurator/1.0.1
> >> 4/org.apache.felix.configurator-1.0.14.jar = 11
> >>
> >> reference\:file\:org/apache/sling/org.apache.sling.commons.johnzon/1.
> >> 2.14/org.apache.sling.commons.johnzon-1.2.14.jar = 11
> >>
> >> reference\:file\:org/apache/felix/org.apache.felix.configadmin.plugin
> >> .interpolation/1.2.4/org.apache.felix.configadmin.plugin.interpolatio
> >> n-1.2.4.jar = 11
> >>
> >> reference\:file\:org/apache/felix/org.apache.felix.cm.json/1.0.6/org.
> >> apache.felix.cm.json-1.0.6.jar = 11
> >>
> >> reference\:file\:org/apache/felix/org.apache.felix.fileinstall/3.7.4/
> >> org.apache.felix.fileinstall-3.7.4.jar = 12
> >>
> >> reference\:file\:org/apache/karaf/features/org.apache.karaf.features.
> >> core/4.4.1/org.apache.karaf.features.core-4.4.1.jar = 15
> >>
> >>
> >>
> >> When I tried to replace the <startupFeatures> with <bootFeatures> Karaf failed to start (the log file is completely empty).
> >>
> >> I would really appreciate if you could point me to a good documentation on startupFeatures and bootFeatures.
> >>
> >>
> >>
> >> Best regards
> >>
> >> Martin Zukal
> >>
> >>
> >>
> >> From: Grzegorz Grzybek <gr...@gmail.com>
> >> Sent: Thursday, November 3, 2022 11:04 AM
> >> To: user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> >> Subject: Re: webconsole and pax-web-http-tomcat
> >>
> >>
> >>
> >> Hi
> >>
> >>
> >>
> >> about "pax-web-http-jetty", just get rid of "<startupFeature>http</startupFeature>" because it's quite legacy/convenient feature defined like this:
> >>
> >>
> >>
> >>     <feature name="http" description="Transition feature for backward compatibility" version="8.0.6">
> >>         <feature>pax-web-http</feature>
> >>     </feature>
> >>
> >>
> >>
> >> and "pax-web-http" (notice that the feature name doesn't specify the runtime to choose: jetty, tomcat or undertow) is:
> >>
> >>
> >>
> >>     <feature name="pax-web-http" description="Pax Web OSGi HTTP Service" version="8.0.6">
> >>         <feature>pax-web-http-jetty</feature>
> >>         <bundle start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
> >>         <capability>http-service;provider:=pax-http</capability>
> >>         <conditional>
> >>             <condition>webconsole</condition>
> >>             <bundle start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
> >>         </conditional>
> >>     </feature>
> >>
> >>
> >>
> >> So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or "pax-web-http-undertow") specified explicitly.
> >>
> >>
> >>
> >> Webconsole is listed in the bootFeatures (see above). […]
> >>
> >>
> >>
> >> Actually, it's specified in <startupFeatures> :) that's big difference - you're effectively doing (karaf-maven-plugin is doing) the resolution at build time, so you simply get a big list of bundles inside etc/startup.properties. This makes uninstalling the features a bit harder.
> >>
> >> In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle vs feature. With "startup features" you're "flattening" the features into a list of bundles. It may speed things up, but generally I'm not recommending it.
> >>
> >>
> >>
> >> And finally, to see what's the problem, you can increase logging level of "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of information about ServletContainerInitializers and annotated classes being discovered.
> >>
> >>
> >>
> >> I still hope that removing pax-web-http-jetty (by not including "http" feature) will solve your problem.
> >>
> >>
> >>
> >> regards
> >>
> >> Grzegorz Grzybek
> >>
> >>
> >>
> >>
> >>
> >> czw., 3 lis 2022 o 10:36 Martin Zukal via user <us...@karaf.apache.org> napisał(a):
> >>
> >> Hello and thank you for a quick response!
> >>
> >> Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1 which comes with Pax Web 8.0.6.
> >>
> >> I looked at the samples and they already helped me a lot but I will
> >> look at them once again, maybe I missed something. Basically, I
> >> followed:
> >> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/sa
> >> mples-jsf/war-primefaces-wired/pom.xml
> >>
> >>
> >>
> >>
> >>
> >> You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.
> >>
> >>
> >>
> >> I have the following dependencies in my pom.xml (used to build custom
> >> Karaf distribution)
> >>
> >> <dependency>
> >>
> >>
> >> <groupId>org.apache.karaf.features</groupId>
> >>
> >>
> >> <artifactId>framework</artifactId>
> >>
> >>
> >> <version>${karaf.version}</version>
> >>
> >>                                                <type>kar</type>
> >>
> >>                                </dependency>
> >>
> >>                                <dependency>
> >>
> >>
> >> <groupId>org.apache.karaf.features</groupId>
> >>
> >>
> >> <artifactId>framework</artifactId>
> >>
> >>
> >> <version>${karaf.version}</version>
> >>
> >>
> >> <classifier>features</classifier>
> >>
> >>                                                <type>xml</type>
> >>
> >>                                                <scope>runtime</scope>
> >>
> >>                                </dependency>
> >>
> >>                                <dependency>
> >>
> >>
> >> <groupId>org.apache.karaf.features</groupId>
> >>
> >>
> >> <artifactId>standard</artifactId>
> >>
> >>
> >> <version>${karaf.version}</version>
> >>
> >>
> >> <classifier>features</classifier>
> >>
> >>                                                <type>xml</type>
> >>
> >>                                                <scope>runtime</scope>
> >>
> >>                                </dependency>
> >>
> >> And I listed the following features in startupFeatures:
> >>
> >> <startupFeatures>
> >>
> >>
> >> <startupFeature>framework-logback</startupFeature>
> >>
> >>
> >> <startupFeature>instance</startupFeature>
> >>
> >>
> >> <startupFeature>package</startupFeature>
> >>
> >>
> >> <startupFeature>log</startupFeature>
> >>
> >>
> >> <startupFeature>ssh</startupFeature>
> >>
> >>
> >> <startupFeature>system</startupFeature>
> >>
> >>
> >> <startupFeature>feature</startupFeature>
> >>
> >>
> >> <startupFeature>shell</startupFeature>
> >>
> >>
> >> <startupFeature>management</startupFeature>
> >>
> >>
> >> <startupFeature>service</startupFeature>
> >>
> >>
> >> <startupFeature>jaas</startupFeature>
> >>
> >>
> >> <startupFeature>deployer</startupFeature>
> >>
> >>
> >> <startupFeature>diagnostic</startupFeature>
> >>
> >>
> >> <startupFeature>wrap</startupFeature>
> >>
> >>
> >> <startupFeature>bundle</startupFeature>
> >>
> >>
> >> <startupFeature>config</startupFeature>
> >>
> >>
> >> <startupFeature>http</startupFeature>
> >>
> >>
> >> <startupFeature>webconsole</startupFeature>
> >>
> >>
> >> <startupFeature>pax-web-http-tomcat</startupFeature>
> >>
> >>
> >> </startupFeatures>
> >>
> >> This results in the above declared features listed in bootFeatures in etc/org.apache.karaf.features.cfg.
> >>
> >> When I start Karaf with this set up without my application the webconsole works fine and I can see the following on the features page:
> >>
> >> pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6              Installed
> >>
> >> pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6              Installed
> >>
> >> Therefore I asked whether it i possible to uninstall pax-web-http-jetty.
> >>
> >>
> >>
> >> 2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.
> >>
> >>
> >>
> >> Webconsole is listed in the bootFeatures (see above). My application consists of a lot of bundles but the one with the UI is a WAB (war packaging with manifest which includes: Web-ContextPath: /main). Primefaces and JSF are wired using the Require-Bundle header in manifest:
> >>
> >> <Require-Bundle>
> >>
> >> javax.faces-api,
> >>
> >> org.primefaces
> >>
> >> </Require-Bundle>
> >>
> >> All the bundles and their dependencies (JSF, primefaces etc.) are listed in a feature.xml file which I place in the deploy directory in Karaf. The application loads and works fine. I am just having problem with the webconsole.
> >>
> >> I unfortunately cannot share the code of the bundles. But I am happy to provide more information if necessary.
> >>
> >>
> >>
> >> Let me know if you need more information.
> >>
> >> Best regards
> >>
> >> Martin Zukal
> >>
> >>
> >>
> >>
> >>
> >> From: Grzegorz Grzybek <gr...@gmail.com>
> >> Sent: Thursday, November 3, 2022 9:56 AM
> >> To: user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> >> Subject: Re: webconsole and pax-web-http-tomcat
> >>
> >>
> >>
> >> Hello
> >>
> >>
> >>
> >> First - which Karaf version are you using?
> >>
> >> Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.
> >>
> >>
> >>
> >> Pax Web 8 is highly refactored major version of the project where we've tried to make sure that things like JSF (which rely heavily on ServletContainerInitializers) work smoothly.
> >>
> >> There are dedicated tests both for webconsole and for JSF (MyFaces, Primefaces) and even for techs like Vaadin.
> >>
> >>
> >>
> >> Check the JSF samples at
> >> https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/sa
> >> mples-jsf
> >>
> >>
> >>
> >> Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
> >>
> >>
> >>
> >> You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.
> >>
> >>
> >>
> >> 2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.
> >>
> >>
> >>
> >> kind regards
> >>
> >> Grzegorz Grzybek
> >>
> >>
> >>
> >> czw., 3 lis 2022 o 09:46 Martin Zukal via user <us...@karaf.apache.org> napisał(a):
> >>
> >> Hello everyone,
> >> I am experiencing strange behavior with webconsole of Apache Karaf. I have an application deployed using a custom feature file in Apache Karaf. The application is based on Spring and is using Primefaces (and Mojarra JSF implementation version 2.2.15). When I run it with standard war feature (which by default installs pax-web-http-jetty) I am getting the following error messages in the log file:
> >> Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI?
> >> Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?
> >> However, the webconsole works perfectly in this case.
> >> When I install the pax-web-http-tomcat feature the above mentioned error messages are gone but the webconsole is not working properly (the resources from res and lib are not loaded so I see allmost an empty page - see attachment).
> >> I can see the following errors in the log file:
> >>
> >> [2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10
> >> o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]
> >> Marking servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as
> >> unavailable
> >> [2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10 o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] javax.servlet.UnavailableException: No static resources were found
> >>         at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
> >>         at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
> >>         at javax.servlet.GenericServlet.init(GenericServlet.java:180)
> >>         at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
> >>         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
> >>         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
> >>         at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
> >>         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
> >>         at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
> >>         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
> >>         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
> >>         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
> >>         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
> >>         at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
> >>         at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
> >>         at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
> >>         at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
> >>         at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
> >>         at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
> >>         at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
> >>         at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
> >>         at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
> >>         at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
> >>         at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown Source)
> >>         at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
> >>         at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
> >>         at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> >>         at java.base/java.lang.Thread.run(Unknown Source)
> >>
> >>
> >> Does it mean that the webconsole works only with pax-web-http-jetty?
> >>
> >> I can also see that both pax-web-http-jetty and pax-web-http-tomcat features are installed. Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
> >> Any help with this issue will be appreciated.
> >>
> >> Best regards
> >> Martin Zukal
> >>
>
>
>
>
>

RE: startupFeatures vs. bootFeatures when building custom karaf distribution

Posted by Martin Zukal via user <us...@karaf.apache.org>.
Hi,
Thanks for pointing me to the right documentation.
So the best practice is to use:
bootFeatures with runtime scope dependencies (features)
or 
startupFeatures with compile scope dependencies (features)
is that right?
I currently use startupFeatures with runtime scope dependencies which is apparently wrong (but it produces the same result as if bootFeatures are used).
Regards
Martin Zukal


-----Original Message-----
From: Jean-Baptiste Onofré <jb...@nanthrax.net> 
Sent: Sunday, November 6, 2022 11:32 AM
To: user@karaf.apache.org
Cc: Martin Zukal <ma...@stabilit.ch>
Subject: Re: startupFeatures vs. bootFeatures when building custom karaf distribution

Hi,

As reminder, it's documented here:
https://karaf.apache.org/manual/latest/#_instances_and_distributions_goals

Especially you can see:

startupFeatures | List<String> | List of features from compile-scope features XML files and KARs to be installed into system repo and listed in etc/startup.properties.
bootFeatures | List<String> | List of features from runtime-scope features XML files and KARs to be installed into system repo and listed in featuresBoot property in etc/org.apache.karaf.features.cfg

Regards
JB

On Thu, Nov 3, 2022 at 12:47 PM Grzegorz Grzybek <gr...@gmail.com> wrote:
>
> Hello
>
>> When I tried to replace the <startupFeatures> with <bootFeatures> Karaf failed to start (the log file is completely empty).
>
>
> In previous email I didn't explain enough about the difference. What I said could be confusing, though it's true:
>
> compile scoped dependencies and/or features declared in 
> <startupFeatures> are effectively replaced by a list of bundles and 
> put into etc/startup.properties runtime scoped dependencies and/or 
> features declared in <bootFeatures> are declared in "featuresBoot" 
> property in etc/org.apache.karaf.features.cfg
>
> In both cases, you get your dependencies in "system/" directory of your custom distro.
>
> What I didn't mention is that you actually need _some_ features to be startupFeatures - most importantly the "feature" feature ;) The point is that in order to install features (from etc/org.apache.karaf.features.cfg) you need a bundle running that reads this file, so this bundle (org.apache.karaf.features.core) needs to be installed directly - from etc/startup.properties.
>
> Please have a look at the configuration of karaf-maven-plugin of the 
> Apache Karaf distro itself: 
> https://github.com/apache/karaf/blob/karaf-4.4.2/assemblies/apache-kar
> af/pom.xml While "feature" feature is not a startup feature, there's 
> compile-scoped dependency:
>
>         <dependency>
>             <groupId>org.apache.karaf.features</groupId>
>             <artifactId>framework</artifactId>
>             <type>kar</type>
>         </dependency>
>
> it (through a bit complex stages) installs a startup feature called "framework" which includes the org.apache.karaf.features.core bundle as startup bundle.
> You're using "framework-logback" variant of this feature and it has to be kept as startupFeature.
>
> regards
> Grzegorz Grzybek
>
> czw., 3 lis 2022 o 12:35 Martin Zukal via user <us...@karaf.apache.org> napisał(a):
>>
>> Hello,
>>
>> To be honest I am confused about the <startupFeatures> and 
>> <bootFeatures>. I followed the documentation here: 
>> https://svn.apache.org/repos/asf/karaf/site/production/manual/latest/
>> custom-distribution.html#_plugin_configuration but it did not work 
>> the way I expected. I am trying to build a custom Karaf distribution 
>> which should resolve all artifacts locally (not in the maven 
>> repository). The idea is to have all artifacts needed by Karaf itself 
>> in the <KARAF_HOME>/system directory and all artifacts required by my 
>> application in a new directory <KARAF_HOME>/repository. I firstly 
>> build the „bare“ karaf and then I add the repository directory (which 
>> is generated using karaf-maven-plugin but using the 
>> <goal>features-add-to-repository</goal> based on my feature.xml file 
>> )
>>
>> I created the following 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/xsd/maven-4.0.0.xsd>
>>
>>                 <modelVersion>4.0.0</modelVersion>
>>
>>
>>
>>
>>
>>                 <groupId>ch.stabilit</groupId>
>>
>>                 <artifactId>apache-karaf-STABILIT</artifactId>
>>
>>                 <version>4.4.1</version>
>>
>>                 <name>Apache Karaf distribution</name>
>>
>>                 <packaging>karaf-assembly</packaging>
>>
>>
>>
>>
>>
>>                 <properties>
>>
>>                                <karaf.version>4.4.1</karaf.version>
>>
>>                 </properties>
>>
>>
>>
>>                 <dependencies>
>>
>>                                <dependency>
>>
>>                                                
>> <groupId>org.apache.karaf.features</groupId>
>>
>>                                                
>> <artifactId>framework</artifactId>
>>
>>                                                
>> <version>${karaf.version}</version>
>>
>>                                                <type>kar</type>
>>
>>                                </dependency>
>>
>>                                <dependency>
>>
>>                                                
>> <groupId>org.apache.karaf.features</groupId>
>>
>>                                                
>> <artifactId>framework</artifactId>
>>
>>                                                
>> <version>${karaf.version}</version>
>>
>>                                                
>> <classifier>features</classifier>
>>
>>                                                <type>xml</type>
>>
>>                                                <scope>runtime</scope>
>>
>>                                </dependency>
>>
>>                                <dependency>
>>
>>                                                
>> <groupId>org.apache.karaf.features</groupId>
>>
>>                                                
>> <artifactId>standard</artifactId>
>>
>>                                                
>> <version>${karaf.version}</version>
>>
>>                                                
>> <classifier>features</classifier>
>>
>>                                                <type>xml</type>
>>
>>                                                <scope>runtime</scope>
>>
>>                                </dependency>
>>
>>                 </dependencies>
>>
>>
>>
>>                 <build>
>>
>>                                <plugins>
>>
>>                                                <plugin>
>>
>>                                                                
>> <groupId>org.apache.karaf.tooling</groupId>
>>
>>                                                                
>> <artifactId>karaf-maven-plugin</artifactId>
>>
>>                                                                
>> <version>${karaf.version}</version>
>>
>>                                                                
>> <extensions>true</extensions>
>>
>>                                                                
>> <executions>
>>
>>                                                                                
>> <execution>
>>
>>                                                                                               
>> <id>assembly</id>
>>
>>                                                                                               
>> <phase>prepare-package</phase>
>>
>>                                                                                               
>> <goals>
>>
>>                                                                                                               
>> <goal>assembly</goal>
>>
>>                                                                                               
>> </goals>
>>
>>                                                                                
>> </execution>
>>
>>                                                                
>> </executions>
>>
>>                                                                
>> <configuration>
>>
>>                                                                                
>> <bootRepositories>
>>
>>                                                                                                
>> <bootRepository>mvn:org.apache.karaf.features/spring/${karaf.version}
>> /xml/features</bootRepository>
>>
>>                                                                                                
>> <bootRepository>mvn:org.apache.karaf.features/specs/${karaf.version}/
>> xml/features</bootRepository>
>>
>>                                                                                                
>> <bootRepository>mvn:org.apache.karaf.features/enterprise/${karaf.vers
>> ion}/xml/features</bootRepository>
>>
>>                                                                                
>> </bootRepositories>
>>
>>                                                                                
>> <startupFeatures>
>>
>>                                                                                               
>> <startupFeature>framework-logback</startupFeature>
>>
>>                                                                                               
>> <startupFeature>instance</startupFeature>
>>
>>                                                                                               
>> <startupFeature>package</startupFeature>
>>
>>                                                                                               
>> <startupFeature>log</startupFeature>
>>
>>                                                                                               
>> <startupFeature>ssh</startupFeature>
>>
>>                                                                                               
>> <startupFeature>system</startupFeature>
>>
>>                                                                                               
>> <startupFeature>feature</startupFeature>
>>
>>                                                                                               
>> <startupFeature>shell</startupFeature>
>>
>>                                                                                               
>> <startupFeature>management</startupFeature>
>>
>>                                                                                               
>> <startupFeature>service</startupFeature>
>>
>>                                                                                               
>> <startupFeature>jaas</startupFeature>
>>
>>                                                                                               
>> <startupFeature>deployer</startupFeature>
>>
>>                                                                                               
>> <startupFeature>diagnostic</startupFeature>
>>
>>                                                                                               
>> <startupFeature>wrap</startupFeature>
>>
>>                                                                                               
>> <startupFeature>bundle</startupFeature>
>>
>>                                                                                               
>> <startupFeature>config</startupFeature>
>>
>>                                                                                               
>> <startupFeature>webconsole</startupFeature>
>>
>>                                                                                               
>> <startupFeature>pax-web-http-tomcat</startupFeature>
>>
>>                                                                                
>> </startupFeatures>
>>
>>                                                                                
>> <useReferenceUrls>true</useReferenceUrls>
>>
>>                                                                                
>> <installAllFeaturesByDefault>false</installAllFeaturesByDefault>
>>
>>                                                                                
>> <framework>framework-logback</framework>
>>
>>                                                                                
>> <archiveTarGz>false</archiveTarGz>
>>
>>                                                                                
>> <propertyEdits>
>>
>>                                                                                               
>> <edits>
>>
>>                                                                                                               
>> <edit>
>>
>>                                                                                                                               
>> <file>config.properties</file>
>>
>>                                                                                                                               
>> <operation>
>>
>>                                                                                                                                               
>> <operation>put</operation>
>>
>>                                                                                                                               
>> </operation>
>>
>>                                                                                                                               
>> <key>karaf.framework</key>
>>
>>                                                                                                                               
>> <value>equinox</value>
>>
>>                                                                                                               
>> </edit>
>>
>>                                                                                                               
>> <edit>
>>
>>                                                                                                                               
>> <file>config.properties</file>
>>
>>                                                                                                                               
>> <operation>
>>
>>                                                                                                                                               
>> <operation>extend</operation>
>>
>>                                                                                                                               
>> </operation>
>>
>>                                                                                                                               
>> <key>org.osgi.framework.system.packages</key>
>>
>>                                                                                                                               
>> <value>com.sun.jndi.ldap</value>
>>
>>                                                                                                               
>> </edit>
>>
>>                                                                                                               
>> <edit>
>>
>>                                                                                                                               
>> <file>config.properties</file>
>>
>>                                                                                                                               
>> <operation>
>>
>>                                                                                                                                               
>> <operation>extend</operation>
>>
>>                                                                                                                               
>> </operation>
>>
>>                                                                                                                               
>> <key>org.osgi.framework.system.packages</key>
>>
>>                                                                                                                               
>> <value>com.sun.jndi.url.ldap</value>
>>
>>                                                                                                               
>> </edit>
>>
>>                                                                                                               
>> <edit>
>>
>>                                                                                                                               
>> <file>config.properties</file>
>>
>>                                                                                                                               
>> <operation>
>>
>>                                                                                                                                               
>> <operation>extend</operation>
>>
>>                                                                                                                               
>> </operation>
>>
>>                                                                                                                               
>> <key>org.osgi.framework.bootdelegation</key>
>>
>>                                                                                                                               
>> <value> com.sun.jndi.ldap.*</value>
>>
>>                                                                                                               
>> </edit>
>>
>>                                                                                                               
>> <edit>
>>
>>                                                                                                                               
>> <file>users.properties</file>
>>
>>                                                                                                                               
>> <operation>
>>
>>                                                                                                                                               
>> <operation>put</operation>
>>
>>                                                                                                                               
>> </operation>
>>
>>                                                                                                                               
>> <key>_g_:admingroup</key>
>>
>>                                                                                                                               
>> <value>group,admin,manager,viewer,systembundles,ssh</value>
>>
>>                                                                                                               
>> </edit>
>>
>>                                                                                                               
>> <edit>
>>
>>                                                                                                                               
>> <file>users.properties</file>
>>
>>                                                                                                                               
>> <operation>
>>
>>                                                                                                                                               
>> <operation>put</operation>
>>
>>                                                                                                                               
>> </operation>
>>
>>                                                                                                                               
>> <key>karaf</key>
>>
>>                                                                                                                               
>> <value>karaf,_g_:admingroup</value>
>>
>>                                                                                                               
>> </edit>
>>
>>                                                                                                               
>> <edit>
>>
>>                                                                                                                               
>> <file>org.ops4j.pax.logging.cfg</file>
>>
>>                                                                                                                               
>> <operation>
>>
>>                                                                                                                                               
>> <operation>put</operation>
>>
>>                                                                                                                               
>> </operation>
>>
>>                                                                                                                               
>> <key>org.ops4j.pax.logging.logback.config.file</key>
>>
>>                                                                                                                               
>> <value>${karaf.base}/configuration/serviceability.xml</value>
>>
>>                                                                                                               
>> </edit>
>>
>>                                                                                                               
>> <edit>
>>
>>                                                                                                                               
>> <file>system.properties</file>
>>
>>                                                                                                                               
>> <operation>
>>
>>                                                                                                                                               
>> <operation>put</operation>
>>
>>                                                                                                                               
>> </operation>
>>
>>                                                                                                                               
>> <key>karaf.clean.all</key>
>>
>>                                                                                                                               
>> <value>true</value>
>>
>>                                                                                                               
>> </edit>
>>
>>                                                                                                               
>> <edit>
>>
>>                                                                                                                               
>> <file>org.ops4j.pax.web.cfg</file>
>>
>>                                                                                                                               
>> <operation>
>>
>>                                                                                                                                               
>> <operation>put</operation>
>>
>>                                                                                                                               
>> </operation>
>>
>>                                                                                                                               
>> <key>org.osgi.service.http.port</key>
>>
>>                                                                                                                               
>> <value>8080</value>
>>
>>                                                                                                               
>> </edit>
>>
>>                                                                                                               
>> <edit>
>>
>>                                                                                                                               
>> <file>org.ops4j.pax.url.mvn.cfg</file>
>>
>>                                                                                                                               
>> <operation>
>>
>>                                                                                                                                               
>> <operation>put</operation>
>>
>>                                                                                                                               
>> </operation>
>>
>>                                                                                                                               
>> <key>org.ops4j.pax.url.mvn.localRepository</key>
>>
>>                                                                                                                               
>> <value>${karaf.base}/repository</value>
>>
>>                                                                                                               
>> </edit>
>>
>>                                                                                                               
>> <edit>
>>
>>                                                                                                                               
>> <file>org.ops4j.pax.url.mvn.cfg</file>
>>
>>                                                                                                                               
>> <operation>
>>
>>                                                                                                                                               
>> <operation>put</operation>
>>
>>                                                                                                                               
>> </operation>
>>
>>                                                                                                                               
>> <key>org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote</key>
>>
>>                                                                                                                               
>> <value>true</value>
>>
>>                                                                                                               
>> </edit>
>>
>>                                                                                                               
>> <edit>
>>
>>                                                                                                                               
>> <file>org.ops4j.pax.url.mvn.cfg</file>
>>
>>                                                                                                                               
>> <operation>
>>
>>                                                                                                                                               
>> <operation>put</operation>
>>
>>                                                                                                                               
>> </operation>
>>
>>                                                                                                                               
>> <key>org.ops4j.pax.url.mvn.repositories</key>
>>
>>                                                                                                                               
>> <value>${karaf.home.uri}repository@id=local.repository@snapshots</val
>> ue>
>>
>>                                                                                                               
>> </edit>
>>
>>                                                                                               
>> </edits>
>>
>>                                                                                
>> </propertyEdits>
>>
>>                                                                
>> </configuration>
>>
>>
>>
>>                                                </plugin>
>>
>>                                </plugins>
>>
>>                 </build>
>>
>> </project>
>>
>>
>>
>> With which I am able to build Karaf distribution which satisfies all my requirements.
>>
>>
>>
>> You wrote that using startupFeatures will create a large startup.properties file. This is something I don’t observe. My startup.properties looks like this:
>>
>> # Bundles to be started on startup, with startlevel
>>
>> reference\:file\:org/apache/karaf/features/org.apache.karaf.features.
>> extension/4.4.1/org.apache.karaf.features.extension-4.4.1.jar = 1
>>
>> reference\:file\:org/ops4j/pax/url/pax-url-aether/2.6.11/pax-url-aeth
>> er-2.6.11.jar = 5
>>
>> reference\:file\:org/ops4j/pax/logging/pax-logging-logback/2.1.3/pax-
>> logging-logback-2.1.3.jar = 8
>>
>> reference\:file\:org/ops4j/pax/logging/pax-logging-api/2.1.3/pax-logg
>> ing-api-2.1.3.jar = 8
>>
>> reference\:file\:org/osgi/org.osgi.util.function/1.2.0/org.osgi.util.
>> function-1.2.0.jar = 9
>>
>> reference\:file\:org/osgi/org.osgi.util.promise/1.2.0/org.osgi.util.p
>> romise-1.2.0.jar = 9
>>
>> reference\:file\:org/apache/felix/org.apache.felix.coordinator/1.0.2/
>> org.apache.felix.coordinator-1.0.2.jar = 9
>>
>> reference\:file\:org/apache/felix/org.apache.felix.converter/1.0.14/o
>> rg.apache.felix.converter-1.0.14.jar = 9
>>
>> reference\:file\:org/apache/felix/org.apache.felix.configadmin/1.9.24
>> /org.apache.felix.configadmin-1.9.24.jar = 10
>>
>> reference\:file\:org/apache/felix/org.apache.felix.configurator/1.0.1
>> 4/org.apache.felix.configurator-1.0.14.jar = 11
>>
>> reference\:file\:org/apache/sling/org.apache.sling.commons.johnzon/1.
>> 2.14/org.apache.sling.commons.johnzon-1.2.14.jar = 11
>>
>> reference\:file\:org/apache/felix/org.apache.felix.configadmin.plugin
>> .interpolation/1.2.4/org.apache.felix.configadmin.plugin.interpolatio
>> n-1.2.4.jar = 11
>>
>> reference\:file\:org/apache/felix/org.apache.felix.cm.json/1.0.6/org.
>> apache.felix.cm.json-1.0.6.jar = 11
>>
>> reference\:file\:org/apache/felix/org.apache.felix.fileinstall/3.7.4/
>> org.apache.felix.fileinstall-3.7.4.jar = 12
>>
>> reference\:file\:org/apache/karaf/features/org.apache.karaf.features.
>> core/4.4.1/org.apache.karaf.features.core-4.4.1.jar = 15
>>
>>
>>
>> When I tried to replace the <startupFeatures> with <bootFeatures> Karaf failed to start (the log file is completely empty).
>>
>> I would really appreciate if you could point me to a good documentation on startupFeatures and bootFeatures.
>>
>>
>>
>> Best regards
>>
>> Martin Zukal
>>
>>
>>
>> From: Grzegorz Grzybek <gr...@gmail.com>
>> Sent: Thursday, November 3, 2022 11:04 AM
>> To: user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
>> Subject: Re: webconsole and pax-web-http-tomcat
>>
>>
>>
>> Hi
>>
>>
>>
>> about "pax-web-http-jetty", just get rid of "<startupFeature>http</startupFeature>" because it's quite legacy/convenient feature defined like this:
>>
>>
>>
>>     <feature name="http" description="Transition feature for backward compatibility" version="8.0.6">
>>         <feature>pax-web-http</feature>
>>     </feature>
>>
>>
>>
>> and "pax-web-http" (notice that the feature name doesn't specify the runtime to choose: jetty, tomcat or undertow) is:
>>
>>
>>
>>     <feature name="pax-web-http" description="Pax Web OSGi HTTP Service" version="8.0.6">
>>         <feature>pax-web-http-jetty</feature>
>>         <bundle start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
>>         <capability>http-service;provider:=pax-http</capability>
>>         <conditional>
>>             <condition>webconsole</condition>
>>             <bundle start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
>>         </conditional>
>>     </feature>
>>
>>
>>
>> So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or "pax-web-http-undertow") specified explicitly.
>>
>>
>>
>> Webconsole is listed in the bootFeatures (see above). […]
>>
>>
>>
>> Actually, it's specified in <startupFeatures> :) that's big difference - you're effectively doing (karaf-maven-plugin is doing) the resolution at build time, so you simply get a big list of bundles inside etc/startup.properties. This makes uninstalling the features a bit harder.
>>
>> In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle vs feature. With "startup features" you're "flattening" the features into a list of bundles. It may speed things up, but generally I'm not recommending it.
>>
>>
>>
>> And finally, to see what's the problem, you can increase logging level of "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of information about ServletContainerInitializers and annotated classes being discovered.
>>
>>
>>
>> I still hope that removing pax-web-http-jetty (by not including "http" feature) will solve your problem.
>>
>>
>>
>> regards
>>
>> Grzegorz Grzybek
>>
>>
>>
>>
>>
>> czw., 3 lis 2022 o 10:36 Martin Zukal via user <us...@karaf.apache.org> napisał(a):
>>
>> Hello and thank you for a quick response!
>>
>> Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1 which comes with Pax Web 8.0.6.
>>
>> I looked at the samples and they already helped me a lot but I will 
>> look at them once again, maybe I missed something. Basically, I 
>> followed: 
>> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/sa
>> mples-jsf/war-primefaces-wired/pom.xml
>>
>>
>>
>>
>>
>> You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.
>>
>>
>>
>> I have the following dependencies in my pom.xml (used to build custom 
>> Karaf distribution)
>>
>> <dependency>
>>
>>                                                
>> <groupId>org.apache.karaf.features</groupId>
>>
>>                                                
>> <artifactId>framework</artifactId>
>>
>>                                                
>> <version>${karaf.version}</version>
>>
>>                                                <type>kar</type>
>>
>>                                </dependency>
>>
>>                                <dependency>
>>
>>                                                
>> <groupId>org.apache.karaf.features</groupId>
>>
>>                                                
>> <artifactId>framework</artifactId>
>>
>>                                                
>> <version>${karaf.version}</version>
>>
>>                                                
>> <classifier>features</classifier>
>>
>>                                                <type>xml</type>
>>
>>                                                <scope>runtime</scope>
>>
>>                                </dependency>
>>
>>                                <dependency>
>>
>>                                                
>> <groupId>org.apache.karaf.features</groupId>
>>
>>                                                
>> <artifactId>standard</artifactId>
>>
>>                                                
>> <version>${karaf.version}</version>
>>
>>                                                
>> <classifier>features</classifier>
>>
>>                                                <type>xml</type>
>>
>>                                                <scope>runtime</scope>
>>
>>                                </dependency>
>>
>> And I listed the following features in startupFeatures:
>>
>> <startupFeatures>
>>
>>                                                                                               
>> <startupFeature>framework-logback</startupFeature>
>>
>>                                                                                               
>> <startupFeature>instance</startupFeature>
>>
>>                                                                                               
>> <startupFeature>package</startupFeature>
>>
>>                                                                                               
>> <startupFeature>log</startupFeature>
>>
>>                                                                                               
>> <startupFeature>ssh</startupFeature>
>>
>>                                                                                               
>> <startupFeature>system</startupFeature>
>>
>>                                                                                               
>> <startupFeature>feature</startupFeature>
>>
>>                                                                                               
>> <startupFeature>shell</startupFeature>
>>
>>                                                                                               
>> <startupFeature>management</startupFeature>
>>
>>                                                                                               
>> <startupFeature>service</startupFeature>
>>
>>                                                                                               
>> <startupFeature>jaas</startupFeature>
>>
>>                                                                                               
>> <startupFeature>deployer</startupFeature>
>>
>>                                                                                               
>> <startupFeature>diagnostic</startupFeature>
>>
>>                                                                                               
>> <startupFeature>wrap</startupFeature>
>>
>>                                                                                               
>> <startupFeature>bundle</startupFeature>
>>
>>                                                                                               
>> <startupFeature>config</startupFeature>
>>
>>                                                                                               
>> <startupFeature>http</startupFeature>
>>
>>                                                                                               
>> <startupFeature>webconsole</startupFeature>
>>
>>                                                                                               
>> <startupFeature>pax-web-http-tomcat</startupFeature>
>>
>>                                                                                
>> </startupFeatures>
>>
>> This results in the above declared features listed in bootFeatures in etc/org.apache.karaf.features.cfg.
>>
>> When I start Karaf with this set up without my application the webconsole works fine and I can see the following on the features page:
>>
>> pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6              Installed
>>
>> pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6              Installed
>>
>> Therefore I asked whether it i possible to uninstall pax-web-http-jetty.
>>
>>
>>
>> 2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.
>>
>>
>>
>> Webconsole is listed in the bootFeatures (see above). My application consists of a lot of bundles but the one with the UI is a WAB (war packaging with manifest which includes: Web-ContextPath: /main). Primefaces and JSF are wired using the Require-Bundle header in manifest:
>>
>> <Require-Bundle>
>>
>> javax.faces-api,
>>
>> org.primefaces
>>
>> </Require-Bundle>
>>
>> All the bundles and their dependencies (JSF, primefaces etc.) are listed in a feature.xml file which I place in the deploy directory in Karaf. The application loads and works fine. I am just having problem with the webconsole.
>>
>> I unfortunately cannot share the code of the bundles. But I am happy to provide more information if necessary.
>>
>>
>>
>> Let me know if you need more information.
>>
>> Best regards
>>
>> Martin Zukal
>>
>>
>>
>>
>>
>> From: Grzegorz Grzybek <gr...@gmail.com>
>> Sent: Thursday, November 3, 2022 9:56 AM
>> To: user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
>> Subject: Re: webconsole and pax-web-http-tomcat
>>
>>
>>
>> Hello
>>
>>
>>
>> First - which Karaf version are you using?
>>
>> Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.
>>
>>
>>
>> Pax Web 8 is highly refactored major version of the project where we've tried to make sure that things like JSF (which rely heavily on ServletContainerInitializers) work smoothly.
>>
>> There are dedicated tests both for webconsole and for JSF (MyFaces, Primefaces) and even for techs like Vaadin.
>>
>>
>>
>> Check the JSF samples at 
>> https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/sa
>> mples-jsf
>>
>>
>>
>> Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
>>
>>
>>
>> You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.
>>
>>
>>
>> 2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.
>>
>>
>>
>> kind regards
>>
>> Grzegorz Grzybek
>>
>>
>>
>> czw., 3 lis 2022 o 09:46 Martin Zukal via user <us...@karaf.apache.org> napisał(a):
>>
>> Hello everyone,
>> I am experiencing strange behavior with webconsole of Apache Karaf. I have an application deployed using a custom feature file in Apache Karaf. The application is based on Spring and is using Primefaces (and Mojarra JSF implementation version 2.2.15). When I run it with standard war feature (which by default installs pax-web-http-jetty) I am getting the following error messages in the log file:
>> Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI?
>> Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?
>> However, the webconsole works perfectly in this case.
>> When I install the pax-web-http-tomcat feature the above mentioned error messages are gone but the webconsole is not working properly (the resources from res and lib are not loaded so I see allmost an empty page - see attachment).
>> I can see the following errors in the log file:
>>
>> [2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10 
>> o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  
>> Marking servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as 
>> unavailable
>> [2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10 o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] javax.servlet.UnavailableException: No static resources were found
>>         at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
>>         at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
>>         at javax.servlet.GenericServlet.init(GenericServlet.java:180)
>>         at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
>>         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
>>         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
>>         at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
>>         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>>         at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
>>         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
>>         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
>>         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>>         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
>>         at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
>>         at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>>         at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
>>         at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
>>         at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
>>         at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
>>         at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
>>         at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
>>         at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
>>         at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
>>         at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown Source)
>>         at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>>         at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>>         at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>>         at java.base/java.lang.Thread.run(Unknown Source)
>>
>>
>> Does it mean that the webconsole works only with pax-web-http-jetty?
>>
>> I can also see that both pax-web-http-jetty and pax-web-http-tomcat features are installed. Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
>> Any help with this issue will be appreciated.
>>
>> Best regards
>> Martin Zukal
>>






Re: startupFeatures vs. bootFeatures when building custom karaf distribution

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

As reminder, it's documented here:
https://karaf.apache.org/manual/latest/#_instances_and_distributions_goals

Especially you can see:

startupFeatures | List<String> | List of features from compile-scope
features XML files and KARs to be installed into system repo and
listed in etc/startup.properties.
bootFeatures | List<String> | List of features from runtime-scope
features XML files and KARs to be installed into system repo and
listed in featuresBoot property in etc/org.apache.karaf.features.cfg

Regards
JB

On Thu, Nov 3, 2022 at 12:47 PM Grzegorz Grzybek <gr...@gmail.com> wrote:
>
> Hello
>
>> When I tried to replace the <startupFeatures> with <bootFeatures> Karaf failed to start (the log file is completely empty).
>
>
> In previous email I didn't explain enough about the difference. What I said could be confusing, though it's true:
>
> compile scoped dependencies and/or features declared in <startupFeatures> are effectively replaced by a list of bundles and put into etc/startup.properties
> runtime scoped dependencies and/or features declared in <bootFeatures> are declared in "featuresBoot" property in etc/org.apache.karaf.features.cfg
>
> In both cases, you get your dependencies in "system/" directory of your custom distro.
>
> What I didn't mention is that you actually need _some_ features to be startupFeatures - most importantly the "feature" feature ;) The point is that in order to install features (from etc/org.apache.karaf.features.cfg) you need a bundle running that reads this file, so this bundle (org.apache.karaf.features.core) needs to be installed directly - from etc/startup.properties.
>
> Please have a look at the configuration of karaf-maven-plugin of the Apache Karaf distro itself: https://github.com/apache/karaf/blob/karaf-4.4.2/assemblies/apache-karaf/pom.xml
> While "feature" feature is not a startup feature, there's compile-scoped dependency:
>
>         <dependency>
>             <groupId>org.apache.karaf.features</groupId>
>             <artifactId>framework</artifactId>
>             <type>kar</type>
>         </dependency>
>
> it (through a bit complex stages) installs a startup feature called "framework" which includes the org.apache.karaf.features.core bundle as startup bundle.
> You're using "framework-logback" variant of this feature and it has to be kept as startupFeature.
>
> regards
> Grzegorz Grzybek
>
> czw., 3 lis 2022 o 12:35 Martin Zukal via user <us...@karaf.apache.org> napisał(a):
>>
>> Hello,
>>
>> To be honest I am confused about the <startupFeatures> and <bootFeatures>. I followed the documentation here: https://svn.apache.org/repos/asf/karaf/site/production/manual/latest/custom-distribution.html#_plugin_configuration but it did not work the way I expected. I am trying to build a custom Karaf distribution which should resolve all artifacts locally (not in the maven repository). The idea is to have all artifacts needed by Karaf itself in the <KARAF_HOME>/system directory and all artifacts required by my application in a new directory <KARAF_HOME>/repository. I firstly build the „bare“ karaf and then I add the repository directory (which is generated using karaf-maven-plugin but using the <goal>features-add-to-repository</goal> based on my feature.xml file )
>>
>> I created the following 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/xsd/maven-4.0.0.xsd>
>>
>>                 <modelVersion>4.0.0</modelVersion>
>>
>>
>>
>>
>>
>>                 <groupId>ch.stabilit</groupId>
>>
>>                 <artifactId>apache-karaf-STABILIT</artifactId>
>>
>>                 <version>4.4.1</version>
>>
>>                 <name>Apache Karaf distribution</name>
>>
>>                 <packaging>karaf-assembly</packaging>
>>
>>
>>
>>
>>
>>                 <properties>
>>
>>                                <karaf.version>4.4.1</karaf.version>
>>
>>                 </properties>
>>
>>
>>
>>                 <dependencies>
>>
>>                                <dependency>
>>
>>                                                <groupId>org.apache.karaf.features</groupId>
>>
>>                                                <artifactId>framework</artifactId>
>>
>>                                                <version>${karaf.version}</version>
>>
>>                                                <type>kar</type>
>>
>>                                </dependency>
>>
>>                                <dependency>
>>
>>                                                <groupId>org.apache.karaf.features</groupId>
>>
>>                                                <artifactId>framework</artifactId>
>>
>>                                                <version>${karaf.version}</version>
>>
>>                                                <classifier>features</classifier>
>>
>>                                                <type>xml</type>
>>
>>                                                <scope>runtime</scope>
>>
>>                                </dependency>
>>
>>                                <dependency>
>>
>>                                                <groupId>org.apache.karaf.features</groupId>
>>
>>                                                <artifactId>standard</artifactId>
>>
>>                                                <version>${karaf.version}</version>
>>
>>                                                <classifier>features</classifier>
>>
>>                                                <type>xml</type>
>>
>>                                                <scope>runtime</scope>
>>
>>                                </dependency>
>>
>>                 </dependencies>
>>
>>
>>
>>                 <build>
>>
>>                                <plugins>
>>
>>                                                <plugin>
>>
>>                                                                <groupId>org.apache.karaf.tooling</groupId>
>>
>>                                                                <artifactId>karaf-maven-plugin</artifactId>
>>
>>                                                                <version>${karaf.version}</version>
>>
>>                                                                <extensions>true</extensions>
>>
>>                                                                <executions>
>>
>>                                                                                <execution>
>>
>>                                                                                               <id>assembly</id>
>>
>>                                                                                               <phase>prepare-package</phase>
>>
>>                                                                                               <goals>
>>
>>                                                                                                               <goal>assembly</goal>
>>
>>                                                                                               </goals>
>>
>>                                                                                </execution>
>>
>>                                                                </executions>
>>
>>                                                                <configuration>
>>
>>                                                                                <bootRepositories>
>>
>>                                                                                                <bootRepository>mvn:org.apache.karaf.features/spring/${karaf.version}/xml/features</bootRepository>
>>
>>                                                                                                <bootRepository>mvn:org.apache.karaf.features/specs/${karaf.version}/xml/features</bootRepository>
>>
>>                                                                                                <bootRepository>mvn:org.apache.karaf.features/enterprise/${karaf.version}/xml/features</bootRepository>
>>
>>                                                                                </bootRepositories>
>>
>>                                                                                <startupFeatures>
>>
>>                                                                                               <startupFeature>framework-logback</startupFeature>
>>
>>                                                                                               <startupFeature>instance</startupFeature>
>>
>>                                                                                               <startupFeature>package</startupFeature>
>>
>>                                                                                               <startupFeature>log</startupFeature>
>>
>>                                                                                               <startupFeature>ssh</startupFeature>
>>
>>                                                                                               <startupFeature>system</startupFeature>
>>
>>                                                                                               <startupFeature>feature</startupFeature>
>>
>>                                                                                               <startupFeature>shell</startupFeature>
>>
>>                                                                                               <startupFeature>management</startupFeature>
>>
>>                                                                                               <startupFeature>service</startupFeature>
>>
>>                                                                                               <startupFeature>jaas</startupFeature>
>>
>>                                                                                               <startupFeature>deployer</startupFeature>
>>
>>                                                                                               <startupFeature>diagnostic</startupFeature>
>>
>>                                                                                               <startupFeature>wrap</startupFeature>
>>
>>                                                                                               <startupFeature>bundle</startupFeature>
>>
>>                                                                                               <startupFeature>config</startupFeature>
>>
>>                                                                                               <startupFeature>webconsole</startupFeature>
>>
>>                                                                                               <startupFeature>pax-web-http-tomcat</startupFeature>
>>
>>                                                                                </startupFeatures>
>>
>>                                                                                <useReferenceUrls>true</useReferenceUrls>
>>
>>                                                                                <installAllFeaturesByDefault>false</installAllFeaturesByDefault>
>>
>>                                                                                <framework>framework-logback</framework>
>>
>>                                                                                <archiveTarGz>false</archiveTarGz>
>>
>>                                                                                <propertyEdits>
>>
>>                                                                                               <edits>
>>
>>                                                                                                               <edit>
>>
>>                                                                                                                               <file>config.properties</file>
>>
>>                                                                                                                               <operation>
>>
>>                                                                                                                                               <operation>put</operation>
>>
>>                                                                                                                               </operation>
>>
>>                                                                                                                               <key>karaf.framework</key>
>>
>>                                                                                                                               <value>equinox</value>
>>
>>                                                                                                               </edit>
>>
>>                                                                                                               <edit>
>>
>>                                                                                                                               <file>config.properties</file>
>>
>>                                                                                                                               <operation>
>>
>>                                                                                                                                               <operation>extend</operation>
>>
>>                                                                                                                               </operation>
>>
>>                                                                                                                               <key>org.osgi.framework.system.packages</key>
>>
>>                                                                                                                               <value>com.sun.jndi.ldap</value>
>>
>>                                                                                                               </edit>
>>
>>                                                                                                               <edit>
>>
>>                                                                                                                               <file>config.properties</file>
>>
>>                                                                                                                               <operation>
>>
>>                                                                                                                                               <operation>extend</operation>
>>
>>                                                                                                                               </operation>
>>
>>                                                                                                                               <key>org.osgi.framework.system.packages</key>
>>
>>                                                                                                                               <value>com.sun.jndi.url.ldap</value>
>>
>>                                                                                                               </edit>
>>
>>                                                                                                               <edit>
>>
>>                                                                                                                               <file>config.properties</file>
>>
>>                                                                                                                               <operation>
>>
>>                                                                                                                                               <operation>extend</operation>
>>
>>                                                                                                                               </operation>
>>
>>                                                                                                                               <key>org.osgi.framework.bootdelegation</key>
>>
>>                                                                                                                               <value> com.sun.jndi.ldap.*</value>
>>
>>                                                                                                               </edit>
>>
>>                                                                                                               <edit>
>>
>>                                                                                                                               <file>users.properties</file>
>>
>>                                                                                                                               <operation>
>>
>>                                                                                                                                               <operation>put</operation>
>>
>>                                                                                                                               </operation>
>>
>>                                                                                                                               <key>_g_:admingroup</key>
>>
>>                                                                                                                               <value>group,admin,manager,viewer,systembundles,ssh</value>
>>
>>                                                                                                               </edit>
>>
>>                                                                                                               <edit>
>>
>>                                                                                                                               <file>users.properties</file>
>>
>>                                                                                                                               <operation>
>>
>>                                                                                                                                               <operation>put</operation>
>>
>>                                                                                                                               </operation>
>>
>>                                                                                                                               <key>karaf</key>
>>
>>                                                                                                                               <value>karaf,_g_:admingroup</value>
>>
>>                                                                                                               </edit>
>>
>>                                                                                                               <edit>
>>
>>                                                                                                                               <file>org.ops4j.pax.logging.cfg</file>
>>
>>                                                                                                                               <operation>
>>
>>                                                                                                                                               <operation>put</operation>
>>
>>                                                                                                                               </operation>
>>
>>                                                                                                                               <key>org.ops4j.pax.logging.logback.config.file</key>
>>
>>                                                                                                                               <value>${karaf.base}/configuration/serviceability.xml</value>
>>
>>                                                                                                               </edit>
>>
>>                                                                                                               <edit>
>>
>>                                                                                                                               <file>system.properties</file>
>>
>>                                                                                                                               <operation>
>>
>>                                                                                                                                               <operation>put</operation>
>>
>>                                                                                                                               </operation>
>>
>>                                                                                                                               <key>karaf.clean.all</key>
>>
>>                                                                                                                               <value>true</value>
>>
>>                                                                                                               </edit>
>>
>>                                                                                                               <edit>
>>
>>                                                                                                                               <file>org.ops4j.pax.web.cfg</file>
>>
>>                                                                                                                               <operation>
>>
>>                                                                                                                                               <operation>put</operation>
>>
>>                                                                                                                               </operation>
>>
>>                                                                                                                               <key>org.osgi.service.http.port</key>
>>
>>                                                                                                                               <value>8080</value>
>>
>>                                                                                                               </edit>
>>
>>                                                                                                               <edit>
>>
>>                                                                                                                               <file>org.ops4j.pax.url.mvn.cfg</file>
>>
>>                                                                                                                               <operation>
>>
>>                                                                                                                                               <operation>put</operation>
>>
>>                                                                                                                               </operation>
>>
>>                                                                                                                               <key>org.ops4j.pax.url.mvn.localRepository</key>
>>
>>                                                                                                                               <value>${karaf.base}/repository</value>
>>
>>                                                                                                               </edit>
>>
>>                                                                                                               <edit>
>>
>>                                                                                                                               <file>org.ops4j.pax.url.mvn.cfg</file>
>>
>>                                                                                                                               <operation>
>>
>>                                                                                                                                               <operation>put</operation>
>>
>>                                                                                                                               </operation>
>>
>>                                                                                                                               <key>org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote</key>
>>
>>                                                                                                                               <value>true</value>
>>
>>                                                                                                               </edit>
>>
>>                                                                                                               <edit>
>>
>>                                                                                                                               <file>org.ops4j.pax.url.mvn.cfg</file>
>>
>>                                                                                                                               <operation>
>>
>>                                                                                                                                               <operation>put</operation>
>>
>>                                                                                                                               </operation>
>>
>>                                                                                                                               <key>org.ops4j.pax.url.mvn.repositories</key>
>>
>>                                                                                                                               <value>${karaf.home.uri}repository@id=local.repository@snapshots</value>
>>
>>                                                                                                               </edit>
>>
>>                                                                                               </edits>
>>
>>                                                                                </propertyEdits>
>>
>>                                                                </configuration>
>>
>>
>>
>>                                                </plugin>
>>
>>                                </plugins>
>>
>>                 </build>
>>
>> </project>
>>
>>
>>
>> With which I am able to build Karaf distribution which satisfies all my requirements.
>>
>>
>>
>> You wrote that using startupFeatures will create a large startup.properties file. This is something I don’t observe. My startup.properties looks like this:
>>
>> # Bundles to be started on startup, with startlevel
>>
>> reference\:file\:org/apache/karaf/features/org.apache.karaf.features.extension/4.4.1/org.apache.karaf.features.extension-4.4.1.jar = 1
>>
>> reference\:file\:org/ops4j/pax/url/pax-url-aether/2.6.11/pax-url-aether-2.6.11.jar = 5
>>
>> reference\:file\:org/ops4j/pax/logging/pax-logging-logback/2.1.3/pax-logging-logback-2.1.3.jar = 8
>>
>> reference\:file\:org/ops4j/pax/logging/pax-logging-api/2.1.3/pax-logging-api-2.1.3.jar = 8
>>
>> reference\:file\:org/osgi/org.osgi.util.function/1.2.0/org.osgi.util.function-1.2.0.jar = 9
>>
>> reference\:file\:org/osgi/org.osgi.util.promise/1.2.0/org.osgi.util.promise-1.2.0.jar = 9
>>
>> reference\:file\:org/apache/felix/org.apache.felix.coordinator/1.0.2/org.apache.felix.coordinator-1.0.2.jar = 9
>>
>> reference\:file\:org/apache/felix/org.apache.felix.converter/1.0.14/org.apache.felix.converter-1.0.14.jar = 9
>>
>> reference\:file\:org/apache/felix/org.apache.felix.configadmin/1.9.24/org.apache.felix.configadmin-1.9.24.jar = 10
>>
>> reference\:file\:org/apache/felix/org.apache.felix.configurator/1.0.14/org.apache.felix.configurator-1.0.14.jar = 11
>>
>> reference\:file\:org/apache/sling/org.apache.sling.commons.johnzon/1.2.14/org.apache.sling.commons.johnzon-1.2.14.jar = 11
>>
>> reference\:file\:org/apache/felix/org.apache.felix.configadmin.plugin.interpolation/1.2.4/org.apache.felix.configadmin.plugin.interpolation-1.2.4.jar = 11
>>
>> reference\:file\:org/apache/felix/org.apache.felix.cm.json/1.0.6/org.apache.felix.cm.json-1.0.6.jar = 11
>>
>> reference\:file\:org/apache/felix/org.apache.felix.fileinstall/3.7.4/org.apache.felix.fileinstall-3.7.4.jar = 12
>>
>> reference\:file\:org/apache/karaf/features/org.apache.karaf.features.core/4.4.1/org.apache.karaf.features.core-4.4.1.jar = 15
>>
>>
>>
>> When I tried to replace the <startupFeatures> with <bootFeatures> Karaf failed to start (the log file is completely empty).
>>
>> I would really appreciate if you could point me to a good documentation on startupFeatures and bootFeatures.
>>
>>
>>
>> Best regards
>>
>> Martin Zukal
>>
>>
>>
>> From: Grzegorz Grzybek <gr...@gmail.com>
>> Sent: Thursday, November 3, 2022 11:04 AM
>> To: user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
>> Subject: Re: webconsole and pax-web-http-tomcat
>>
>>
>>
>> Hi
>>
>>
>>
>> about "pax-web-http-jetty", just get rid of "<startupFeature>http</startupFeature>" because it's quite legacy/convenient feature defined like this:
>>
>>
>>
>>     <feature name="http" description="Transition feature for backward compatibility" version="8.0.6">
>>         <feature>pax-web-http</feature>
>>     </feature>
>>
>>
>>
>> and "pax-web-http" (notice that the feature name doesn't specify the runtime to choose: jetty, tomcat or undertow) is:
>>
>>
>>
>>     <feature name="pax-web-http" description="Pax Web OSGi HTTP Service" version="8.0.6">
>>         <feature>pax-web-http-jetty</feature>
>>         <bundle start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
>>         <capability>http-service;provider:=pax-http</capability>
>>         <conditional>
>>             <condition>webconsole</condition>
>>             <bundle start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
>>         </conditional>
>>     </feature>
>>
>>
>>
>> So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or "pax-web-http-undertow") specified explicitly.
>>
>>
>>
>> Webconsole is listed in the bootFeatures (see above). […]
>>
>>
>>
>> Actually, it's specified in <startupFeatures> :) that's big difference - you're effectively doing (karaf-maven-plugin is doing) the resolution at build time, so you simply get a big list of bundles inside etc/startup.properties. This makes uninstalling the features a bit harder.
>>
>> In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle vs feature. With "startup features" you're "flattening" the features into a list of bundles. It may speed things up, but generally I'm not recommending it.
>>
>>
>>
>> And finally, to see what's the problem, you can increase logging level of "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of information about ServletContainerInitializers and annotated classes being discovered.
>>
>>
>>
>> I still hope that removing pax-web-http-jetty (by not including "http" feature) will solve your problem.
>>
>>
>>
>> regards
>>
>> Grzegorz Grzybek
>>
>>
>>
>>
>>
>> czw., 3 lis 2022 o 10:36 Martin Zukal via user <us...@karaf.apache.org> napisał(a):
>>
>> Hello and thank you for a quick response!
>>
>> Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1 which comes with Pax Web 8.0.6.
>>
>> I looked at the samples and they already helped me a lot but I will look at them once again, maybe I missed something. Basically, I followed: https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml
>>
>>
>>
>>
>>
>> You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.
>>
>>
>>
>> I have the following dependencies in my pom.xml (used to build custom Karaf distribution)
>>
>> <dependency>
>>
>>                                                <groupId>org.apache.karaf.features</groupId>
>>
>>                                                <artifactId>framework</artifactId>
>>
>>                                                <version>${karaf.version}</version>
>>
>>                                                <type>kar</type>
>>
>>                                </dependency>
>>
>>                                <dependency>
>>
>>                                                <groupId>org.apache.karaf.features</groupId>
>>
>>                                                <artifactId>framework</artifactId>
>>
>>                                                <version>${karaf.version}</version>
>>
>>                                                <classifier>features</classifier>
>>
>>                                                <type>xml</type>
>>
>>                                                <scope>runtime</scope>
>>
>>                                </dependency>
>>
>>                                <dependency>
>>
>>                                                <groupId>org.apache.karaf.features</groupId>
>>
>>                                                <artifactId>standard</artifactId>
>>
>>                                                <version>${karaf.version}</version>
>>
>>                                                <classifier>features</classifier>
>>
>>                                                <type>xml</type>
>>
>>                                                <scope>runtime</scope>
>>
>>                                </dependency>
>>
>> And I listed the following features in startupFeatures:
>>
>> <startupFeatures>
>>
>>                                                                                               <startupFeature>framework-logback</startupFeature>
>>
>>                                                                                               <startupFeature>instance</startupFeature>
>>
>>                                                                                               <startupFeature>package</startupFeature>
>>
>>                                                                                               <startupFeature>log</startupFeature>
>>
>>                                                                                               <startupFeature>ssh</startupFeature>
>>
>>                                                                                               <startupFeature>system</startupFeature>
>>
>>                                                                                               <startupFeature>feature</startupFeature>
>>
>>                                                                                               <startupFeature>shell</startupFeature>
>>
>>                                                                                               <startupFeature>management</startupFeature>
>>
>>                                                                                               <startupFeature>service</startupFeature>
>>
>>                                                                                               <startupFeature>jaas</startupFeature>
>>
>>                                                                                               <startupFeature>deployer</startupFeature>
>>
>>                                                                                               <startupFeature>diagnostic</startupFeature>
>>
>>                                                                                               <startupFeature>wrap</startupFeature>
>>
>>                                                                                               <startupFeature>bundle</startupFeature>
>>
>>                                                                                               <startupFeature>config</startupFeature>
>>
>>                                                                                               <startupFeature>http</startupFeature>
>>
>>                                                                                               <startupFeature>webconsole</startupFeature>
>>
>>                                                                                               <startupFeature>pax-web-http-tomcat</startupFeature>
>>
>>                                                                                </startupFeatures>
>>
>> This results in the above declared features listed in bootFeatures in etc/org.apache.karaf.features.cfg.
>>
>> When I start Karaf with this set up without my application the webconsole works fine and I can see the following on the features page:
>>
>> pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6              Installed
>>
>> pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6              Installed
>>
>> Therefore I asked whether it i possible to uninstall pax-web-http-jetty.
>>
>>
>>
>> 2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.
>>
>>
>>
>> Webconsole is listed in the bootFeatures (see above). My application consists of a lot of bundles but the one with the UI is a WAB (war packaging with manifest which includes: Web-ContextPath: /main). Primefaces and JSF are wired using the Require-Bundle header in manifest:
>>
>> <Require-Bundle>
>>
>> javax.faces-api,
>>
>> org.primefaces
>>
>> </Require-Bundle>
>>
>> All the bundles and their dependencies (JSF, primefaces etc.) are listed in a feature.xml file which I place in the deploy directory in Karaf. The application loads and works fine. I am just having problem with the webconsole.
>>
>> I unfortunately cannot share the code of the bundles. But I am happy to provide more information if necessary.
>>
>>
>>
>> Let me know if you need more information.
>>
>> Best regards
>>
>> Martin Zukal
>>
>>
>>
>>
>>
>> From: Grzegorz Grzybek <gr...@gmail.com>
>> Sent: Thursday, November 3, 2022 9:56 AM
>> To: user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
>> Subject: Re: webconsole and pax-web-http-tomcat
>>
>>
>>
>> Hello
>>
>>
>>
>> First - which Karaf version are you using?
>>
>> Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.
>>
>>
>>
>> Pax Web 8 is highly refactored major version of the project where we've tried to make sure that things like JSF (which rely heavily on ServletContainerInitializers) work smoothly.
>>
>> There are dedicated tests both for webconsole and for JSF (MyFaces, Primefaces) and even for techs like Vaadin.
>>
>>
>>
>> Check the JSF samples at https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf
>>
>>
>>
>> Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
>>
>>
>>
>> You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.
>>
>>
>>
>> 2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.
>>
>>
>>
>> kind regards
>>
>> Grzegorz Grzybek
>>
>>
>>
>> czw., 3 lis 2022 o 09:46 Martin Zukal via user <us...@karaf.apache.org> napisał(a):
>>
>> Hello everyone,
>> I am experiencing strange behavior with webconsole of Apache Karaf. I have an application deployed using a custom feature file in Apache Karaf. The application is based on Spring and is using Primefaces (and Mojarra JSF implementation version 2.2.15). When I run it with standard war feature (which by default installs pax-web-http-jetty) I am getting the following error messages in the log file:
>> Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI?
>> Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?
>> However, the webconsole works perfectly in this case.
>> When I install the pax-web-http-tomcat feature the above mentioned error messages are gone but the webconsole is not working properly (the resources from res and lib are not loaded so I see allmost an empty page - see attachment).
>> I can see the following errors in the log file:
>>
>> [2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10 o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable
>> [2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10 o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] javax.servlet.UnavailableException: No static resources were found
>>         at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
>>         at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
>>         at javax.servlet.GenericServlet.init(GenericServlet.java:180)
>>         at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
>>         at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
>>         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
>>         at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
>>         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>>         at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
>>         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
>>         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
>>         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>>         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
>>         at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
>>         at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>>         at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
>>         at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
>>         at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
>>         at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
>>         at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
>>         at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
>>         at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
>>         at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
>>         at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown Source)
>>         at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>>         at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>>         at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>>         at java.base/java.lang.Thread.run(Unknown Source)
>>
>>
>> Does it mean that the webconsole works only with pax-web-http-jetty?
>>
>> I can also see that both pax-web-http-jetty and pax-web-http-tomcat features are installed. Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
>> Any help with this issue will be appreciated.
>>
>> Best regards
>> Martin Zukal
>>


Re: startupFeatures vs. bootFeatures when building custom karaf distribution

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Hello

When I tried to replace the <startupFeatures> with <bootFeatures> Karaf
> failed to start (the log file is completely empty).
>

In previous email I didn't explain enough about the difference. What I said
could be confusing, though it's true:

   - compile scoped dependencies and/or features declared in
   <startupFeatures> are effectively replaced by a list of bundles and put
   into etc/startup.properties
   - runtime scoped dependencies and/or features declared in <bootFeatures>
   are declared in "featuresBoot" property in etc/org.apache.karaf.features.cfg

In both cases, you get your dependencies in "system/" directory of your
custom distro.

What I didn't mention is that you actually need _some_ features to be
startupFeatures - most importantly the "feature" feature ;) The point is
that in order to install features (from etc/org.apache.karaf.features.cfg)
you need a bundle running that reads this file, so this bundle
(org.apache.karaf.features.core) needs to be installed directly - from
etc/startup.properties.

Please have a look at the configuration of karaf-maven-plugin of the Apache
Karaf distro itself:
https://github.com/apache/karaf/blob/karaf-4.4.2/assemblies/apache-karaf/pom.xml
While "feature" feature is not a startup feature, there's compile-scoped
dependency:

        <dependency>
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>framework</artifactId>
            <type>kar</type>
        </dependency>

it (through a bit complex stages) installs a startup feature called
"framework" which includes the org.apache.karaf.features.core bundle as
startup bundle.
You're using "framework-logback" variant of this feature and *it has to be
kept as startupFeature*.

regards
Grzegorz Grzybek

czw., 3 lis 2022 o 12:35 Martin Zukal via user <us...@karaf.apache.org>
napisał(a):

> Hello,
>
> To be honest I am confused about the <startupFeatures> and <bootFeatures>.
> I followed the documentation here:
> https://svn.apache.org/repos/asf/karaf/site/production/manual/latest/custom-distribution.html#_plugin_configuration
> but it did not work the way I expected. I am trying to build a custom Karaf
> distribution which should resolve all artifacts locally (not in the maven
> repository). The idea is to have all artifacts needed by Karaf itself in
> the <KARAF_HOME>/system directory and all artifacts required by my
> application in a new directory <KARAF_HOME>/repository. I firstly build the
> „bare“ karaf and then I add the repository directory (which is generated
> using karaf-maven-plugin but using the
> <goal>features-add-to-repository</goal> based on my feature.xml file )
>
> I created the following 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/xsd/maven-4.0.0.xsd>
>
>                 <modelVersion>4.0.0</modelVersion>
>
>
>
>
>
>                 <groupId>ch.stabilit</groupId>
>
>                 <artifactId>apache-karaf-STABILIT</artifactId>
>
>                 <version>4.4.1</version>
>
>                 <name>Apache Karaf distribution</name>
>
>                 <packaging>karaf-assembly</packaging>
>
>
>
>
>
>                 <properties>
>
>                                <karaf.version>4.4.1</karaf.version>
>
>                 </properties>
>
>
>
>                 <dependencies>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>framework</artifactId>
>
>
> <version>${karaf.version}</version>
>
>                                                <type>kar</type>
>
>                                </dependency>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>framework</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <classifier>features</classifier>
>
>                                                <type>xml</type>
>
>                                                <scope>runtime</scope>
>
>                                </dependency>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>standard</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <classifier>features</classifier>
>
>                                                <type>xml</type>
>
>                                                <scope>runtime</scope>
>
>                                </dependency>
>
>                 </dependencies>
>
>
>
>                 <build>
>
>                                <plugins>
>
>                                                <plugin>
>
>
> <groupId>org.apache.karaf.tooling</groupId>
>
>
> <artifactId>karaf-maven-plugin</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <extensions>true</extensions>
>
>                                                                <executions>
>
>
> <execution>
>
>
> <id>assembly</id>
>
>
> <phase>prepare-package</phase>
>
>
> <goals>
>
>
> <goal>assembly</goal>
>
>
> </goals>
>
>
> </execution>
>
>
> </executions>
>
>
> <configuration>
>
>
> <bootRepositories>
>
>
>
> <bootRepository>mvn:org.apache.karaf.features/spring/${karaf.version}/xml/features</bootRepository>
>
>
>
> <bootRepository>mvn:org.apache.karaf.features/specs/${karaf.version}/xml/features</bootRepository>
>
>
>
>
> <bootRepository>mvn:org.apache.karaf.features/enterprise/${karaf.version}/xml/features</bootRepository>
>
>
> </bootRepositories>
>
>
> <startupFeatures>
>
>
> <startupFeature>framework-logback</startupFeature>
>
>
> <startupFeature>instance</startupFeature>
>
>
> <startupFeature>package</startupFeature>
>
>
> <startupFeature>log</startupFeature>
>
>
> <startupFeature>ssh</startupFeature>
>
>
> <startupFeature>system</startupFeature>
>
>
> <startupFeature>feature</startupFeature>
>
>
> <startupFeature>shell</startupFeature>
>
>
> <startupFeature>management</startupFeature>
>
>
> <startupFeature>service</startupFeature>
>
>
> <startupFeature>jaas</startupFeature>
>
>
> <startupFeature>deployer</startupFeature>
>
>
> <startupFeature>diagnostic</startupFeature>
>
>
> <startupFeature>wrap</startupFeature>
>
>
> <startupFeature>bundle</startupFeature>
>
>
> <startupFeature>config</startupFeature>
>
>
> <startupFeature>webconsole</startupFeature>
>
>
> <startupFeature>pax-web-http-tomcat</startupFeature>
>
>
> </startupFeatures>
>
>
> <useReferenceUrls>true</useReferenceUrls>
>
>
> <installAllFeaturesByDefault>false</installAllFeaturesByDefault>
>
>
> <framework>framework-logback</framework>
>
>
> <archiveTarGz>false</archiveTarGz>
>
>
> <propertyEdits>
>
>
> <edits>
>
>
> <edit>
>
>
> <file>config.properties</file>
>
>
> <operation>
>
>
> <operation>put</operation>
>
>
> </operation>
>
>
> <key>karaf.framework</key>
>
>
> <value>equinox</value>
>
>
> </edit>
>
>
> <edit>
>
>
> <file>config.properties</file>
>
>
> <operation>
>
>
> <operation>extend</operation>
>
>
> </operation>
>
>
> <key>org.osgi.framework.system.packages</key>
>
>
> <value>com.sun.jndi.ldap</value>
>
>
> </edit>
>
>
> <edit>
>
>
> <file>config.properties</file>
>
>
> <operation>
>
>
> <operation>extend</operation>
>
>
> </operation>
>
>
> <key>org.osgi.framework.system.packages</key>
>
>
> <value>com.sun.jndi.url.ldap</value>
>
>
> </edit>
>
>
> <edit>
>
>
> <file>config.properties</file>
>
>
> <operation>
>
>
> <operation>extend</operation>
>
>
> </operation>
>
>
> <key>org.osgi.framework.bootdelegation</key>
>
>
> <value> com.sun.jndi.ldap.*</value>
>
>
> </edit>
>
>
> <edit>
>
>
> <file>users.properties</file>
>
>
> <operation>
>
>
> <operation>put</operation>
>
>
> </operation>
>
>
> <key>_g_:admingroup</key>
>
>
>                 <value>group,admin,manager,viewer,systembundles,ssh</value>
>
>
> </edit>
>
>
> <edit>
>
>
> <file>users.properties</file>
>
>
> <operation>
>
>
> <operation>put</operation>
>
>
> </operation>
>
>
> <key>karaf</key>
>
>
> <value>karaf,_g_:admingroup</value>
>
>
> </edit>
>
>
> <edit>
>
>
> <file>org.ops4j.pax.logging.cfg</file>
>
>
> <operation>
>
>
> <operation>put</operation>
>
>
> </operation>
>
>
> <key>org.ops4j.pax.logging.logback.config.file</key>
>
>
>
> <value>${karaf.base}/configuration/serviceability.xml</value>
>
>
> </edit>
>
>
> <edit>
>
>
> <file>system.properties</file>
>
>
> <operation>
>
>
> <operation>put</operation>
>
>
> </operation>
>
>
> <key>karaf.clean.all</key>
>
>
>
> <value>true</value>
>
>
> </edit>
>
>
> <edit>
>
>
> <file>org.ops4j.pax.web.cfg</file>
>
>
> <operation>
>
>
> <operation>put</operation>
>
>
> </operation>
>
>
> <key>org.osgi.service.http.port</key>
>
>
> <value>8080</value>
>
>
> </edit>
>
>
> <edit>
>
>
> <file>org.ops4j.pax.url.mvn.cfg</file>
>
>
> <operation>
>
>
> <operation>put</operation>
>
>
> </operation>
>
>
> <key>org.ops4j.pax.url.mvn.localRepository</key>
>
>
> <value>${karaf.base}/repository</value>
>
>
> </edit>
>
>
> <edit>
>
>
> <file>org.ops4j.pax.url.mvn.cfg</file>
>
>
> <operation>
>
>
> <operation>put</operation>
>
>
> </operation>
>
>
>                 <key>org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote</key>
>
>
> <value>true</value>
>
>
> </edit>
>
>
> <edit>
>
>
> <file>org.ops4j.pax.url.mvn.cfg</file>
>
>
> <operation>
>
>
> <operation>put</operation>
>
>
> </operation>
>
>
>                 <key>org.ops4j.pax.url.mvn.repositories</key>
>
>
>                 <value>
> ${karaf.home.uri}repository@id=local.repository@snapshots</value>
>
>
> </edit>
>
>
> </edits>
>
>
> </propertyEdits>
>
>
> </configuration>
>
>
>
>                                                </plugin>
>
>                                </plugins>
>
>                 </build>
>
> </project>
>
>
>
> With which I am able to build Karaf distribution which satisfies all my
> requirements.
>
>
>
> You wrote that using startupFeatures will create a large
> startup.properties file. This is something I don’t observe. My
> startup.properties looks like this:
>
> # Bundles to be started on startup, with startlevel
>
> reference\:file\:org/apache/karaf/features/org.apache.karaf.features.extension/4.4.1/org.apache.karaf.features.extension-4.4.1.jar
> = 1
>
> reference\:file\:org/ops4j/pax/url/pax-url-aether/2.6.11/pax-url-aether-2.6.11.jar
> = 5
>
> reference\:file\:org/ops4j/pax/logging/pax-logging-logback/2.1.3/pax-logging-logback-2.1.3.jar
> = 8
>
> reference\:file\:org/ops4j/pax/logging/pax-logging-api/2.1.3/pax-logging-api-2.1.3.jar
> = 8
>
> reference\:file\:org/osgi/org.osgi.util.function/1.2.0/org.osgi.util.function-1.2.0.jar
> = 9
>
> reference\:file\:org/osgi/org.osgi.util.promise/1.2.0/org.osgi.util.promise-1.2.0.jar
> = 9
>
> reference\:file\:org/apache/felix/org.apache.felix.coordinator/1.0.2/org.apache.felix.coordinator-1.0.2.jar
> = 9
>
> reference\:file\:org/apache/felix/org.apache.felix.converter/1.0.14/org.apache.felix.converter-1.0.14.jar
> = 9
>
> reference\:file\:org/apache/felix/org.apache.felix.configadmin/1.9.24/org.apache.felix.configadmin-1.9.24.jar
> = 10
>
> reference\:file\:org/apache/felix/org.apache.felix.configurator/1.0.14/org.apache.felix.configurator-1.0.14.jar
> = 11
>
> reference\:file\:org/apache/sling/org.apache.sling.commons.johnzon/1.2.14/org.apache.sling.commons.johnzon-1.2.14.jar
> = 11
>
> reference\:file\:org/apache/felix/org.apache.felix.configadmin.plugin.interpolation/1.2.4/org.apache.felix.configadmin.plugin.interpolation-1.2.4.jar
> = 11
>
> reference\:file\:org/apache/felix/org.apache.felix.cm.json/1.0.6/org.apache.felix.cm.json-1.0.6.jar
> = 11
>
> reference\:file\:org/apache/felix/org.apache.felix.fileinstall/3.7.4/org.apache.felix.fileinstall-3.7.4.jar
> = 12
>
> reference\:file\:org/apache/karaf/features/org.apache.karaf.features.core/4.4.1/org.apache.karaf.features.core-4.4.1.jar
> = 15
>
>
>
> When I tried to replace the <startupFeatures> with <bootFeatures> Karaf
> failed to start (the log file is completely empty).
>
> I would really appreciate if you could point me to a good documentation on
> startupFeatures and bootFeatures.
>
>
>
> Best regards
>
> Martin Zukal
>
>
>
> *From:* Grzegorz Grzybek <gr...@gmail.com>
> *Sent:* Thursday, November 3, 2022 11:04 AM
> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> *Subject:* Re: webconsole and pax-web-http-tomcat
>
>
>
> Hi
>
>
>
> about "pax-web-http-jetty", just get rid of
> "<startupFeature>http</startupFeature>" because it's quite
> legacy/convenient feature defined like this:
>
>
>
>     <feature name="http" description="Transition feature for backward
> compatibility" version="8.0.6">
>         <feature>pax-web-http</feature>
>     </feature>
>
>
>
> and "pax-web-http" (notice that the feature name doesn't specify the
> runtime to choose: jetty, tomcat or undertow) is:
>
>
>
>     <feature name="pax-web-http" description="Pax Web OSGi HTTP Service"
> version="8.0.6">
>         <feature>pax-web-http-jetty</feature>
>         <bundle
> start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
>         <capability>http-service;provider:=pax-http</capability>
>         <conditional>
>             <condition>webconsole</condition>
>             <bundle
> start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
>         </conditional>
>     </feature>
>
>
>
> So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or
> "pax-web-http-undertow") specified explicitly.
>
>
>
> *Webconsole is listed in the bootFeatures (see above). […]*
>
>
>
> Actually, it's specified in <startupFeatures> :) that's big difference -
> you're effectively doing (karaf-maven-plugin is doing) the resolution at
> build time, so you simply get a big list of bundles inside
> etc/startup.properties. This makes uninstalling the features a bit harder.
>
> In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle
> vs feature. With "startup features" you're "flattening" the features into a
> list of bundles. It may speed things up, but generally I'm not recommending
> it.
>
>
>
> And finally, to see what's the problem, you can increase logging level of
> "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of
> information about ServletContainerInitializers and annotated classes being
> discovered.
>
>
>
> I still hope that removing pax-web-http-jetty (by not including "http"
> feature) will solve your problem.
>
>
>
> regards
>
> Grzegorz Grzybek
>
>
>
>
>
> czw., 3 lis 2022 o 10:36 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
> Hello and thank you for a quick response!
>
> Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1
> which comes with Pax Web 8.0.6.
>
> I looked at the samples and they already helped me a lot but I will look
> at them once again, maybe I missed something. Basically, I followed:
> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml
>
>
>
>
>
> *You actually don't uninstall features using karaf-maven-plugin - you
> declare features you want, and karaf-maven-plugin will put the features
> into boot features (etc/org.apache.karaf.features.cfg - when in runtime
> scope) or into startup bundles (etc/startup.properties - when in compile
> scope). So definitely you have to fix your <configuration> for
> karaf-maven-plugin.*
>
>
>
> I have the following dependencies in my pom.xml (used to build custom
> Karaf distribution)
>
> <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>framework</artifactId>
>
>
> <version>${karaf.version}</version>
>
>                                                <type>kar</type>
>
>                                </dependency>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>framework</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <classifier>features</classifier>
>
>                                                <type>xml</type>
>
>                                                <scope>runtime</scope>
>
>                                </dependency>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>standard</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <classifier>features</classifier>
>
>                                                <type>xml</type>
>
>                                                <scope>runtime</scope>
>
>                                </dependency>
>
> And I listed the following features in startupFeatures:
>
> <startupFeatures>
>
>
> <startupFeature>framework-logback</startupFeature>
>
>
> <startupFeature>instance</startupFeature>
>
>
> <startupFeature>package</startupFeature>
>
>
> <startupFeature>log</startupFeature>
>
>
> <startupFeature>ssh</startupFeature>
>
>
> <startupFeature>system</startupFeature>
>
>
> <startupFeature>feature</startupFeature>
>
>
> <startupFeature>shell</startupFeature>
>
>
> <startupFeature>management</startupFeature>
>
>
> <startupFeature>service</startupFeature>
>
>
> <startupFeature>jaas</startupFeature>
>
>
> <startupFeature>deployer</startupFeature>
>
>
> <startupFeature>diagnostic</startupFeature>
>
>
> <startupFeature>wrap</startupFeature>
>
>
> <startupFeature>bundle</startupFeature>
>
>
> <startupFeature>config</startupFeature>
>
>
> <startupFeature>http</startupFeature>
>
>
> <startupFeature>webconsole</startupFeature>
>
>
> <startupFeature>pax-web-http-tomcat</startupFeature>
>
>
> </startupFeatures>
>
> This results in the above declared features listed in bootFeatures in
> etc/org.apache.karaf.features.cfg.
>
> When I start Karaf with this set up without my application the webconsole
> works fine and I can see the following on the features page:
>
> pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6
> Installed
>
> pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6
> Installed
>
> Therefore I asked whether it i possible to uninstall pax-web-http-jetty.
>
>
>
> *2nd - how do you install the webconsole and/or your JSF bundle? Are then
> installed as WAR (WAB) files? May I see them? I don't claim that the
> problem is only at your side - maybe Pax Web didn't anticpate some setup
> and I'd be happy to help solving this problem.*
>
>
>
> Webconsole is listed in the bootFeatures (see above). My application
> consists of a lot of bundles but the one with the UI is a WAB (war
> packaging with manifest which includes: Web-ContextPath: /main). Primefaces
> and JSF are wired using the Require-Bundle header in manifest:
>
> <Require-Bundle>
>
> javax.faces-api,
>
> org.primefaces
>
> </Require-Bundle>
>
> All the bundles and their dependencies (JSF, primefaces etc.) are listed
> in a feature.xml file which I place in the deploy directory in Karaf. The
> application loads and works fine. I am just having problem with the
> webconsole.
>
> I unfortunately cannot share the code of the bundles. But I am happy to
> provide more information if necessary.
>
>
>
> Let me know if you need more information.
>
> Best regards
>
> Martin Zukal
>
>
>
>
>
> *From:* Grzegorz Grzybek <gr...@gmail.com>
> *Sent:* Thursday, November 3, 2022 9:56 AM
> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> *Subject:* Re: webconsole and pax-web-http-tomcat
>
>
>
> Hello
>
>
>
> First - which Karaf version are you using?
>
> Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.
>
>
>
> Pax Web 8 is highly refactored major version of the project where we've
> tried to make sure that things like JSF (which rely heavily on
> ServletContainerInitializers) work smoothly.
>
> There are dedicated tests both for webconsole and for JSF (MyFaces,
> Primefaces) and even for techs like Vaadin.
>
>
>
> Check the JSF samples at
> https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf
>
>
>
> *Is it possible that the behavior is caused by conflict between
> pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall
> pax-web-http-jetty using karaf-maven-plugin?*
>
>
>
> You actually don't uninstall features using karaf-maven-plugin - you
> declare features you want, and karaf-maven-plugin will put the features
> into boot features (etc/org.apache.karaf.features.cfg - when in runtime
> scope) or into startup bundles (etc/startup.properties - when in compile
> scope). So definitely you have to fix your <configuration> for
> karaf-maven-plugin.
>
>
>
> 2nd - how do you install the webconsole and/or your JSF bundle? Are then
> installed as WAR (WAB) files? May I see them? I don't claim that the
> problem is only at your side - maybe Pax Web didn't anticpate some setup
> and I'd be happy to help solving this problem.
>
>
>
> kind regards
>
> Grzegorz Grzybek
>
>
>
> czw., 3 lis 2022 o 09:46 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
> Hello everyone,
> I am experiencing strange behavior with webconsole of Apache Karaf. I have
> an application deployed using a custom feature file in Apache Karaf. The
> application is based on Spring and is using Primefaces (and Mojarra JSF
> implementation version 2.2.15). When I run it with standard war feature
> (which by default installs pax-web-http-jetty) I am getting the following
> error messages in the log file:
> Unable to obtain InjectionProvider from init time FacesContext. Does this
> container implement the Mojarra Injection SPI?
> Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f
> because no InjectionProvider can be found. Does this container implement
> the Mojarra Injection SPI?
> However, the webconsole works perfectly in this case.
> When I install the pax-web-http-tomcat feature the above mentioned error
> messages are gone but the webconsole is not working properly (the resources
> from res and lib are not loaded so I see allmost an empty page - see
> attachment).
> I can see the following errors in the log file:
>
> [2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10
> o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking
> servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable
> [2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10
> o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate
> exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469]
> javax.servlet.UnavailableException: No static resources were found
>         at
> org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
>         at
> org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
>         at javax.servlet.GenericServlet.init(GenericServlet.java:180)
>         at
> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
>         at
> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
>         at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>         at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
>         at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
>         at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>         at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
>         at org.apache.tomcat.util.net
> .SocketProcessorBase.run(SocketProcessorBase.java:49)
>         at org.apache.tomcat.util.net
> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
>         at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
>         at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
>         at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown
> Source)
>         at
> org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>         at
> org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>         at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>         at java.base/java.lang.Thread.run(Unknown Source)
>
>
> Does it mean that the webconsole works only with pax-web-http-jetty?
>
> I can also see that both pax-web-http-jetty and pax-web-http-tomcat
> features are installed. Is it possible that the behavior is caused by
> conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way
> how to uninstall pax-web-http-jetty using karaf-maven-plugin?
> Any help with this issue will be appreciated.
>
> Best regards
> Martin Zukal
>
>

RE: webconsole and pax-web-http-tomcat

Posted by Martin Zukal via user <us...@karaf.apache.org>.
Perfect!

I am happy I could help.

Best Regrads

Martin Zukal

 

From: Grzegorz Grzybek <gr...@gmail.com> 
Sent: Friday, November 4, 2022 12:47 PM
To: user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
Subject: Re: webconsole and pax-web-http-tomcat

 

Thanks for the reproducer +Martin Zukal <ma...@stabilit.ch>  !

 

I found that it is indeed a problem with pax-web-http-tomcat. Jetty and Undertow runtimes are fine.

 

I've created https://github.com/ops4j/org.ops4j.pax.web/issues/1784 to track this and I already have a fix.

 

I know that Undertow 2.2.21 is going to be released soon, so please give me few days to prepare new 8.0.x release of Pax Web.

 

kind regards

Grzegorz Grzybek

 

pt., 4 lis 2022 o 11:12 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hi,

Thanks for your hint to use mvn:io.hawt/hawtio-osgi/2.15.0/war web application for testing. It would be really cumbersome to get something meaningful from the log file when running with my application.

So I created a feature.xml file with the following content:

<?xml version="1.0" encoding="UTF-8"?>

 

<features name="application-40.0.1-SNAPSHOT"

                xmlns=http://karaf.apache.org/xmlns/features/v1.4.0

                xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance

                xsi:schemaLocation=http://karaf.apache.org/xmlns/features/v1.4.0>

 

                <feature name="application" install="auto" version="40.0.1-SNAPSHOT">

                               <feature prerequisite="true">jpa</feature>

                               <feature prerequisite="true">hibernate</feature>

                               <feature prerequisite="true">spring</feature>

                               <feature prerequisite="true">spring-jdbc</feature>

                               <feature prerequisite="true">spring-orm</feature>

                               <feature prerequisite="true">spring-aspects</feature>

                               <feature prerequisite="true">spring-instrument</feature>

                               <feature prerequisite="true">spring-security</feature>

                               <feature prerequisite="true">spring-web</feature>

                               <feature prerequisite="true">spifly</feature>

                               <feature prerequisite="true">pax-web-war</feature>

                               <bundle>mvn:io.hawt/hawtio-osgi/2.15.0/war</bundle>

                </feature>

</features>

 

The feature.xml file is placed in the deploy directory. When I start Karaf it loads successfully but when I try to access /system/console page I get the already mentioned error in the log file.

To complete the information I have the following features listed in featuresBoot:

featuresBoot = \

    instance/4.4.1, \

    package/4.4.1, \

    log/4.4.1, \

    ssh/4.4.1, \

    pax-web-http-tomcat/8.0.6, \

    webconsole/4.4.1, \

    framework-logback/4.4.1, \

    system/4.4.1, \

    feature/4.4.1, \

    shell/4.4.1, \

    management/4.4.1, \

    service/4.4.1, \

    jaas/4.4.1, \

    deployer/4.4.1, \

    diagnostic/4.4.1, \

    wrap/2.6.11, \

    bundle/4.4.1, \

    config/4.4.1

 

I believe you should be able to reproduce it as well and possibly debug it if necessary.

My humbe guess would be that the problem might be caused by the spring-web feature.

Regards

Martin Zukal

 

From: Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > 
Sent: Thursday, November 3, 2022 3:41 PM
To: user@karaf.apache.org <ma...@karaf.apache.org> ; Martin Zukal <martin.zukal@stabilit.ch <ma...@stabilit.ch> >
Subject: Re: webconsole and pax-web-http-tomcat

 

Hi

 

OK, I checked the scenario (Karaf 4.4.1, Pax Web 8.0.6, pax-web-http-tomcat and mvn:io.hawt/hawtio-osgi/2.15.0/war web application).

 

The missing RESOURCES_ATTR attribute in your case is available in my case and is added with this code (in org.apache.catalina.core.StandardContext#startInternal()):

 

if (ok) {
    getServletContext().setAttribute
        (Globals.RESOURCES_ATTR, getResources());

 

so looks like "ok" is false ;) please increase logging for "org.ops4j.pax.web.extender.war" logger to see what may be wrong.

 

regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 14:47 Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > napisał(a):

Let me check this, because there's obvious check in Tomcat code:

 

// Load the web resources
resources = (WebResourceRoot) getServletContext().getAttribute(Globals.RESOURCES_ATTR);
if (resources == null) {
    throw new UnavailableException(sm.getString("defaultServlet.noResources"));
}

 

I'm sure I've added enough customization, but maybe something's wrong with Tomcat upgrade? Give me few hours (I have urgent tasks to do..)

 

regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 14:34 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hi,

Thanks a lot! I finally got rid off the jetty feature when using the pax-web-war.

Unfortunately, I still see the following errors in the log file:

[2022-11-03 14:21:03.337] INFO  ttp-nio2-0.0.0.0-8080-exec-4 o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking servlet [default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] as unavailable 

[2022-11-03 14:21:03.341] ERROR ttp-nio2-0.0.0.0-8080-exec-4 o.a.c.c.C.[.[.[/].[default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] Allocate exception for servlet [default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] javax.servlet.UnavailableException: No static resources were found

                at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)

                at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)

                at javax.servlet.GenericServlet.init(GenericServlet.java:180)

                at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)

                at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)

                at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)

                at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)

                at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)

                at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)

                at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)

                at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)

                at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

                at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)

                at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)

                at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)

                at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:127)

                at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:219)

                at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)

                at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)

                at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)

                at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

                at java.base/java.lang.Thread.run(Thread.java:829)

 

The weird thing is that when I run Karaf locally (where it is configured to resolve the dependencies from my local maven repository) the console works. I can see the bundles, services, features etc. However, the menu item http under Main is not displayed. 

When I run Karaf in test environment (based on docker) where it is configured to resolve the dependencies from system or repository directories I see the alsmost empty page which I sent in attachment in my first email.

The above mentioned errors are in the log file In both cases.´

Best regards

Martin Zukal

 

From: Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > 
Sent: Thursday, November 3, 2022 12:33 PM
To: user@karaf.apache.org <ma...@karaf.apache.org> ; Martin Zukal <martin.zukal@stabilit.ch <ma...@stabilit.ch> >
Subject: Re: webconsole and pax-web-http-tomcat

 

Ah - I forgot about "war"...

 

It's defined as:

 

    <feature name="war" description="Transition feature for backward compatibility" version="4.4.1">
        <feature>pax-web-http-war</feature>
    </feature>

 

which again leads to Jetty. You need "pax-web-war" feature, which doesn't enforce any particular runtime, so you have to use one explicitly - like pax-web-http-tomcat.

 

regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 12:28 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hi,

Again thanks for a quick response. I tried to remove the http feature from startupFeatures but then Karaf does not start and I can see the following error in the log file:

Error resolving artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6: [Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/), Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)]

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.configureIOException(AetherBasedResolver.java:803)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:774)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:657)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:598)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:565)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:555)

                at org.ops4j.pax.url.mvn.internal.Connection.getInputStream(Connection.java:123)

                at java.base/java.net.URL.openStream(Unknown Source)

                at org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:304)

                at org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:173)

                at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.installConfigs(BundleInstallSupportImpl.java:301)

                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.installConfigs(FeaturesServiceImpl.java:1185)

                at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:961)

                at org.apache.karaf.features.internal.service.Deployer.handlePrerequisites(Deployer.java:1121)

                at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:394)

                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069)

                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004)

                at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

                at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

                at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

                at java.base/java.lang.Thread.run(Unknown Source)

                Suppressed: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)

                               at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)

                               at shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)

                               at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)

                               at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)

                               ... 19 more

                Suppressed: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)

                               at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)

                               at shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)

                               at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)

                               at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)

                               ... 19 more

Caused by: shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Error resolving artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6

                at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:413)

                at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)

                at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)

                at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)

 

I guess that there is still some other feature which requires jetty. Looking at the standard features I believe it is the war feature. War feature is specified in my feature.xml file as follows: <feature prerequisite="true">war</feature>.

Is there a way how to deploy WAB file and use tomcat as the container?

 

Best Regards

Martin Zukal

 

P.S.: I am going to send another email regarding the startup and boot features.

 

 

 

 

From: Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > 
Sent: Thursday, November 3, 2022 11:04 AM
To: user@karaf.apache.org <ma...@karaf.apache.org> ; Martin Zukal <martin.zukal@stabilit.ch <ma...@stabilit.ch> >
Subject: Re: webconsole and pax-web-http-tomcat

 

Hi

 

about "pax-web-http-jetty", just get rid of "<startupFeature>http</startupFeature>" because it's quite legacy/convenient feature defined like this:

 

    <feature name="http" description="Transition feature for backward compatibility" version="8.0.6">
        <feature>pax-web-http</feature>
    </feature>

 

and "pax-web-http" (notice that the feature name doesn't specify the runtime to choose: jetty, tomcat or undertow) is:

 

    <feature name="pax-web-http" description="Pax Web OSGi HTTP Service" version="8.0.6">
        <feature>pax-web-http-jetty</feature>
        <bundle start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
        <capability>http-service;provider:=pax-http</capability>
        <conditional>
            <condition>webconsole</condition>
            <bundle start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
        </conditional>
    </feature>

 

So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or "pax-web-http-undertow") specified explicitly.

 

Webconsole is listed in the bootFeatures (see above). […]

 

Actually, it's specified in <startupFeatures> :) that's big difference - you're effectively doing (karaf-maven-plugin is doing) the resolution at build time, so you simply get a big list of bundles inside etc/startup.properties. This makes uninstalling the features a bit harder.

In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle vs feature. With "startup features" you're "flattening" the features into a list of bundles. It may speed things up, but generally I'm not recommending it.

 

And finally, to see what's the problem, you can increase logging level of "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of information about ServletContainerInitializers and annotated classes being discovered.

 

I still hope that removing pax-web-http-jetty (by not including "http" feature) will solve your problem.

 

regards

Grzegorz Grzybek

 

 

czw., 3 lis 2022 o 10:36 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hello and thank you for a quick response!

Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1 which comes with Pax Web 8.0.6.

I looked at the samples and they already helped me a lot but I will look at them once again, maybe I missed something. Basically, I followed: https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml

 

 

You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.

 

I have the following dependencies in my pom.xml (used to build custom Karaf distribution)

<dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <type>kar</type>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>standard</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

And I listed the following features in startupFeatures:

<startupFeatures>

                                                                                              <startupFeature>framework-logback</startupFeature>

                                                                                              <startupFeature>instance</startupFeature>

                                                                                              <startupFeature>package</startupFeature>

                                                                                              <startupFeature>log</startupFeature>

                                                                                              <startupFeature>ssh</startupFeature>

                                                                                              <startupFeature>system</startupFeature>

                                                                                              <startupFeature>feature</startupFeature>

                                                                                              <startupFeature>shell</startupFeature>

                                                                                              <startupFeature>management</startupFeature>

                                                                                              <startupFeature>service</startupFeature>

                                                                                              <startupFeature>jaas</startupFeature>

                                                                                              <startupFeature>deployer</startupFeature>

                                                                                              <startupFeature>diagnostic</startupFeature>

                                                                                              <startupFeature>wrap</startupFeature>

                                                                                              <startupFeature>bundle</startupFeature>

                                                                                              <startupFeature>config</startupFeature>

                                                                                              <startupFeature>http</startupFeature>

                                                                                              <startupFeature>webconsole</startupFeature>

                                                                                              <startupFeature>pax-web-http-tomcat</startupFeature>

                                                                               </startupFeatures>

This results in the above declared features listed in bootFeatures in etc/org.apache.karaf.features.cfg.

When I start Karaf with this set up without my application the webconsole works fine and I can see the following on the features page:

pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6              Installed

pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6              Installed

Therefore I asked whether it i possible to uninstall pax-web-http-jetty.

 

2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.

 

Webconsole is listed in the bootFeatures (see above). My application consists of a lot of bundles but the one with the UI is a WAB (war packaging with manifest which includes: Web-ContextPath: /main). Primefaces and JSF are wired using the Require-Bundle header in manifest:

<Require-Bundle>

javax.faces-api,

org.primefaces

</Require-Bundle>

All the bundles and their dependencies (JSF, primefaces etc.) are listed in a feature.xml file which I place in the deploy directory in Karaf. The application loads and works fine. I am just having problem with the webconsole.

I unfortunately cannot share the code of the bundles. But I am happy to provide more information if necessary.

 

Let me know if you need more information.

Best regards

Martin Zukal

 

 

From: Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > 
Sent: Thursday, November 3, 2022 9:56 AM
To: user@karaf.apache.org <ma...@karaf.apache.org> ; Martin Zukal <martin.zukal@stabilit.ch <ma...@stabilit.ch> >
Subject: Re: webconsole and pax-web-http-tomcat

 

Hello

 

First - which Karaf version are you using?

Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.

 

Pax Web 8 is highly refactored major version of the project where we've tried to make sure that things like JSF (which rely heavily on ServletContainerInitializers) work smoothly.

There are dedicated tests both for webconsole and for JSF (MyFaces, Primefaces) and even for techs like Vaadin.

 

Check the JSF samples at https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf

 

Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?

 

You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.

 

2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.

 

kind regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 09:46 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hello everyone,
I am experiencing strange behavior with webconsole of Apache Karaf. I have an application deployed using a custom feature file in Apache Karaf. The application is based on Spring and is using Primefaces (and Mojarra JSF implementation version 2.2.15). When I run it with standard war feature (which by default installs pax-web-http-jetty) I am getting the following error messages in the log file:
Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI? 
Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f <ma...@5005965f>  because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?
However, the webconsole works perfectly in this case.
When I install the pax-web-http-tomcat feature the above mentioned error messages are gone but the webconsole is not working properly (the resources from res and lib are not loaded so I see allmost an empty page - see attachment).
I can see the following errors in the log file:

[2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10 o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable 
[2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10 o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] javax.servlet.UnavailableException: No static resources were found
        at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
        at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
        at javax.servlet.GenericServlet.init(GenericServlet.java:180)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
        at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
        at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
        at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .SocketProcessorBase.run(SocketProcessorBase.java:49)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
        at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
        at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
        at java.base/sun.nio.ch <http://sun.nio.ch> .AsynchronousChannelGroupImpl$1.run(Unknown Source)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Unknown Source)


Does it mean that the webconsole works only with pax-web-http-jetty? 

I can also see that both pax-web-http-jetty and pax-web-http-tomcat features are installed. Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
Any help with this issue will be appreciated.

Best regards
Martin Zukal




Re: webconsole and pax-web-http-tomcat

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Thanks for the reproducer +Martin Zukal <ma...@stabilit.ch> !

I found that it is indeed a problem with pax-web-http-tomcat. Jetty and
Undertow runtimes are fine.

I've created https://github.com/ops4j/org.ops4j.pax.web/issues/1784 to
track this and I already have a fix.

I know that Undertow 2.2.21 is going to be released soon, so please give me
few days to prepare new 8.0.x release of Pax Web.

kind regards
Grzegorz Grzybek

pt., 4 lis 2022 o 11:12 Martin Zukal via user <us...@karaf.apache.org>
napisał(a):

> Hi,
>
> Thanks for your hint to use mvn:io.hawt/hawtio-osgi/2.15.0/war web
> application for testing. It would be really cumbersome to get something
> meaningful from the log file when running with my application.
>
> So I created a feature.xml file with the following content:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
>
>
> <features name="application-40.0.1-SNAPSHOT"
>
>                 xmlns=http://karaf.apache.org/xmlns/features/v1.4.0
>
>                 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
>
>                 xsi:schemaLocation=
> http://karaf.apache.org/xmlns/features/v1.4.0>
>
>
>
>                 <feature name="application" install="auto"
> version="40.0.1-SNAPSHOT">
>
>                                <feature prerequisite="true">jpa</feature>
>
>                                <feature
> prerequisite="true">hibernate</feature>
>
>                                <feature
> prerequisite="true">spring</feature>
>
>                                <feature
> prerequisite="true">spring-jdbc</feature>
>
>                                <feature
> prerequisite="true">spring-orm</feature>
>
>                                <feature
> prerequisite="true">spring-aspects</feature>
>
>                                <feature
> prerequisite="true">spring-instrument</feature>
>
>                                <feature
> prerequisite="true">spring-security</feature>
>
>                                <feature
> prerequisite="true">spring-web</feature>
>
>                                <feature
> prerequisite="true">spifly</feature>
>
>                                <feature
> prerequisite="true">pax-web-war</feature>
>
>
> <bundle>mvn:io.hawt/hawtio-osgi/2.15.0/war</bundle>
>
>                 </feature>
>
> </features>
>
>
>
> The feature.xml file is placed in the deploy directory. When I start Karaf
> it loads successfully but when I try to access /system/console page I get
> the already mentioned error in the log file.
>
> To complete the information I have the following features listed in
> featuresBoot:
>
> featuresBoot = \
>
>     instance/4.4.1, \
>
>     package/4.4.1, \
>
>     log/4.4.1, \
>
>     ssh/4.4.1, \
>
>     pax-web-http-tomcat/8.0.6, \
>
>     webconsole/4.4.1, \
>
>     framework-logback/4.4.1, \
>
>     system/4.4.1, \
>
>     feature/4.4.1, \
>
>     shell/4.4.1, \
>
>     management/4.4.1, \
>
>     service/4.4.1, \
>
>     jaas/4.4.1, \
>
>     deployer/4.4.1, \
>
>     diagnostic/4.4.1, \
>
>     wrap/2.6.11, \
>
>     bundle/4.4.1, \
>
>     config/4.4.1
>
>
>
> I believe you should be able to reproduce it as well and possibly debug it
> if necessary.
>
> My humbe guess would be that the problem might be caused by the spring-web
> feature.
>
> Regards
>
> Martin Zukal
>
>
>
> *From:* Grzegorz Grzybek <gr...@gmail.com>
> *Sent:* Thursday, November 3, 2022 3:41 PM
> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> *Subject:* Re: webconsole and pax-web-http-tomcat
>
>
>
> Hi
>
>
>
> OK, I checked the scenario (Karaf 4.4.1, Pax Web 8.0.6,
> pax-web-http-tomcat and mvn:io.hawt/hawtio-osgi/2.15.0/war web application).
>
>
>
> The missing RESOURCES_ATTR attribute in your case is available in my case
> and is added with this code (in
> org.apache.catalina.core.StandardContext#startInternal()):
>
>
>
> if (ok) {
>     getServletContext().setAttribute
>         (Globals.RESOURCES_ATTR, getResources());
>
>
>
> so looks like "ok" is false ;) please increase logging for
> "org.ops4j.pax.web.extender.war" logger to see what may be wrong.
>
>
>
> regards
>
> Grzegorz Grzybek
>
>
>
> czw., 3 lis 2022 o 14:47 Grzegorz Grzybek <gr...@gmail.com>
> napisał(a):
>
> Let me check this, because there's obvious check in Tomcat code:
>
>
>
> // Load the web resources
> resources = (WebResourceRoot)
> getServletContext().getAttribute(Globals.RESOURCES_ATTR);
> if (resources == null) {
>     throw new
> UnavailableException(sm.getString("defaultServlet.noResources"));
> }
>
>
>
> I'm sure I've added enough customization, but maybe something's wrong with
> Tomcat upgrade? Give me few hours (I have urgent tasks to do..)
>
>
>
> regards
>
> Grzegorz Grzybek
>
>
>
> czw., 3 lis 2022 o 14:34 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
> Hi,
>
> Thanks a lot! I finally got rid off the jetty feature when using the
> pax-web-war.
>
> Unfortunately, I still see the following errors in the log file:
>
> [2022-11-03 14:21:03.337] INFO  ttp-nio2-0.0.0.0-8080-exec-4
> o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking
> servlet [default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] as unavailable
>
> [2022-11-03 14:21:03.341] ERROR ttp-nio2-0.0.0.0-8080-exec-4
> o.a.c.c.C.[.[.[/].[default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] Allocate
> exception for servlet [default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9]
> javax.servlet.UnavailableException: No static resources were found
>
>                 at
> org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
>
>                 at
> org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
>
>                 at
> javax.servlet.GenericServlet.init(GenericServlet.java:180)
>
>                 at
> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
>
>                 at
> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
>
>                 at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
>
>                 at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
>
>                 at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>
>                 at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
>
>                 at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
>
>                 at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
>
>                 at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>
>                 at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
>
>                 at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
>
>                 at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>
>                 at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
>
>                 at
> org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
>
>                 at
> org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
>
>                 at
> org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
>
>                 at
> org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
>
>                 at
> org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
>
>                 at
> java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:127)
>
>                 at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:219)
>
>                 at
> java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
>
>                 at
> org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>
>                 at
> org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>
>                 at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>
>                 at java.base/java.lang.Thread.run(Thread.java:829)
>
>
>
> The weird thing is that when I run Karaf locally (where it is configured
> to resolve the dependencies from my local maven repository) the console
> works. I can see the bundles, services, features etc. However, the menu
> item http under Main is not displayed.
>
> When I run Karaf in test environment (based on docker) where it is
> configured to resolve the dependencies from system or repository
> directories I see the alsmost empty page which I sent in attachment in my
> first email.
>
> The above mentioned errors are in the log file In both cases.´
>
> Best regards
>
> Martin Zukal
>
>
>
> *From:* Grzegorz Grzybek <gr...@gmail.com>
> *Sent:* Thursday, November 3, 2022 12:33 PM
> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> *Subject:* Re: webconsole and pax-web-http-tomcat
>
>
>
> Ah - I forgot about "war"...
>
>
>
> It's defined as:
>
>
>
>     <feature name="war" description="Transition feature for backward
> compatibility" version="4.4.1">
>         <feature>pax-web-http-war</feature>
>     </feature>
>
>
>
> which again leads to Jetty. You need "pax-web-war" feature, which doesn't
> enforce any particular runtime, so you have to use one explicitly - like
> pax-web-http-tomcat.
>
>
>
> regards
>
> Grzegorz Grzybek
>
>
>
> czw., 3 lis 2022 o 12:28 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
> Hi,
>
> Again thanks for a quick response. I tried to remove the http feature from
> startupFeatures but then Karaf does not start and I can see the following
> error in the log file:
>
> Error resolving artifact
> org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6: [Could not find
> artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
> defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/), Could not
> find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
> local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)]
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.configureIOException(AetherBasedResolver.java:803)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:774)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:657)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:598)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:565)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:555)
>
>                 at
> org.ops4j.pax.url.mvn.internal.Connection.getInputStream(Connection.java:123)
>
>                 at java.base/java.net.URL.openStream(Unknown Source)
>
>                 at
> org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:304)
>
>                 at
> org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:173)
>
>                 at
> org.apache.karaf.features.internal.service.BundleInstallSupportImpl.installConfigs(BundleInstallSupportImpl.java:301)
>
>                 at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.installConfigs(FeaturesServiceImpl.java:1185)
>
>                 at
> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:961)
>
>                 at
> org.apache.karaf.features.internal.service.Deployer.handlePrerequisites(Deployer.java:1121)
>
>                 at
> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:394)
>
>                 at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069)
>
>                 at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004)
>
>                 at java.base/java.util.concurrent.FutureTask.run(Unknown
> Source)
>
>                 at
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>
>                 at
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>
>                 at java.base/java.lang.Thread.run(Unknown Source)
>
>                 Suppressed:
> shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not
> find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
> defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)
>
>                                at
> shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
>
>                                at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
>
>                                ... 19 more
>
>                 Suppressed:
> shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not
> find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
> local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)
>
>                                at
> shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
>
>                                at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
>
>                                ... 19 more
>
> Caused by:
> shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Error
> resolving artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6
>
>                 at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:413)
>
>                 at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
>
>                 at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
>
>                 at
> shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
>
>
>
> I guess that there is still some other feature which requires jetty.
> Looking at the standard features I believe it is the war feature. War
> feature is specified in my feature.xml file as follows: <feature
> prerequisite="true">war</feature>.
>
> Is there a way how to deploy WAB file and use tomcat as the container?
>
>
>
> Best Regards
>
> Martin Zukal
>
>
>
> P.S.: I am going to send another email regarding the startup and boot
> features.
>
>
>
>
>
>
>
>
>
> *From:* Grzegorz Grzybek <gr...@gmail.com>
> *Sent:* Thursday, November 3, 2022 11:04 AM
> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> *Subject:* Re: webconsole and pax-web-http-tomcat
>
>
>
> Hi
>
>
>
> about "pax-web-http-jetty", just get rid of
> "<startupFeature>http</startupFeature>" because it's quite
> legacy/convenient feature defined like this:
>
>
>
>     <feature name="http" description="Transition feature for backward
> compatibility" version="8.0.6">
>         <feature>pax-web-http</feature>
>     </feature>
>
>
>
> and "pax-web-http" (notice that the feature name doesn't specify the
> runtime to choose: jetty, tomcat or undertow) is:
>
>
>
>     <feature name="pax-web-http" description="Pax Web OSGi HTTP Service"
> version="8.0.6">
>         <feature>pax-web-http-jetty</feature>
>         <bundle
> start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
>         <capability>http-service;provider:=pax-http</capability>
>         <conditional>
>             <condition>webconsole</condition>
>             <bundle
> start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
>         </conditional>
>     </feature>
>
>
>
> So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or
> "pax-web-http-undertow") specified explicitly.
>
>
>
> *Webconsole is listed in the bootFeatures (see above). […]*
>
>
>
> Actually, it's specified in <startupFeatures> :) that's big difference -
> you're effectively doing (karaf-maven-plugin is doing) the resolution at
> build time, so you simply get a big list of bundles inside
> etc/startup.properties. This makes uninstalling the features a bit harder.
>
> In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle
> vs feature. With "startup features" you're "flattening" the features into a
> list of bundles. It may speed things up, but generally I'm not recommending
> it.
>
>
>
> And finally, to see what's the problem, you can increase logging level of
> "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of
> information about ServletContainerInitializers and annotated classes being
> discovered.
>
>
>
> I still hope that removing pax-web-http-jetty (by not including "http"
> feature) will solve your problem.
>
>
>
> regards
>
> Grzegorz Grzybek
>
>
>
>
>
> czw., 3 lis 2022 o 10:36 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
> Hello and thank you for a quick response!
>
> Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1
> which comes with Pax Web 8.0.6.
>
> I looked at the samples and they already helped me a lot but I will look
> at them once again, maybe I missed something. Basically, I followed:
> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml
>
>
>
>
>
> *You actually don't uninstall features using karaf-maven-plugin - you
> declare features you want, and karaf-maven-plugin will put the features
> into boot features (etc/org.apache.karaf.features.cfg - when in runtime
> scope) or into startup bundles (etc/startup.properties - when in compile
> scope). So definitely you have to fix your <configuration> for
> karaf-maven-plugin.*
>
>
>
> I have the following dependencies in my pom.xml (used to build custom
> Karaf distribution)
>
> <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>framework</artifactId>
>
>
> <version>${karaf.version}</version>
>
>                                                <type>kar</type>
>
>                                </dependency>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>framework</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <classifier>features</classifier>
>
>                                                <type>xml</type>
>
>                                                <scope>runtime</scope>
>
>                                </dependency>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>standard</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <classifier>features</classifier>
>
>                                                <type>xml</type>
>
>                                                <scope>runtime</scope>
>
>                                </dependency>
>
> And I listed the following features in startupFeatures:
>
> <startupFeatures>
>
>
> <startupFeature>framework-logback</startupFeature>
>
>
> <startupFeature>instance</startupFeature>
>
>
> <startupFeature>package</startupFeature>
>
>
> <startupFeature>log</startupFeature>
>
>
> <startupFeature>ssh</startupFeature>
>
>
> <startupFeature>system</startupFeature>
>
>
> <startupFeature>feature</startupFeature>
>
>
> <startupFeature>shell</startupFeature>
>
>
> <startupFeature>management</startupFeature>
>
>
> <startupFeature>service</startupFeature>
>
>
> <startupFeature>jaas</startupFeature>
>
>
> <startupFeature>deployer</startupFeature>
>
>
> <startupFeature>diagnostic</startupFeature>
>
>
> <startupFeature>wrap</startupFeature>
>
>
> <startupFeature>bundle</startupFeature>
>
>
> <startupFeature>config</startupFeature>
>
>
> <startupFeature>http</startupFeature>
>
>
> <startupFeature>webconsole</startupFeature>
>
>
> <startupFeature>pax-web-http-tomcat</startupFeature>
>
>
> </startupFeatures>
>
> This results in the above declared features listed in bootFeatures in
> etc/org.apache.karaf.features.cfg.
>
> When I start Karaf with this set up without my application the webconsole
> works fine and I can see the following on the features page:
>
> pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6
> Installed
>
> pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6
> Installed
>
> Therefore I asked whether it i possible to uninstall pax-web-http-jetty.
>
>
>
> *2nd - how do you install the webconsole and/or your JSF bundle? Are then
> installed as WAR (WAB) files? May I see them? I don't claim that the
> problem is only at your side - maybe Pax Web didn't anticpate some setup
> and I'd be happy to help solving this problem.*
>
>
>
> Webconsole is listed in the bootFeatures (see above). My application
> consists of a lot of bundles but the one with the UI is a WAB (war
> packaging with manifest which includes: Web-ContextPath: /main). Primefaces
> and JSF are wired using the Require-Bundle header in manifest:
>
> <Require-Bundle>
>
> javax.faces-api,
>
> org.primefaces
>
> </Require-Bundle>
>
> All the bundles and their dependencies (JSF, primefaces etc.) are listed
> in a feature.xml file which I place in the deploy directory in Karaf. The
> application loads and works fine. I am just having problem with the
> webconsole.
>
> I unfortunately cannot share the code of the bundles. But I am happy to
> provide more information if necessary.
>
>
>
> Let me know if you need more information.
>
> Best regards
>
> Martin Zukal
>
>
>
>
>
> *From:* Grzegorz Grzybek <gr...@gmail.com>
> *Sent:* Thursday, November 3, 2022 9:56 AM
> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> *Subject:* Re: webconsole and pax-web-http-tomcat
>
>
>
> Hello
>
>
>
> First - which Karaf version are you using?
>
> Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.
>
>
>
> Pax Web 8 is highly refactored major version of the project where we've
> tried to make sure that things like JSF (which rely heavily on
> ServletContainerInitializers) work smoothly.
>
> There are dedicated tests both for webconsole and for JSF (MyFaces,
> Primefaces) and even for techs like Vaadin.
>
>
>
> Check the JSF samples at
> https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf
>
>
>
> *Is it possible that the behavior is caused by conflict between
> pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall
> pax-web-http-jetty using karaf-maven-plugin?*
>
>
>
> You actually don't uninstall features using karaf-maven-plugin - you
> declare features you want, and karaf-maven-plugin will put the features
> into boot features (etc/org.apache.karaf.features.cfg - when in runtime
> scope) or into startup bundles (etc/startup.properties - when in compile
> scope). So definitely you have to fix your <configuration> for
> karaf-maven-plugin.
>
>
>
> 2nd - how do you install the webconsole and/or your JSF bundle? Are then
> installed as WAR (WAB) files? May I see them? I don't claim that the
> problem is only at your side - maybe Pax Web didn't anticpate some setup
> and I'd be happy to help solving this problem.
>
>
>
> kind regards
>
> Grzegorz Grzybek
>
>
>
> czw., 3 lis 2022 o 09:46 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
> Hello everyone,
> I am experiencing strange behavior with webconsole of Apache Karaf. I have
> an application deployed using a custom feature file in Apache Karaf. The
> application is based on Spring and is using Primefaces (and Mojarra JSF
> implementation version 2.2.15). When I run it with standard war feature
> (which by default installs pax-web-http-jetty) I am getting the following
> error messages in the log file:
> Unable to obtain InjectionProvider from init time FacesContext. Does this
> container implement the Mojarra Injection SPI?
> Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f
> because no InjectionProvider can be found. Does this container implement
> the Mojarra Injection SPI?
> However, the webconsole works perfectly in this case.
> When I install the pax-web-http-tomcat feature the above mentioned error
> messages are gone but the webconsole is not working properly (the resources
> from res and lib are not loaded so I see allmost an empty page - see
> attachment).
> I can see the following errors in the log file:
>
> [2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10
> o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking
> servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable
> [2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10
> o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate
> exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469]
> javax.servlet.UnavailableException: No static resources were found
>         at
> org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
>         at
> org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
>         at javax.servlet.GenericServlet.init(GenericServlet.java:180)
>         at
> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
>         at
> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
>         at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>         at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
>         at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
>         at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>         at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
>         at org.apache.tomcat.util.net
> .SocketProcessorBase.run(SocketProcessorBase.java:49)
>         at org.apache.tomcat.util.net
> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
>         at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
>         at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
>         at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown
> Source)
>         at
> org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>         at
> org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>         at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>         at java.base/java.lang.Thread.run(Unknown Source)
>
>
> Does it mean that the webconsole works only with pax-web-http-jetty?
>
> I can also see that both pax-web-http-jetty and pax-web-http-tomcat
> features are installed. Is it possible that the behavior is caused by
> conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way
> how to uninstall pax-web-http-jetty using karaf-maven-plugin?
> Any help with this issue will be appreciated.
>
> Best regards
> Martin Zukal
>
>

RE: webconsole and pax-web-http-tomcat

Posted by Martin Zukal via user <us...@karaf.apache.org>.
Hi,

Thanks for your hint to use mvn:io.hawt/hawtio-osgi/2.15.0/war web application for testing. It would be really cumbersome to get something meaningful from the log file when running with my application.

So I created a feature.xml file with the following content:

<?xml version="1.0" encoding="UTF-8"?>

 

<features name="application-40.0.1-SNAPSHOT"

                xmlns=http://karaf.apache.org/xmlns/features/v1.4.0

                xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance

                xsi:schemaLocation=http://karaf.apache.org/xmlns/features/v1.4.0>

 

                <feature name="application" install="auto" version="40.0.1-SNAPSHOT">

                               <feature prerequisite="true">jpa</feature>

                               <feature prerequisite="true">hibernate</feature>

                               <feature prerequisite="true">spring</feature>

                               <feature prerequisite="true">spring-jdbc</feature>

                               <feature prerequisite="true">spring-orm</feature>

                               <feature prerequisite="true">spring-aspects</feature>

                               <feature prerequisite="true">spring-instrument</feature>

                               <feature prerequisite="true">spring-security</feature>

                               <feature prerequisite="true">spring-web</feature>

                               <feature prerequisite="true">spifly</feature>

                               <feature prerequisite="true">pax-web-war</feature>

                               <bundle>mvn:io.hawt/hawtio-osgi/2.15.0/war</bundle>

                </feature>

</features>

 

The feature.xml file is placed in the deploy directory. When I start Karaf it loads successfully but when I try to access /system/console page I get the already mentioned error in the log file.

To complete the information I have the following features listed in featuresBoot:

featuresBoot = \

    instance/4.4.1, \

    package/4.4.1, \

    log/4.4.1, \

    ssh/4.4.1, \

    pax-web-http-tomcat/8.0.6, \

    webconsole/4.4.1, \

    framework-logback/4.4.1, \

    system/4.4.1, \

    feature/4.4.1, \

    shell/4.4.1, \

    management/4.4.1, \

    service/4.4.1, \

    jaas/4.4.1, \

    deployer/4.4.1, \

    diagnostic/4.4.1, \

    wrap/2.6.11, \

    bundle/4.4.1, \

    config/4.4.1

 

I believe you should be able to reproduce it as well and possibly debug it if necessary.

My humbe guess would be that the problem might be caused by the spring-web feature.

Regards

Martin Zukal

 

From: Grzegorz Grzybek <gr...@gmail.com> 
Sent: Thursday, November 3, 2022 3:41 PM
To: user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
Subject: Re: webconsole and pax-web-http-tomcat

 

Hi

 

OK, I checked the scenario (Karaf 4.4.1, Pax Web 8.0.6, pax-web-http-tomcat and mvn:io.hawt/hawtio-osgi/2.15.0/war web application).

 

The missing RESOURCES_ATTR attribute in your case is available in my case and is added with this code (in org.apache.catalina.core.StandardContext#startInternal()):

 

if (ok) {
    getServletContext().setAttribute
        (Globals.RESOURCES_ATTR, getResources());

 

so looks like "ok" is false ;) please increase logging for "org.ops4j.pax.web.extender.war" logger to see what may be wrong.

 

regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 14:47 Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > napisał(a):

Let me check this, because there's obvious check in Tomcat code:

 

// Load the web resources
resources = (WebResourceRoot) getServletContext().getAttribute(Globals.RESOURCES_ATTR);
if (resources == null) {
    throw new UnavailableException(sm.getString("defaultServlet.noResources"));
}

 

I'm sure I've added enough customization, but maybe something's wrong with Tomcat upgrade? Give me few hours (I have urgent tasks to do..)

 

regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 14:34 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hi,

Thanks a lot! I finally got rid off the jetty feature when using the pax-web-war.

Unfortunately, I still see the following errors in the log file:

[2022-11-03 14:21:03.337] INFO  ttp-nio2-0.0.0.0-8080-exec-4 o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking servlet [default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] as unavailable 

[2022-11-03 14:21:03.341] ERROR ttp-nio2-0.0.0.0-8080-exec-4 o.a.c.c.C.[.[.[/].[default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] Allocate exception for servlet [default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] javax.servlet.UnavailableException: No static resources were found

                at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)

                at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)

                at javax.servlet.GenericServlet.init(GenericServlet.java:180)

                at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)

                at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)

                at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)

                at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)

                at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)

                at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)

                at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)

                at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)

                at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

                at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)

                at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)

                at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)

                at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:127)

                at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:219)

                at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)

                at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)

                at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)

                at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

                at java.base/java.lang.Thread.run(Thread.java:829)

 

The weird thing is that when I run Karaf locally (where it is configured to resolve the dependencies from my local maven repository) the console works. I can see the bundles, services, features etc. However, the menu item http under Main is not displayed. 

When I run Karaf in test environment (based on docker) where it is configured to resolve the dependencies from system or repository directories I see the alsmost empty page which I sent in attachment in my first email.

The above mentioned errors are in the log file In both cases.´

Best regards

Martin Zukal

 

From: Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > 
Sent: Thursday, November 3, 2022 12:33 PM
To: user@karaf.apache.org <ma...@karaf.apache.org> ; Martin Zukal <martin.zukal@stabilit.ch <ma...@stabilit.ch> >
Subject: Re: webconsole and pax-web-http-tomcat

 

Ah - I forgot about "war"...

 

It's defined as:

 

    <feature name="war" description="Transition feature for backward compatibility" version="4.4.1">
        <feature>pax-web-http-war</feature>
    </feature>

 

which again leads to Jetty. You need "pax-web-war" feature, which doesn't enforce any particular runtime, so you have to use one explicitly - like pax-web-http-tomcat.

 

regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 12:28 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hi,

Again thanks for a quick response. I tried to remove the http feature from startupFeatures but then Karaf does not start and I can see the following error in the log file:

Error resolving artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6: [Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/), Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)]

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.configureIOException(AetherBasedResolver.java:803)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:774)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:657)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:598)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:565)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:555)

                at org.ops4j.pax.url.mvn.internal.Connection.getInputStream(Connection.java:123)

                at java.base/java.net.URL.openStream(Unknown Source)

                at org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:304)

                at org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:173)

                at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.installConfigs(BundleInstallSupportImpl.java:301)

                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.installConfigs(FeaturesServiceImpl.java:1185)

                at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:961)

                at org.apache.karaf.features.internal.service.Deployer.handlePrerequisites(Deployer.java:1121)

                at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:394)

                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069)

                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004)

                at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

                at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

                at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

                at java.base/java.lang.Thread.run(Unknown Source)

                Suppressed: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)

                               at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)

                               at shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)

                               at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)

                               at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)

                               ... 19 more

                Suppressed: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)

                               at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)

                               at shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)

                               at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)

                               at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)

                               ... 19 more

Caused by: shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Error resolving artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6

                at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:413)

                at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)

                at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)

                at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)

 

I guess that there is still some other feature which requires jetty. Looking at the standard features I believe it is the war feature. War feature is specified in my feature.xml file as follows: <feature prerequisite="true">war</feature>.

Is there a way how to deploy WAB file and use tomcat as the container?

 

Best Regards

Martin Zukal

 

P.S.: I am going to send another email regarding the startup and boot features.

 

 

 

 

From: Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > 
Sent: Thursday, November 3, 2022 11:04 AM
To: user@karaf.apache.org <ma...@karaf.apache.org> ; Martin Zukal <martin.zukal@stabilit.ch <ma...@stabilit.ch> >
Subject: Re: webconsole and pax-web-http-tomcat

 

Hi

 

about "pax-web-http-jetty", just get rid of "<startupFeature>http</startupFeature>" because it's quite legacy/convenient feature defined like this:

 

    <feature name="http" description="Transition feature for backward compatibility" version="8.0.6">
        <feature>pax-web-http</feature>
    </feature>

 

and "pax-web-http" (notice that the feature name doesn't specify the runtime to choose: jetty, tomcat or undertow) is:

 

    <feature name="pax-web-http" description="Pax Web OSGi HTTP Service" version="8.0.6">
        <feature>pax-web-http-jetty</feature>
        <bundle start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
        <capability>http-service;provider:=pax-http</capability>
        <conditional>
            <condition>webconsole</condition>
            <bundle start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
        </conditional>
    </feature>

 

So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or "pax-web-http-undertow") specified explicitly.

 

Webconsole is listed in the bootFeatures (see above). […]

 

Actually, it's specified in <startupFeatures> :) that's big difference - you're effectively doing (karaf-maven-plugin is doing) the resolution at build time, so you simply get a big list of bundles inside etc/startup.properties. This makes uninstalling the features a bit harder.

In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle vs feature. With "startup features" you're "flattening" the features into a list of bundles. It may speed things up, but generally I'm not recommending it.

 

And finally, to see what's the problem, you can increase logging level of "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of information about ServletContainerInitializers and annotated classes being discovered.

 

I still hope that removing pax-web-http-jetty (by not including "http" feature) will solve your problem.

 

regards

Grzegorz Grzybek

 

 

czw., 3 lis 2022 o 10:36 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hello and thank you for a quick response!

Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1 which comes with Pax Web 8.0.6.

I looked at the samples and they already helped me a lot but I will look at them once again, maybe I missed something. Basically, I followed: https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml

 

 

You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.

 

I have the following dependencies in my pom.xml (used to build custom Karaf distribution)

<dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <type>kar</type>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>standard</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

And I listed the following features in startupFeatures:

<startupFeatures>

                                                                                              <startupFeature>framework-logback</startupFeature>

                                                                                              <startupFeature>instance</startupFeature>

                                                                                              <startupFeature>package</startupFeature>

                                                                                              <startupFeature>log</startupFeature>

                                                                                              <startupFeature>ssh</startupFeature>

                                                                                              <startupFeature>system</startupFeature>

                                                                                              <startupFeature>feature</startupFeature>

                                                                                              <startupFeature>shell</startupFeature>

                                                                                              <startupFeature>management</startupFeature>

                                                                                              <startupFeature>service</startupFeature>

                                                                                              <startupFeature>jaas</startupFeature>

                                                                                              <startupFeature>deployer</startupFeature>

                                                                                              <startupFeature>diagnostic</startupFeature>

                                                                                              <startupFeature>wrap</startupFeature>

                                                                                              <startupFeature>bundle</startupFeature>

                                                                                              <startupFeature>config</startupFeature>

                                                                                              <startupFeature>http</startupFeature>

                                                                                              <startupFeature>webconsole</startupFeature>

                                                                                              <startupFeature>pax-web-http-tomcat</startupFeature>

                                                                               </startupFeatures>

This results in the above declared features listed in bootFeatures in etc/org.apache.karaf.features.cfg.

When I start Karaf with this set up without my application the webconsole works fine and I can see the following on the features page:

pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6              Installed

pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6              Installed

Therefore I asked whether it i possible to uninstall pax-web-http-jetty.

 

2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.

 

Webconsole is listed in the bootFeatures (see above). My application consists of a lot of bundles but the one with the UI is a WAB (war packaging with manifest which includes: Web-ContextPath: /main). Primefaces and JSF are wired using the Require-Bundle header in manifest:

<Require-Bundle>

javax.faces-api,

org.primefaces

</Require-Bundle>

All the bundles and their dependencies (JSF, primefaces etc.) are listed in a feature.xml file which I place in the deploy directory in Karaf. The application loads and works fine. I am just having problem with the webconsole.

I unfortunately cannot share the code of the bundles. But I am happy to provide more information if necessary.

 

Let me know if you need more information.

Best regards

Martin Zukal

 

 

From: Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > 
Sent: Thursday, November 3, 2022 9:56 AM
To: user@karaf.apache.org <ma...@karaf.apache.org> ; Martin Zukal <martin.zukal@stabilit.ch <ma...@stabilit.ch> >
Subject: Re: webconsole and pax-web-http-tomcat

 

Hello

 

First - which Karaf version are you using?

Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.

 

Pax Web 8 is highly refactored major version of the project where we've tried to make sure that things like JSF (which rely heavily on ServletContainerInitializers) work smoothly.

There are dedicated tests both for webconsole and for JSF (MyFaces, Primefaces) and even for techs like Vaadin.

 

Check the JSF samples at https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf

 

Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?

 

You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.

 

2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.

 

kind regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 09:46 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hello everyone,
I am experiencing strange behavior with webconsole of Apache Karaf. I have an application deployed using a custom feature file in Apache Karaf. The application is based on Spring and is using Primefaces (and Mojarra JSF implementation version 2.2.15). When I run it with standard war feature (which by default installs pax-web-http-jetty) I am getting the following error messages in the log file:
Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI? 
Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f <ma...@5005965f>  because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?
However, the webconsole works perfectly in this case.
When I install the pax-web-http-tomcat feature the above mentioned error messages are gone but the webconsole is not working properly (the resources from res and lib are not loaded so I see allmost an empty page - see attachment).
I can see the following errors in the log file:

[2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10 o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable 
[2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10 o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] javax.servlet.UnavailableException: No static resources were found
        at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
        at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
        at javax.servlet.GenericServlet.init(GenericServlet.java:180)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
        at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
        at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
        at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .SocketProcessorBase.run(SocketProcessorBase.java:49)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
        at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
        at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
        at java.base/sun.nio.ch <http://sun.nio.ch> .AsynchronousChannelGroupImpl$1.run(Unknown Source)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Unknown Source)


Does it mean that the webconsole works only with pax-web-http-jetty? 

I can also see that both pax-web-http-jetty and pax-web-http-tomcat features are installed. Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
Any help with this issue will be appreciated.

Best regards
Martin Zukal




Re: webconsole and pax-web-http-tomcat

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Hi

OK, I checked the scenario (Karaf 4.4.1, Pax Web 8.0.6, pax-web-http-tomcat
and mvn:io.hawt/hawtio-osgi/2.15.0/war web application).

The missing RESOURCES_ATTR attribute in your case is available in my case
and is added with this code (in
org.apache.catalina.core.StandardContext#startInternal()):

if (ok) {
    getServletContext().setAttribute
        (Globals.RESOURCES_ATTR, getResources());

so looks like "ok" is false ;) please increase logging for
"org.ops4j.pax.web.extender.war" logger to see what may be wrong.

regards
Grzegorz Grzybek

czw., 3 lis 2022 o 14:47 Grzegorz Grzybek <gr...@gmail.com> napisał(a):

> Let me check this, because there's obvious check in Tomcat code:
>
> // Load the web resources
> resources = (WebResourceRoot)
> getServletContext().getAttribute(Globals.RESOURCES_ATTR);
> if (resources == null) {
>     throw new
> UnavailableException(sm.getString("defaultServlet.noResources"));
> }
>
> I'm sure I've added enough customization, but maybe something's wrong with
> Tomcat upgrade? Give me few hours (I have urgent tasks to do..)
>
> regards
> Grzegorz Grzybek
>
> czw., 3 lis 2022 o 14:34 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
>> Hi,
>>
>> Thanks a lot! I finally got rid off the jetty feature when using the
>> pax-web-war.
>>
>> Unfortunately, I still see the following errors in the log file:
>>
>> [2022-11-03 14:21:03.337] INFO  ttp-nio2-0.0.0.0-8080-exec-4
>> o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking
>> servlet [default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] as unavailable
>>
>> [2022-11-03 14:21:03.341] ERROR ttp-nio2-0.0.0.0-8080-exec-4
>> o.a.c.c.C.[.[.[/].[default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] Allocate
>> exception for servlet [default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9]
>> javax.servlet.UnavailableException: No static resources were found
>>
>>                 at
>> org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
>>
>>                 at
>> org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
>>
>>                 at
>> javax.servlet.GenericServlet.init(GenericServlet.java:180)
>>
>>                 at
>> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
>>
>>                 at
>> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
>>
>>                 at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
>>
>>                 at
>> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
>>
>>                 at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>>
>>                 at
>> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
>>
>>                 at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
>>
>>                 at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
>>
>>                 at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>>
>>                 at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
>>
>>                 at
>> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
>>
>>                 at
>> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>>
>>                 at
>> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
>>
>>                 at
>> org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
>>
>>                 at
>> org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
>>
>>                 at
>> org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
>>
>>                 at
>> org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
>>
>>                 at
>> org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
>>
>>                 at
>> java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:127)
>>
>>                 at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:219)
>>
>>                 at
>> java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
>>
>>                 at
>> org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>>
>>                 at
>> org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>>
>>                 at
>> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>>
>>                 at java.base/java.lang.Thread.run(Thread.java:829)
>>
>>
>>
>> The weird thing is that when I run Karaf locally (where it is configured
>> to resolve the dependencies from my local maven repository) the console
>> works. I can see the bundles, services, features etc. However, the menu
>> item http under Main is not displayed.
>>
>> When I run Karaf in test environment (based on docker) where it is
>> configured to resolve the dependencies from system or repository
>> directories I see the alsmost empty page which I sent in attachment in my
>> first email.
>>
>> The above mentioned errors are in the log file In both cases.´
>>
>> Best regards
>>
>> Martin Zukal
>>
>>
>>
>> *From:* Grzegorz Grzybek <gr...@gmail.com>
>> *Sent:* Thursday, November 3, 2022 12:33 PM
>> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
>> *Subject:* Re: webconsole and pax-web-http-tomcat
>>
>>
>>
>> Ah - I forgot about "war"...
>>
>>
>>
>> It's defined as:
>>
>>
>>
>>     <feature name="war" description="Transition feature for backward
>> compatibility" version="4.4.1">
>>         <feature>pax-web-http-war</feature>
>>     </feature>
>>
>>
>>
>> which again leads to Jetty. You need "pax-web-war" feature, which doesn't
>> enforce any particular runtime, so you have to use one explicitly - like
>> pax-web-http-tomcat.
>>
>>
>>
>> regards
>>
>> Grzegorz Grzybek
>>
>>
>>
>> czw., 3 lis 2022 o 12:28 Martin Zukal via user <us...@karaf.apache.org>
>> napisał(a):
>>
>> Hi,
>>
>> Again thanks for a quick response. I tried to remove the http feature
>> from startupFeatures but then Karaf does not start and I can see the
>> following error in the log file:
>>
>> Error resolving artifact
>> org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6: [Could not find
>> artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
>> defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/), Could not
>> find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
>> local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)]
>>
>>                 at
>> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.configureIOException(AetherBasedResolver.java:803)
>>
>>                 at
>> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:774)
>>
>>                 at
>> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:657)
>>
>>                 at
>> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:598)
>>
>>                 at
>> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:565)
>>
>>                 at
>> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:555)
>>
>>                 at
>> org.ops4j.pax.url.mvn.internal.Connection.getInputStream(Connection.java:123)
>>
>>                 at java.base/java.net.URL.openStream(Unknown Source)
>>
>>                 at
>> org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:304)
>>
>>                 at
>> org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:173)
>>
>>                 at
>> org.apache.karaf.features.internal.service.BundleInstallSupportImpl.installConfigs(BundleInstallSupportImpl.java:301)
>>
>>                 at
>> org.apache.karaf.features.internal.service.FeaturesServiceImpl.installConfigs(FeaturesServiceImpl.java:1185)
>>
>>                 at
>> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:961)
>>
>>                 at
>> org.apache.karaf.features.internal.service.Deployer.handlePrerequisites(Deployer.java:1121)
>>
>>                 at
>> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:394)
>>
>>                 at
>> org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069)
>>
>>                 at
>> org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004)
>>
>>                 at java.base/java.util.concurrent.FutureTask.run(Unknown
>> Source)
>>
>>                 at
>> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>>
>>                 at
>> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>>
>>                 at java.base/java.lang.Thread.run(Unknown Source)
>>
>>                 Suppressed:
>> shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not
>> find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
>> defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)
>>
>>                                at
>> shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)
>>
>>                                at
>> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)
>>
>>                                at
>> shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
>>
>>                                at
>> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)
>>
>>                                at
>> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
>>
>>                                at
>> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)
>>
>>                                at
>> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)
>>
>>                                at
>> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
>>
>>                                at
>> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
>>
>>                                at
>> shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
>>
>>                                at
>> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
>>
>>                                ... 19 more
>>
>>                 Suppressed:
>> shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not
>> find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
>> local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)
>>
>>                                at
>> shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)
>>
>>                                at
>> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)
>>
>>                                at
>> shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
>>
>>                                at
>> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)
>>
>>                                at
>> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
>>
>>                                at
>> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)
>>
>>                                at
>> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)
>>
>>                                at
>> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
>>
>>                                at
>> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
>>
>>                                at
>> shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
>>
>>                                at
>> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
>>
>>                                ... 19 more
>>
>> Caused by:
>> shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Error
>> resolving artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6
>>
>>                 at
>> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:413)
>>
>>                 at
>> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
>>
>>                 at
>> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
>>
>>                 at
>> shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
>>
>>                 at
>> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
>>
>>
>>
>> I guess that there is still some other feature which requires jetty.
>> Looking at the standard features I believe it is the war feature. War
>> feature is specified in my feature.xml file as follows: <feature
>> prerequisite="true">war</feature>.
>>
>> Is there a way how to deploy WAB file and use tomcat as the container?
>>
>>
>>
>> Best Regards
>>
>> Martin Zukal
>>
>>
>>
>> P.S.: I am going to send another email regarding the startup and boot
>> features.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *From:* Grzegorz Grzybek <gr...@gmail.com>
>> *Sent:* Thursday, November 3, 2022 11:04 AM
>> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
>> *Subject:* Re: webconsole and pax-web-http-tomcat
>>
>>
>>
>> Hi
>>
>>
>>
>> about "pax-web-http-jetty", just get rid of
>> "<startupFeature>http</startupFeature>" because it's quite
>> legacy/convenient feature defined like this:
>>
>>
>>
>>     <feature name="http" description="Transition feature for backward
>> compatibility" version="8.0.6">
>>         <feature>pax-web-http</feature>
>>     </feature>
>>
>>
>>
>> and "pax-web-http" (notice that the feature name doesn't specify the
>> runtime to choose: jetty, tomcat or undertow) is:
>>
>>
>>
>>     <feature name="pax-web-http" description="Pax Web OSGi HTTP Service"
>> version="8.0.6">
>>         <feature>pax-web-http-jetty</feature>
>>         <bundle
>> start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
>>         <capability>http-service;provider:=pax-http</capability>
>>         <conditional>
>>             <condition>webconsole</condition>
>>             <bundle
>> start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
>>         </conditional>
>>     </feature>
>>
>>
>>
>> So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or
>> "pax-web-http-undertow") specified explicitly.
>>
>>
>>
>> *Webconsole is listed in the bootFeatures (see above). […]*
>>
>>
>>
>> Actually, it's specified in <startupFeatures> :) that's big difference -
>> you're effectively doing (karaf-maven-plugin is doing) the resolution at
>> build time, so you simply get a big list of bundles inside
>> etc/startup.properties. This makes uninstalling the features a bit harder.
>>
>> In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle
>> vs feature. With "startup features" you're "flattening" the features into a
>> list of bundles. It may speed things up, but generally I'm not recommending
>> it.
>>
>>
>>
>> And finally, to see what's the problem, you can increase logging level of
>> "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of
>> information about ServletContainerInitializers and annotated classes being
>> discovered.
>>
>>
>>
>> I still hope that removing pax-web-http-jetty (by not including "http"
>> feature) will solve your problem.
>>
>>
>>
>> regards
>>
>> Grzegorz Grzybek
>>
>>
>>
>>
>>
>> czw., 3 lis 2022 o 10:36 Martin Zukal via user <us...@karaf.apache.org>
>> napisał(a):
>>
>> Hello and thank you for a quick response!
>>
>> Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1
>> which comes with Pax Web 8.0.6.
>>
>> I looked at the samples and they already helped me a lot but I will look
>> at them once again, maybe I missed something. Basically, I followed:
>> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml
>>
>>
>>
>>
>>
>> *You actually don't uninstall features using karaf-maven-plugin - you
>> declare features you want, and karaf-maven-plugin will put the features
>> into boot features (etc/org.apache.karaf.features.cfg - when in runtime
>> scope) or into startup bundles (etc/startup.properties - when in compile
>> scope). So definitely you have to fix your <configuration> for
>> karaf-maven-plugin.*
>>
>>
>>
>> I have the following dependencies in my pom.xml (used to build custom
>> Karaf distribution)
>>
>> <dependency>
>>
>>
>> <groupId>org.apache.karaf.features</groupId>
>>
>>
>> <artifactId>framework</artifactId>
>>
>>
>> <version>${karaf.version}</version>
>>
>>                                                <type>kar</type>
>>
>>                                </dependency>
>>
>>                                <dependency>
>>
>>
>> <groupId>org.apache.karaf.features</groupId>
>>
>>
>> <artifactId>framework</artifactId>
>>
>>
>> <version>${karaf.version}</version>
>>
>>
>> <classifier>features</classifier>
>>
>>                                                <type>xml</type>
>>
>>                                                <scope>runtime</scope>
>>
>>                                </dependency>
>>
>>                                <dependency>
>>
>>
>> <groupId>org.apache.karaf.features</groupId>
>>
>>
>> <artifactId>standard</artifactId>
>>
>>
>> <version>${karaf.version}</version>
>>
>>
>> <classifier>features</classifier>
>>
>>                                                <type>xml</type>
>>
>>                                                <scope>runtime</scope>
>>
>>                                </dependency>
>>
>> And I listed the following features in startupFeatures:
>>
>> <startupFeatures>
>>
>>
>> <startupFeature>framework-logback</startupFeature>
>>
>>
>> <startupFeature>instance</startupFeature>
>>
>>
>> <startupFeature>package</startupFeature>
>>
>>
>> <startupFeature>log</startupFeature>
>>
>>
>> <startupFeature>ssh</startupFeature>
>>
>>
>> <startupFeature>system</startupFeature>
>>
>>
>> <startupFeature>feature</startupFeature>
>>
>>
>> <startupFeature>shell</startupFeature>
>>
>>
>> <startupFeature>management</startupFeature>
>>
>>
>> <startupFeature>service</startupFeature>
>>
>>
>> <startupFeature>jaas</startupFeature>
>>
>>
>> <startupFeature>deployer</startupFeature>
>>
>>
>> <startupFeature>diagnostic</startupFeature>
>>
>>
>> <startupFeature>wrap</startupFeature>
>>
>>
>> <startupFeature>bundle</startupFeature>
>>
>>
>> <startupFeature>config</startupFeature>
>>
>>
>> <startupFeature>http</startupFeature>
>>
>>
>> <startupFeature>webconsole</startupFeature>
>>
>>
>> <startupFeature>pax-web-http-tomcat</startupFeature>
>>
>>
>> </startupFeatures>
>>
>> This results in the above declared features listed in bootFeatures in
>> etc/org.apache.karaf.features.cfg.
>>
>> When I start Karaf with this set up without my application the webconsole
>> works fine and I can see the following on the features page:
>>
>> pax-web-http-jetty         8.0.6
>> org.ops4j.pax.web-8.0.6              Installed
>>
>> pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6
>> Installed
>>
>> Therefore I asked whether it i possible to uninstall pax-web-http-jetty.
>>
>>
>>
>> *2nd - how do you install the webconsole and/or your JSF bundle? Are then
>> installed as WAR (WAB) files? May I see them? I don't claim that the
>> problem is only at your side - maybe Pax Web didn't anticpate some setup
>> and I'd be happy to help solving this problem.*
>>
>>
>>
>> Webconsole is listed in the bootFeatures (see above). My application
>> consists of a lot of bundles but the one with the UI is a WAB (war
>> packaging with manifest which includes: Web-ContextPath: /main). Primefaces
>> and JSF are wired using the Require-Bundle header in manifest:
>>
>> <Require-Bundle>
>>
>> javax.faces-api,
>>
>> org.primefaces
>>
>> </Require-Bundle>
>>
>> All the bundles and their dependencies (JSF, primefaces etc.) are listed
>> in a feature.xml file which I place in the deploy directory in Karaf. The
>> application loads and works fine. I am just having problem with the
>> webconsole.
>>
>> I unfortunately cannot share the code of the bundles. But I am happy to
>> provide more information if necessary.
>>
>>
>>
>> Let me know if you need more information.
>>
>> Best regards
>>
>> Martin Zukal
>>
>>
>>
>>
>>
>> *From:* Grzegorz Grzybek <gr...@gmail.com>
>> *Sent:* Thursday, November 3, 2022 9:56 AM
>> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
>> *Subject:* Re: webconsole and pax-web-http-tomcat
>>
>>
>>
>> Hello
>>
>>
>>
>> First - which Karaf version are you using?
>>
>> Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.
>>
>>
>>
>> Pax Web 8 is highly refactored major version of the project where we've
>> tried to make sure that things like JSF (which rely heavily on
>> ServletContainerInitializers) work smoothly.
>>
>> There are dedicated tests both for webconsole and for JSF (MyFaces,
>> Primefaces) and even for techs like Vaadin.
>>
>>
>>
>> Check the JSF samples at
>> https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf
>>
>>
>>
>> *Is it possible that the behavior is caused by conflict between
>> pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall
>> pax-web-http-jetty using karaf-maven-plugin?*
>>
>>
>>
>> You actually don't uninstall features using karaf-maven-plugin - you
>> declare features you want, and karaf-maven-plugin will put the features
>> into boot features (etc/org.apache.karaf.features.cfg - when in runtime
>> scope) or into startup bundles (etc/startup.properties - when in compile
>> scope). So definitely you have to fix your <configuration> for
>> karaf-maven-plugin.
>>
>>
>>
>> 2nd - how do you install the webconsole and/or your JSF bundle? Are then
>> installed as WAR (WAB) files? May I see them? I don't claim that the
>> problem is only at your side - maybe Pax Web didn't anticpate some setup
>> and I'd be happy to help solving this problem.
>>
>>
>>
>> kind regards
>>
>> Grzegorz Grzybek
>>
>>
>>
>> czw., 3 lis 2022 o 09:46 Martin Zukal via user <us...@karaf.apache.org>
>> napisał(a):
>>
>> Hello everyone,
>> I am experiencing strange behavior with webconsole of Apache Karaf. I
>> have an application deployed using a custom feature file in Apache Karaf.
>> The application is based on Spring and is using Primefaces (and Mojarra JSF
>> implementation version 2.2.15). When I run it with standard war feature
>> (which by default installs pax-web-http-jetty) I am getting the following
>> error messages in the log file:
>> Unable to obtain InjectionProvider from init time FacesContext. Does this
>> container implement the Mojarra Injection SPI?
>> Unable to inject
>> com.sun.faces.application.ApplicationFactoryImpl@5005965f because no
>> InjectionProvider can be found. Does this container implement the Mojarra
>> Injection SPI?
>> However, the webconsole works perfectly in this case.
>> When I install the pax-web-http-tomcat feature the above mentioned error
>> messages are gone but the webconsole is not working properly (the resources
>> from res and lib are not loaded so I see allmost an empty page - see
>> attachment).
>> I can see the following errors in the log file:
>>
>> [2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10
>> o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking
>> servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable
>> [2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10
>> o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate
>> exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469]
>> javax.servlet.UnavailableException: No static resources were found
>>         at
>> org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
>>         at
>> org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
>>         at javax.servlet.GenericServlet.init(GenericServlet.java:180)
>>         at
>> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
>>         at
>> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
>>         at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
>>         at
>> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
>>         at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>>         at
>> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
>>         at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
>>         at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
>>         at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>>         at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
>>         at
>> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
>>         at
>> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>>         at
>> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
>>         at org.apache.tomcat.util.net
>> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
>>         at org.apache.tomcat.util.net
>> .SocketProcessorBase.run(SocketProcessorBase.java:49)
>>         at org.apache.tomcat.util.net
>> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
>>         at org.apache.tomcat.util.net
>> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
>>         at org.apache.tomcat.util.net
>> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
>>         at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
>>         at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
>>         at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown
>> Source)
>>         at
>> org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>>         at
>> org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>>         at
>> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>>         at java.base/java.lang.Thread.run(Unknown Source)
>>
>>
>> Does it mean that the webconsole works only with pax-web-http-jetty?
>>
>> I can also see that both pax-web-http-jetty and pax-web-http-tomcat
>> features are installed. Is it possible that the behavior is caused by
>> conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way
>> how to uninstall pax-web-http-jetty using karaf-maven-plugin?
>> Any help with this issue will be appreciated.
>>
>> Best regards
>> Martin Zukal
>>
>>

Re: webconsole and pax-web-http-tomcat

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Let me check this, because there's obvious check in Tomcat code:

// Load the web resources
resources = (WebResourceRoot)
getServletContext().getAttribute(Globals.RESOURCES_ATTR);
if (resources == null) {
    throw new
UnavailableException(sm.getString("defaultServlet.noResources"));
}

I'm sure I've added enough customization, but maybe something's wrong with
Tomcat upgrade? Give me few hours (I have urgent tasks to do..)

regards
Grzegorz Grzybek

czw., 3 lis 2022 o 14:34 Martin Zukal via user <us...@karaf.apache.org>
napisał(a):

> Hi,
>
> Thanks a lot! I finally got rid off the jetty feature when using the
> pax-web-war.
>
> Unfortunately, I still see the following errors in the log file:
>
> [2022-11-03 14:21:03.337] INFO  ttp-nio2-0.0.0.0-8080-exec-4
> o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking
> servlet [default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] as unavailable
>
> [2022-11-03 14:21:03.341] ERROR ttp-nio2-0.0.0.0-8080-exec-4
> o.a.c.c.C.[.[.[/].[default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] Allocate
> exception for servlet [default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9]
> javax.servlet.UnavailableException: No static resources were found
>
>                 at
> org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
>
>                 at
> org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
>
>                 at
> javax.servlet.GenericServlet.init(GenericServlet.java:180)
>
>                 at
> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
>
>                 at
> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
>
>                 at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
>
>                 at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
>
>                 at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>
>                 at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
>
>                 at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
>
>                 at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
>
>                 at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>
>                 at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
>
>                 at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
>
>                 at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>
>                 at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
>
>                 at
> org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
>
>                 at
> org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
>
>                 at
> org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
>
>                 at
> org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
>
>                 at
> org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
>
>                 at
> java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:127)
>
>                 at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:219)
>
>                 at
> java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
>
>                 at
> org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>
>                 at
> org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>
>                 at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>
>                 at java.base/java.lang.Thread.run(Thread.java:829)
>
>
>
> The weird thing is that when I run Karaf locally (where it is configured
> to resolve the dependencies from my local maven repository) the console
> works. I can see the bundles, services, features etc. However, the menu
> item http under Main is not displayed.
>
> When I run Karaf in test environment (based on docker) where it is
> configured to resolve the dependencies from system or repository
> directories I see the alsmost empty page which I sent in attachment in my
> first email.
>
> The above mentioned errors are in the log file In both cases.´
>
> Best regards
>
> Martin Zukal
>
>
>
> *From:* Grzegorz Grzybek <gr...@gmail.com>
> *Sent:* Thursday, November 3, 2022 12:33 PM
> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> *Subject:* Re: webconsole and pax-web-http-tomcat
>
>
>
> Ah - I forgot about "war"...
>
>
>
> It's defined as:
>
>
>
>     <feature name="war" description="Transition feature for backward
> compatibility" version="4.4.1">
>         <feature>pax-web-http-war</feature>
>     </feature>
>
>
>
> which again leads to Jetty. You need "pax-web-war" feature, which doesn't
> enforce any particular runtime, so you have to use one explicitly - like
> pax-web-http-tomcat.
>
>
>
> regards
>
> Grzegorz Grzybek
>
>
>
> czw., 3 lis 2022 o 12:28 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
> Hi,
>
> Again thanks for a quick response. I tried to remove the http feature from
> startupFeatures but then Karaf does not start and I can see the following
> error in the log file:
>
> Error resolving artifact
> org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6: [Could not find
> artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
> defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/), Could not
> find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
> local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)]
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.configureIOException(AetherBasedResolver.java:803)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:774)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:657)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:598)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:565)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:555)
>
>                 at
> org.ops4j.pax.url.mvn.internal.Connection.getInputStream(Connection.java:123)
>
>                 at java.base/java.net.URL.openStream(Unknown Source)
>
>                 at
> org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:304)
>
>                 at
> org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:173)
>
>                 at
> org.apache.karaf.features.internal.service.BundleInstallSupportImpl.installConfigs(BundleInstallSupportImpl.java:301)
>
>                 at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.installConfigs(FeaturesServiceImpl.java:1185)
>
>                 at
> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:961)
>
>                 at
> org.apache.karaf.features.internal.service.Deployer.handlePrerequisites(Deployer.java:1121)
>
>                 at
> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:394)
>
>                 at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069)
>
>                 at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004)
>
>                 at java.base/java.util.concurrent.FutureTask.run(Unknown
> Source)
>
>                 at
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>
>                 at
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>
>                 at java.base/java.lang.Thread.run(Unknown Source)
>
>                 Suppressed:
> shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not
> find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
> defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)
>
>                                at
> shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
>
>                                at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
>
>                                ... 19 more
>
>                 Suppressed:
> shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not
> find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
> local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)
>
>                                at
> shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
>
>                                at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
>
>                                ... 19 more
>
> Caused by:
> shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Error
> resolving artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6
>
>                 at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:413)
>
>                 at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
>
>                 at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
>
>                 at
> shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
>
>
>
> I guess that there is still some other feature which requires jetty.
> Looking at the standard features I believe it is the war feature. War
> feature is specified in my feature.xml file as follows: <feature
> prerequisite="true">war</feature>.
>
> Is there a way how to deploy WAB file and use tomcat as the container?
>
>
>
> Best Regards
>
> Martin Zukal
>
>
>
> P.S.: I am going to send another email regarding the startup and boot
> features.
>
>
>
>
>
>
>
>
>
> *From:* Grzegorz Grzybek <gr...@gmail.com>
> *Sent:* Thursday, November 3, 2022 11:04 AM
> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> *Subject:* Re: webconsole and pax-web-http-tomcat
>
>
>
> Hi
>
>
>
> about "pax-web-http-jetty", just get rid of
> "<startupFeature>http</startupFeature>" because it's quite
> legacy/convenient feature defined like this:
>
>
>
>     <feature name="http" description="Transition feature for backward
> compatibility" version="8.0.6">
>         <feature>pax-web-http</feature>
>     </feature>
>
>
>
> and "pax-web-http" (notice that the feature name doesn't specify the
> runtime to choose: jetty, tomcat or undertow) is:
>
>
>
>     <feature name="pax-web-http" description="Pax Web OSGi HTTP Service"
> version="8.0.6">
>         <feature>pax-web-http-jetty</feature>
>         <bundle
> start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
>         <capability>http-service;provider:=pax-http</capability>
>         <conditional>
>             <condition>webconsole</condition>
>             <bundle
> start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
>         </conditional>
>     </feature>
>
>
>
> So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or
> "pax-web-http-undertow") specified explicitly.
>
>
>
> *Webconsole is listed in the bootFeatures (see above). […]*
>
>
>
> Actually, it's specified in <startupFeatures> :) that's big difference -
> you're effectively doing (karaf-maven-plugin is doing) the resolution at
> build time, so you simply get a big list of bundles inside
> etc/startup.properties. This makes uninstalling the features a bit harder.
>
> In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle
> vs feature. With "startup features" you're "flattening" the features into a
> list of bundles. It may speed things up, but generally I'm not recommending
> it.
>
>
>
> And finally, to see what's the problem, you can increase logging level of
> "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of
> information about ServletContainerInitializers and annotated classes being
> discovered.
>
>
>
> I still hope that removing pax-web-http-jetty (by not including "http"
> feature) will solve your problem.
>
>
>
> regards
>
> Grzegorz Grzybek
>
>
>
>
>
> czw., 3 lis 2022 o 10:36 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
> Hello and thank you for a quick response!
>
> Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1
> which comes with Pax Web 8.0.6.
>
> I looked at the samples and they already helped me a lot but I will look
> at them once again, maybe I missed something. Basically, I followed:
> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml
>
>
>
>
>
> *You actually don't uninstall features using karaf-maven-plugin - you
> declare features you want, and karaf-maven-plugin will put the features
> into boot features (etc/org.apache.karaf.features.cfg - when in runtime
> scope) or into startup bundles (etc/startup.properties - when in compile
> scope). So definitely you have to fix your <configuration> for
> karaf-maven-plugin.*
>
>
>
> I have the following dependencies in my pom.xml (used to build custom
> Karaf distribution)
>
> <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>framework</artifactId>
>
>
> <version>${karaf.version}</version>
>
>                                                <type>kar</type>
>
>                                </dependency>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>framework</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <classifier>features</classifier>
>
>                                                <type>xml</type>
>
>                                                <scope>runtime</scope>
>
>                                </dependency>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>standard</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <classifier>features</classifier>
>
>                                                <type>xml</type>
>
>                                                <scope>runtime</scope>
>
>                                </dependency>
>
> And I listed the following features in startupFeatures:
>
> <startupFeatures>
>
>
> <startupFeature>framework-logback</startupFeature>
>
>
> <startupFeature>instance</startupFeature>
>
>
> <startupFeature>package</startupFeature>
>
>
> <startupFeature>log</startupFeature>
>
>
> <startupFeature>ssh</startupFeature>
>
>
> <startupFeature>system</startupFeature>
>
>
> <startupFeature>feature</startupFeature>
>
>
> <startupFeature>shell</startupFeature>
>
>
> <startupFeature>management</startupFeature>
>
>
> <startupFeature>service</startupFeature>
>
>
> <startupFeature>jaas</startupFeature>
>
>
> <startupFeature>deployer</startupFeature>
>
>
> <startupFeature>diagnostic</startupFeature>
>
>
> <startupFeature>wrap</startupFeature>
>
>
> <startupFeature>bundle</startupFeature>
>
>
> <startupFeature>config</startupFeature>
>
>
> <startupFeature>http</startupFeature>
>
>
> <startupFeature>webconsole</startupFeature>
>
>
> <startupFeature>pax-web-http-tomcat</startupFeature>
>
>
> </startupFeatures>
>
> This results in the above declared features listed in bootFeatures in
> etc/org.apache.karaf.features.cfg.
>
> When I start Karaf with this set up without my application the webconsole
> works fine and I can see the following on the features page:
>
> pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6
> Installed
>
> pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6
> Installed
>
> Therefore I asked whether it i possible to uninstall pax-web-http-jetty.
>
>
>
> *2nd - how do you install the webconsole and/or your JSF bundle? Are then
> installed as WAR (WAB) files? May I see them? I don't claim that the
> problem is only at your side - maybe Pax Web didn't anticpate some setup
> and I'd be happy to help solving this problem.*
>
>
>
> Webconsole is listed in the bootFeatures (see above). My application
> consists of a lot of bundles but the one with the UI is a WAB (war
> packaging with manifest which includes: Web-ContextPath: /main). Primefaces
> and JSF are wired using the Require-Bundle header in manifest:
>
> <Require-Bundle>
>
> javax.faces-api,
>
> org.primefaces
>
> </Require-Bundle>
>
> All the bundles and their dependencies (JSF, primefaces etc.) are listed
> in a feature.xml file which I place in the deploy directory in Karaf. The
> application loads and works fine. I am just having problem with the
> webconsole.
>
> I unfortunately cannot share the code of the bundles. But I am happy to
> provide more information if necessary.
>
>
>
> Let me know if you need more information.
>
> Best regards
>
> Martin Zukal
>
>
>
>
>
> *From:* Grzegorz Grzybek <gr...@gmail.com>
> *Sent:* Thursday, November 3, 2022 9:56 AM
> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> *Subject:* Re: webconsole and pax-web-http-tomcat
>
>
>
> Hello
>
>
>
> First - which Karaf version are you using?
>
> Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.
>
>
>
> Pax Web 8 is highly refactored major version of the project where we've
> tried to make sure that things like JSF (which rely heavily on
> ServletContainerInitializers) work smoothly.
>
> There are dedicated tests both for webconsole and for JSF (MyFaces,
> Primefaces) and even for techs like Vaadin.
>
>
>
> Check the JSF samples at
> https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf
>
>
>
> *Is it possible that the behavior is caused by conflict between
> pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall
> pax-web-http-jetty using karaf-maven-plugin?*
>
>
>
> You actually don't uninstall features using karaf-maven-plugin - you
> declare features you want, and karaf-maven-plugin will put the features
> into boot features (etc/org.apache.karaf.features.cfg - when in runtime
> scope) or into startup bundles (etc/startup.properties - when in compile
> scope). So definitely you have to fix your <configuration> for
> karaf-maven-plugin.
>
>
>
> 2nd - how do you install the webconsole and/or your JSF bundle? Are then
> installed as WAR (WAB) files? May I see them? I don't claim that the
> problem is only at your side - maybe Pax Web didn't anticpate some setup
> and I'd be happy to help solving this problem.
>
>
>
> kind regards
>
> Grzegorz Grzybek
>
>
>
> czw., 3 lis 2022 o 09:46 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
> Hello everyone,
> I am experiencing strange behavior with webconsole of Apache Karaf. I have
> an application deployed using a custom feature file in Apache Karaf. The
> application is based on Spring and is using Primefaces (and Mojarra JSF
> implementation version 2.2.15). When I run it with standard war feature
> (which by default installs pax-web-http-jetty) I am getting the following
> error messages in the log file:
> Unable to obtain InjectionProvider from init time FacesContext. Does this
> container implement the Mojarra Injection SPI?
> Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f
> because no InjectionProvider can be found. Does this container implement
> the Mojarra Injection SPI?
> However, the webconsole works perfectly in this case.
> When I install the pax-web-http-tomcat feature the above mentioned error
> messages are gone but the webconsole is not working properly (the resources
> from res and lib are not loaded so I see allmost an empty page - see
> attachment).
> I can see the following errors in the log file:
>
> [2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10
> o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking
> servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable
> [2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10
> o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate
> exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469]
> javax.servlet.UnavailableException: No static resources were found
>         at
> org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
>         at
> org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
>         at javax.servlet.GenericServlet.init(GenericServlet.java:180)
>         at
> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
>         at
> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
>         at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>         at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
>         at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
>         at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>         at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
>         at org.apache.tomcat.util.net
> .SocketProcessorBase.run(SocketProcessorBase.java:49)
>         at org.apache.tomcat.util.net
> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
>         at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
>         at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
>         at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown
> Source)
>         at
> org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>         at
> org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>         at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>         at java.base/java.lang.Thread.run(Unknown Source)
>
>
> Does it mean that the webconsole works only with pax-web-http-jetty?
>
> I can also see that both pax-web-http-jetty and pax-web-http-tomcat
> features are installed. Is it possible that the behavior is caused by
> conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way
> how to uninstall pax-web-http-jetty using karaf-maven-plugin?
> Any help with this issue will be appreciated.
>
> Best regards
> Martin Zukal
>
>

RE: webconsole and pax-web-http-tomcat

Posted by Martin Zukal via user <us...@karaf.apache.org>.
Hi,

Thanks a lot! I finally got rid off the jetty feature when using the pax-web-war.

Unfortunately, I still see the following errors in the log file:

[2022-11-03 14:21:03.337] INFO  ttp-nio2-0.0.0.0-8080-exec-4 o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking servlet [default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] as unavailable 

[2022-11-03 14:21:03.341] ERROR ttp-nio2-0.0.0.0-8080-exec-4 o.a.c.c.C.[.[.[/].[default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] Allocate exception for servlet [default-e4573fbf-222b-4d8d-a8b6-3509f9ba89f9] javax.servlet.UnavailableException: No static resources were found

                at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)

                at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)

                at javax.servlet.GenericServlet.init(GenericServlet.java:180)

                at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)

                at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)

                at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)

                at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)

                at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)

                at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)

                at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)

                at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)

                at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

                at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)

                at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)

                at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)

                at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:127)

                at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:219)

                at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)

                at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)

                at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)

                at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

                at java.base/java.lang.Thread.run(Thread.java:829)

 

The weird thing is that when I run Karaf locally (where it is configured to resolve the dependencies from my local maven repository) the console works. I can see the bundles, services, features etc. However, the menu item http under Main is not displayed. 

When I run Karaf in test environment (based on docker) where it is configured to resolve the dependencies from system or repository directories I see the alsmost empty page which I sent in attachment in my first email.

The above mentioned errors are in the log file In both cases.´

Best regards

Martin Zukal

 

From: Grzegorz Grzybek <gr...@gmail.com> 
Sent: Thursday, November 3, 2022 12:33 PM
To: user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
Subject: Re: webconsole and pax-web-http-tomcat

 

Ah - I forgot about "war"...

 

It's defined as:

 

    <feature name="war" description="Transition feature for backward compatibility" version="4.4.1">
        <feature>pax-web-http-war</feature>
    </feature>

 

which again leads to Jetty. You need "pax-web-war" feature, which doesn't enforce any particular runtime, so you have to use one explicitly - like pax-web-http-tomcat.

 

regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 12:28 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hi,

Again thanks for a quick response. I tried to remove the http feature from startupFeatures but then Karaf does not start and I can see the following error in the log file:

Error resolving artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6: [Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/), Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)]

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.configureIOException(AetherBasedResolver.java:803)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:774)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:657)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:598)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:565)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:555)

                at org.ops4j.pax.url.mvn.internal.Connection.getInputStream(Connection.java:123)

                at java.base/java.net.URL.openStream(Unknown Source)

                at org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:304)

                at org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:173)

                at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.installConfigs(BundleInstallSupportImpl.java:301)

                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.installConfigs(FeaturesServiceImpl.java:1185)

                at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:961)

                at org.apache.karaf.features.internal.service.Deployer.handlePrerequisites(Deployer.java:1121)

                at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:394)

                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069)

                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004)

                at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

                at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

                at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

                at java.base/java.lang.Thread.run(Unknown Source)

                Suppressed: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)

                               at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)

                               at shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)

                               at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)

                               at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)

                               ... 19 more

                Suppressed: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)

                               at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)

                               at shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)

                               at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)

                               at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)

                               ... 19 more

Caused by: shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Error resolving artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6

                at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:413)

                at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)

                at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)

                at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)

 

I guess that there is still some other feature which requires jetty. Looking at the standard features I believe it is the war feature. War feature is specified in my feature.xml file as follows: <feature prerequisite="true">war</feature>.

Is there a way how to deploy WAB file and use tomcat as the container?

 

Best Regards

Martin Zukal

 

P.S.: I am going to send another email regarding the startup and boot features.

 

 

 

 

From: Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > 
Sent: Thursday, November 3, 2022 11:04 AM
To: user@karaf.apache.org <ma...@karaf.apache.org> ; Martin Zukal <martin.zukal@stabilit.ch <ma...@stabilit.ch> >
Subject: Re: webconsole and pax-web-http-tomcat

 

Hi

 

about "pax-web-http-jetty", just get rid of "<startupFeature>http</startupFeature>" because it's quite legacy/convenient feature defined like this:

 

    <feature name="http" description="Transition feature for backward compatibility" version="8.0.6">
        <feature>pax-web-http</feature>
    </feature>

 

and "pax-web-http" (notice that the feature name doesn't specify the runtime to choose: jetty, tomcat or undertow) is:

 

    <feature name="pax-web-http" description="Pax Web OSGi HTTP Service" version="8.0.6">
        <feature>pax-web-http-jetty</feature>
        <bundle start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
        <capability>http-service;provider:=pax-http</capability>
        <conditional>
            <condition>webconsole</condition>
            <bundle start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
        </conditional>
    </feature>

 

So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or "pax-web-http-undertow") specified explicitly.

 

Webconsole is listed in the bootFeatures (see above). […]

 

Actually, it's specified in <startupFeatures> :) that's big difference - you're effectively doing (karaf-maven-plugin is doing) the resolution at build time, so you simply get a big list of bundles inside etc/startup.properties. This makes uninstalling the features a bit harder.

In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle vs feature. With "startup features" you're "flattening" the features into a list of bundles. It may speed things up, but generally I'm not recommending it.

 

And finally, to see what's the problem, you can increase logging level of "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of information about ServletContainerInitializers and annotated classes being discovered.

 

I still hope that removing pax-web-http-jetty (by not including "http" feature) will solve your problem.

 

regards

Grzegorz Grzybek

 

 

czw., 3 lis 2022 o 10:36 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hello and thank you for a quick response!

Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1 which comes with Pax Web 8.0.6.

I looked at the samples and they already helped me a lot but I will look at them once again, maybe I missed something. Basically, I followed: https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml

 

 

You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.

 

I have the following dependencies in my pom.xml (used to build custom Karaf distribution)

<dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <type>kar</type>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>standard</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

And I listed the following features in startupFeatures:

<startupFeatures>

                                                                                              <startupFeature>framework-logback</startupFeature>

                                                                                              <startupFeature>instance</startupFeature>

                                                                                              <startupFeature>package</startupFeature>

                                                                                              <startupFeature>log</startupFeature>

                                                                                              <startupFeature>ssh</startupFeature>

                                                                                              <startupFeature>system</startupFeature>

                                                                                              <startupFeature>feature</startupFeature>

                                                                                              <startupFeature>shell</startupFeature>

                                                                                              <startupFeature>management</startupFeature>

                                                                                              <startupFeature>service</startupFeature>

                                                                                              <startupFeature>jaas</startupFeature>

                                                                                              <startupFeature>deployer</startupFeature>

                                                                                              <startupFeature>diagnostic</startupFeature>

                                                                                              <startupFeature>wrap</startupFeature>

                                                                                              <startupFeature>bundle</startupFeature>

                                                                                              <startupFeature>config</startupFeature>

                                                                                              <startupFeature>http</startupFeature>

                                                                                              <startupFeature>webconsole</startupFeature>

                                                                                              <startupFeature>pax-web-http-tomcat</startupFeature>

                                                                               </startupFeatures>

This results in the above declared features listed in bootFeatures in etc/org.apache.karaf.features.cfg.

When I start Karaf with this set up without my application the webconsole works fine and I can see the following on the features page:

pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6              Installed

pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6              Installed

Therefore I asked whether it i possible to uninstall pax-web-http-jetty.

 

2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.

 

Webconsole is listed in the bootFeatures (see above). My application consists of a lot of bundles but the one with the UI is a WAB (war packaging with manifest which includes: Web-ContextPath: /main). Primefaces and JSF are wired using the Require-Bundle header in manifest:

<Require-Bundle>

javax.faces-api,

org.primefaces

</Require-Bundle>

All the bundles and their dependencies (JSF, primefaces etc.) are listed in a feature.xml file which I place in the deploy directory in Karaf. The application loads and works fine. I am just having problem with the webconsole.

I unfortunately cannot share the code of the bundles. But I am happy to provide more information if necessary.

 

Let me know if you need more information.

Best regards

Martin Zukal

 

 

From: Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > 
Sent: Thursday, November 3, 2022 9:56 AM
To: user@karaf.apache.org <ma...@karaf.apache.org> ; Martin Zukal <martin.zukal@stabilit.ch <ma...@stabilit.ch> >
Subject: Re: webconsole and pax-web-http-tomcat

 

Hello

 

First - which Karaf version are you using?

Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.

 

Pax Web 8 is highly refactored major version of the project where we've tried to make sure that things like JSF (which rely heavily on ServletContainerInitializers) work smoothly.

There are dedicated tests both for webconsole and for JSF (MyFaces, Primefaces) and even for techs like Vaadin.

 

Check the JSF samples at https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf

 

Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?

 

You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.

 

2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.

 

kind regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 09:46 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hello everyone,
I am experiencing strange behavior with webconsole of Apache Karaf. I have an application deployed using a custom feature file in Apache Karaf. The application is based on Spring and is using Primefaces (and Mojarra JSF implementation version 2.2.15). When I run it with standard war feature (which by default installs pax-web-http-jetty) I am getting the following error messages in the log file:
Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI? 
Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f <ma...@5005965f>  because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?
However, the webconsole works perfectly in this case.
When I install the pax-web-http-tomcat feature the above mentioned error messages are gone but the webconsole is not working properly (the resources from res and lib are not loaded so I see allmost an empty page - see attachment).
I can see the following errors in the log file:

[2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10 o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable 
[2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10 o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] javax.servlet.UnavailableException: No static resources were found
        at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
        at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
        at javax.servlet.GenericServlet.init(GenericServlet.java:180)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
        at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
        at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
        at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .SocketProcessorBase.run(SocketProcessorBase.java:49)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
        at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
        at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
        at java.base/sun.nio.ch <http://sun.nio.ch> .AsynchronousChannelGroupImpl$1.run(Unknown Source)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Unknown Source)


Does it mean that the webconsole works only with pax-web-http-jetty? 

I can also see that both pax-web-http-jetty and pax-web-http-tomcat features are installed. Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
Any help with this issue will be appreciated.

Best regards
Martin Zukal




Re: webconsole and pax-web-http-tomcat

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Ah - I forgot about "war"...

It's defined as:

    <feature name="war" description="Transition feature for backward
compatibility" version="4.4.1">
        <feature>pax-web-http-war</feature>
    </feature>

which again leads to Jetty. You need "pax-web-war" feature, which doesn't
enforce any particular runtime, so you have to use one explicitly - like
pax-web-http-tomcat.

regards
Grzegorz Grzybek

czw., 3 lis 2022 o 12:28 Martin Zukal via user <us...@karaf.apache.org>
napisał(a):

> Hi,
>
> Again thanks for a quick response. I tried to remove the http feature from
> startupFeatures but then Karaf does not start and I can see the following
> error in the log file:
>
> Error resolving artifact
> org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6: [Could not find
> artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
> defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/), Could not
> find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
> local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)]
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.configureIOException(AetherBasedResolver.java:803)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:774)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:657)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:598)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:565)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:555)
>
>                 at
> org.ops4j.pax.url.mvn.internal.Connection.getInputStream(Connection.java:123)
>
>                 at java.base/java.net.URL.openStream(Unknown Source)
>
>                 at
> org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:304)
>
>                 at
> org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:173)
>
>                 at
> org.apache.karaf.features.internal.service.BundleInstallSupportImpl.installConfigs(BundleInstallSupportImpl.java:301)
>
>                 at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.installConfigs(FeaturesServiceImpl.java:1185)
>
>                 at
> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:961)
>
>                 at
> org.apache.karaf.features.internal.service.Deployer.handlePrerequisites(Deployer.java:1121)
>
>                 at
> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:394)
>
>                 at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069)
>
>                 at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004)
>
>                 at java.base/java.util.concurrent.FutureTask.run(Unknown
> Source)
>
>                 at
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>
>                 at
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>
>                 at java.base/java.lang.Thread.run(Unknown Source)
>
>                 Suppressed:
> shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not
> find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
> defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)
>
>                                at
> shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
>
>                                at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
>
>                                ... 19 more
>
>                 Suppressed:
> shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not
> find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in
> local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)
>
>                                at
> shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)
>
>                                at
> shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
>
>                                at
> shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
>
>                                at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
>
>                                ... 19 more
>
> Caused by:
> shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Error
> resolving artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6
>
>                 at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:413)
>
>                 at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)
>
>                 at
> shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)
>
>                 at
> shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)
>
>                 at
> org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)
>
>
>
> I guess that there is still some other feature which requires jetty.
> Looking at the standard features I believe it is the war feature. War
> feature is specified in my feature.xml file as follows: <feature
> prerequisite="true">war</feature>.
>
> Is there a way how to deploy WAB file and use tomcat as the container?
>
>
>
> Best Regards
>
> Martin Zukal
>
>
>
> P.S.: I am going to send another email regarding the startup and boot
> features.
>
>
>
>
>
>
>
>
>
> *From:* Grzegorz Grzybek <gr...@gmail.com>
> *Sent:* Thursday, November 3, 2022 11:04 AM
> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> *Subject:* Re: webconsole and pax-web-http-tomcat
>
>
>
> Hi
>
>
>
> about "pax-web-http-jetty", just get rid of
> "<startupFeature>http</startupFeature>" because it's quite
> legacy/convenient feature defined like this:
>
>
>
>     <feature name="http" description="Transition feature for backward
> compatibility" version="8.0.6">
>         <feature>pax-web-http</feature>
>     </feature>
>
>
>
> and "pax-web-http" (notice that the feature name doesn't specify the
> runtime to choose: jetty, tomcat or undertow) is:
>
>
>
>     <feature name="pax-web-http" description="Pax Web OSGi HTTP Service"
> version="8.0.6">
>         <feature>pax-web-http-jetty</feature>
>         <bundle
> start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
>         <capability>http-service;provider:=pax-http</capability>
>         <conditional>
>             <condition>webconsole</condition>
>             <bundle
> start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
>         </conditional>
>     </feature>
>
>
>
> So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or
> "pax-web-http-undertow") specified explicitly.
>
>
>
> *Webconsole is listed in the bootFeatures (see above). […]*
>
>
>
> Actually, it's specified in <startupFeatures> :) that's big difference -
> you're effectively doing (karaf-maven-plugin is doing) the resolution at
> build time, so you simply get a big list of bundles inside
> etc/startup.properties. This makes uninstalling the features a bit harder.
>
> In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle
> vs feature. With "startup features" you're "flattening" the features into a
> list of bundles. It may speed things up, but generally I'm not recommending
> it.
>
>
>
> And finally, to see what's the problem, you can increase logging level of
> "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of
> information about ServletContainerInitializers and annotated classes being
> discovered.
>
>
>
> I still hope that removing pax-web-http-jetty (by not including "http"
> feature) will solve your problem.
>
>
>
> regards
>
> Grzegorz Grzybek
>
>
>
>
>
> czw., 3 lis 2022 o 10:36 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
> Hello and thank you for a quick response!
>
> Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1
> which comes with Pax Web 8.0.6.
>
> I looked at the samples and they already helped me a lot but I will look
> at them once again, maybe I missed something. Basically, I followed:
> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml
>
>
>
>
>
> *You actually don't uninstall features using karaf-maven-plugin - you
> declare features you want, and karaf-maven-plugin will put the features
> into boot features (etc/org.apache.karaf.features.cfg - when in runtime
> scope) or into startup bundles (etc/startup.properties - when in compile
> scope). So definitely you have to fix your <configuration> for
> karaf-maven-plugin.*
>
>
>
> I have the following dependencies in my pom.xml (used to build custom
> Karaf distribution)
>
> <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>framework</artifactId>
>
>
> <version>${karaf.version}</version>
>
>                                                <type>kar</type>
>
>                                </dependency>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>framework</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <classifier>features</classifier>
>
>                                                <type>xml</type>
>
>                                                <scope>runtime</scope>
>
>                                </dependency>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>standard</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <classifier>features</classifier>
>
>                                                <type>xml</type>
>
>                                                <scope>runtime</scope>
>
>                                </dependency>
>
> And I listed the following features in startupFeatures:
>
> <startupFeatures>
>
>
> <startupFeature>framework-logback</startupFeature>
>
>
> <startupFeature>instance</startupFeature>
>
>
> <startupFeature>package</startupFeature>
>
>
> <startupFeature>log</startupFeature>
>
>
> <startupFeature>ssh</startupFeature>
>
>
> <startupFeature>system</startupFeature>
>
>
> <startupFeature>feature</startupFeature>
>
>
> <startupFeature>shell</startupFeature>
>
>
> <startupFeature>management</startupFeature>
>
>
> <startupFeature>service</startupFeature>
>
>
> <startupFeature>jaas</startupFeature>
>
>
> <startupFeature>deployer</startupFeature>
>
>
> <startupFeature>diagnostic</startupFeature>
>
>
> <startupFeature>wrap</startupFeature>
>
>
> <startupFeature>bundle</startupFeature>
>
>
> <startupFeature>config</startupFeature>
>
>
> <startupFeature>http</startupFeature>
>
>
> <startupFeature>webconsole</startupFeature>
>
>
> <startupFeature>pax-web-http-tomcat</startupFeature>
>
>
> </startupFeatures>
>
> This results in the above declared features listed in bootFeatures in
> etc/org.apache.karaf.features.cfg.
>
> When I start Karaf with this set up without my application the webconsole
> works fine and I can see the following on the features page:
>
> pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6
> Installed
>
> pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6
> Installed
>
> Therefore I asked whether it i possible to uninstall pax-web-http-jetty.
>
>
>
> *2nd - how do you install the webconsole and/or your JSF bundle? Are then
> installed as WAR (WAB) files? May I see them? I don't claim that the
> problem is only at your side - maybe Pax Web didn't anticpate some setup
> and I'd be happy to help solving this problem.*
>
>
>
> Webconsole is listed in the bootFeatures (see above). My application
> consists of a lot of bundles but the one with the UI is a WAB (war
> packaging with manifest which includes: Web-ContextPath: /main). Primefaces
> and JSF are wired using the Require-Bundle header in manifest:
>
> <Require-Bundle>
>
> javax.faces-api,
>
> org.primefaces
>
> </Require-Bundle>
>
> All the bundles and their dependencies (JSF, primefaces etc.) are listed
> in a feature.xml file which I place in the deploy directory in Karaf. The
> application loads and works fine. I am just having problem with the
> webconsole.
>
> I unfortunately cannot share the code of the bundles. But I am happy to
> provide more information if necessary.
>
>
>
> Let me know if you need more information.
>
> Best regards
>
> Martin Zukal
>
>
>
>
>
> *From:* Grzegorz Grzybek <gr...@gmail.com>
> *Sent:* Thursday, November 3, 2022 9:56 AM
> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> *Subject:* Re: webconsole and pax-web-http-tomcat
>
>
>
> Hello
>
>
>
> First - which Karaf version are you using?
>
> Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.
>
>
>
> Pax Web 8 is highly refactored major version of the project where we've
> tried to make sure that things like JSF (which rely heavily on
> ServletContainerInitializers) work smoothly.
>
> There are dedicated tests both for webconsole and for JSF (MyFaces,
> Primefaces) and even for techs like Vaadin.
>
>
>
> Check the JSF samples at
> https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf
>
>
>
> *Is it possible that the behavior is caused by conflict between
> pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall
> pax-web-http-jetty using karaf-maven-plugin?*
>
>
>
> You actually don't uninstall features using karaf-maven-plugin - you
> declare features you want, and karaf-maven-plugin will put the features
> into boot features (etc/org.apache.karaf.features.cfg - when in runtime
> scope) or into startup bundles (etc/startup.properties - when in compile
> scope). So definitely you have to fix your <configuration> for
> karaf-maven-plugin.
>
>
>
> 2nd - how do you install the webconsole and/or your JSF bundle? Are then
> installed as WAR (WAB) files? May I see them? I don't claim that the
> problem is only at your side - maybe Pax Web didn't anticpate some setup
> and I'd be happy to help solving this problem.
>
>
>
> kind regards
>
> Grzegorz Grzybek
>
>
>
> czw., 3 lis 2022 o 09:46 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
> Hello everyone,
> I am experiencing strange behavior with webconsole of Apache Karaf. I have
> an application deployed using a custom feature file in Apache Karaf. The
> application is based on Spring and is using Primefaces (and Mojarra JSF
> implementation version 2.2.15). When I run it with standard war feature
> (which by default installs pax-web-http-jetty) I am getting the following
> error messages in the log file:
> Unable to obtain InjectionProvider from init time FacesContext. Does this
> container implement the Mojarra Injection SPI?
> Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f
> because no InjectionProvider can be found. Does this container implement
> the Mojarra Injection SPI?
> However, the webconsole works perfectly in this case.
> When I install the pax-web-http-tomcat feature the above mentioned error
> messages are gone but the webconsole is not working properly (the resources
> from res and lib are not loaded so I see allmost an empty page - see
> attachment).
> I can see the following errors in the log file:
>
> [2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10
> o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking
> servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable
> [2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10
> o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate
> exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469]
> javax.servlet.UnavailableException: No static resources were found
>         at
> org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
>         at
> org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
>         at javax.servlet.GenericServlet.init(GenericServlet.java:180)
>         at
> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
>         at
> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
>         at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>         at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
>         at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
>         at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>         at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
>         at org.apache.tomcat.util.net
> .SocketProcessorBase.run(SocketProcessorBase.java:49)
>         at org.apache.tomcat.util.net
> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
>         at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
>         at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
>         at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown
> Source)
>         at
> org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>         at
> org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>         at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>         at java.base/java.lang.Thread.run(Unknown Source)
>
>
> Does it mean that the webconsole works only with pax-web-http-jetty?
>
> I can also see that both pax-web-http-jetty and pax-web-http-tomcat
> features are installed. Is it possible that the behavior is caused by
> conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way
> how to uninstall pax-web-http-jetty using karaf-maven-plugin?
> Any help with this issue will be appreciated.
>
> Best regards
> Martin Zukal
>
>

startupFeatures vs. bootFeatures when building custom karaf distribution

Posted by Martin Zukal via user <us...@karaf.apache.org>.
Hello,

To be honest I am confused about the <startupFeatures> and <bootFeatures>. I followed the documentation here: https://svn.apache.org/repos/asf/karaf/site/production/manual/latest/custom-distribution.html#_plugin_configuration but it did not work the way I expected. I am trying to build a custom Karaf distribution which should resolve all artifacts locally (not in the maven repository). The idea is to have all artifacts needed by Karaf itself in the <KARAF_HOME>/system directory and all artifacts required by my application in a new directory <KARAF_HOME>/repository. I firstly build the „bare“ karaf and then I add the repository directory (which is generated using karaf-maven-plugin but using the <goal>features-add-to-repository</goal> based on my feature.xml file )

I created the following 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/xsd/maven-4.0.0.xsd>

                <modelVersion>4.0.0</modelVersion>

 

 

                <groupId>ch.stabilit</groupId>

                <artifactId>apache-karaf-STABILIT</artifactId>

                <version>4.4.1</version>

                <name>Apache Karaf distribution</name>

                <packaging>karaf-assembly</packaging>

 

 

                <properties>

                               <karaf.version>4.4.1</karaf.version>

                </properties>

 

                <dependencies>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <type>kar</type>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>standard</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

                </dependencies>

 

                <build>

                               <plugins>

                                               <plugin>

                                                               <groupId>org.apache.karaf.tooling</groupId>

                                                               <artifactId>karaf-maven-plugin</artifactId>

                                                               <version>${karaf.version}</version>

                                                               <extensions>true</extensions>

                                                               <executions>

                                                                               <execution>

                                                                                              <id>assembly</id>

                                                                                              <phase>prepare-package</phase>

                                                                                              <goals>

                                                                                                              <goal>assembly</goal>

                                                                                              </goals>

                                                                               </execution>

                                                               </executions>

                                                               <configuration>

                                                                               <bootRepositories>

                                                                                               <bootRepository>mvn:org.apache.karaf.features/spring/${karaf.version}/xml/features</bootRepository>

                                                                                               <bootRepository>mvn:org.apache.karaf.features/specs/${karaf.version}/xml/features</bootRepository>

                                                                                               <bootRepository>mvn:org.apache.karaf.features/enterprise/${karaf.version}/xml/features</bootRepository>

                                                                               </bootRepositories>

                                                                               <startupFeatures>

                                                                                              <startupFeature>framework-logback</startupFeature>

                                                                                              <startupFeature>instance</startupFeature>

                                                                                              <startupFeature>package</startupFeature>

                                                                                              <startupFeature>log</startupFeature>

                                                                                              <startupFeature>ssh</startupFeature>

                                                                                              <startupFeature>system</startupFeature>

                                                                                              <startupFeature>feature</startupFeature>

                                                                                              <startupFeature>shell</startupFeature>

                                                                                              <startupFeature>management</startupFeature>

                                                                                              <startupFeature>service</startupFeature>

                                                                                              <startupFeature>jaas</startupFeature>

                                                                                              <startupFeature>deployer</startupFeature>

                                                                                              <startupFeature>diagnostic</startupFeature>

                                                                                              <startupFeature>wrap</startupFeature>

                                                                                              <startupFeature>bundle</startupFeature>

                                                                                              <startupFeature>config</startupFeature>

                                                                                              <startupFeature>webconsole</startupFeature>

                                                                                              <startupFeature>pax-web-http-tomcat</startupFeature>

                                                                               </startupFeatures>

                                                                               <useReferenceUrls>true</useReferenceUrls>

                                                                               <installAllFeaturesByDefault>false</installAllFeaturesByDefault>

                                                                               <framework>framework-logback</framework>

                                                                               <archiveTarGz>false</archiveTarGz>

                                                                               <propertyEdits>

                                                                                              <edits>

                                                                                                              <edit>

                                                                                                                              <file>config.properties</file>

                                                                                                                              <operation>

                                                                                                                                              <operation>put</operation>

                                                                                                                              </operation>

                                                                                                                              <key>karaf.framework</key>

                                                                                                                              <value>equinox</value>

                                                                                                              </edit>

                                                                                                              <edit>

                                                                                                                              <file>config.properties</file>

                                                                                                                              <operation>

                                                                                                                                              <operation>extend</operation>

                                                                                                                              </operation>

                                                                                                                              <key>org.osgi.framework.system.packages</key>

                                                                                                                              <value>com.sun.jndi.ldap</value>

                                                                                                              </edit>

                                                                                                              <edit>

                                                                                                                              <file>config.properties</file>

                                                                                                                              <operation>

                                                                                                                                              <operation>extend</operation>

                                                                                                                              </operation>

                                                                                                                              <key>org.osgi.framework.system.packages</key>

                                                                                                                              <value>com.sun.jndi.url.ldap</value>

                                                                                                              </edit>

                                                                                                              <edit>

                                                                                                                              <file>config.properties</file>

                                                                                                                              <operation>

                                                                                                                                              <operation>extend</operation>

                                                                                                                              </operation>

                                                                                                                              <key>org.osgi.framework.bootdelegation</key>

                                                                                                                              <value> com.sun.jndi.ldap.*</value>

                                                                                                              </edit>

                                                                                                              <edit>

                                                                                                                              <file>users.properties</file>

                                                                                                                              <operation>

                                                                                                                                              <operation>put</operation>

                                                                                                                              </operation>

                                                                                                                              <key>_g_:admingroup</key>

                                                                                                                              <value>group,admin,manager,viewer,systembundles,ssh</value>

                                                                                                              </edit>

                                                                                                              <edit>

                                                                                                                              <file>users.properties</file>

                                                                                                                              <operation>

                                                                                                                                              <operation>put</operation>

                                                                                                                              </operation>

                                                                                                                              <key>karaf</key>

                                                                                                                              <value>karaf,_g_:admingroup</value>

                                                                                                              </edit>

                                                                                                              <edit>

                                                                                                                              <file>org.ops4j.pax.logging.cfg</file>

                                                                                                                              <operation>

                                                                                                                                              <operation>put</operation>

                                                                                                                              </operation>

                                                                                                                              <key>org.ops4j.pax.logging.logback.config.file</key>

                                                                                                                              <value>${karaf.base}/configuration/serviceability.xml</value>

                                                                                                              </edit>

                                                                                                              <edit>

                                                                                                                              <file>system.properties</file>

                                                                                                                              <operation>

                                                                                                                                              <operation>put</operation>

                                                                                                                              </operation>

                                                                                                                              <key>karaf.clean.all</key>

                                                                                                                              <value>true</value>

                                                                                                              </edit>

                                                                                                              <edit>

                                                                                                                              <file>org.ops4j.pax.web.cfg</file>

                                                                                                                              <operation>

                                                                                                                                              <operation>put</operation>

                                                                                                                              </operation>

                                                                                                                              <key>org.osgi.service.http.port</key>

                                                                                                                              <value>8080</value>

                                                                                                              </edit>

                                                                                                              <edit>

                                                                                                                              <file>org.ops4j.pax.url.mvn.cfg</file>

                                                                                                                              <operation>

                                                                                                                                              <operation>put</operation>

                                                                                                                              </operation>

                                                                                                                              <key>org.ops4j.pax.url.mvn.localRepository</key>

                                                                                                                              <value>${karaf.base}/repository</value>

                                                                                                              </edit>

                                                                                                              <edit>

                                                                                                                              <file>org.ops4j.pax.url.mvn.cfg</file>

                                                                                                                              <operation>

                                                                                                                                              <operation>put</operation>

                                                                                                                              </operation>

                                                                                                                              <key>org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote</key>

                                                                                                                              <value>true</value>

                                                                                                              </edit>

                                                                                                              <edit>

                                                                                                                              <file>org.ops4j.pax.url.mvn.cfg</file>

                                                                                                                              <operation>

                                                                                                                                              <operation>put</operation>

                                                                                                                              </operation>

                                                                                                                              <key>org.ops4j.pax.url.mvn.repositories</key>

                                                                                                                              <value>${karaf.home.uri}repository@id=local.repository@snapshots <mailto:$%7bkaraf.home.uri%7drepository@id=local.repository@snapshots%3c/value> </value>

                                                                                                              </edit>

                                                                                              </edits>

                                                                               </propertyEdits>

                                                               </configuration>

                                                               

                                               </plugin>

                               </plugins>

                </build>

</project>

 

With which I am able to build Karaf distribution which satisfies all my requirements.

 

You wrote that using startupFeatures will create a large startup.properties file. This is something I don’t observe. My startup.properties looks like this:

# Bundles to be started on startup, with startlevel

reference\:file\:org/apache/karaf/features/org.apache.karaf.features.extension/4.4.1/org.apache.karaf.features.extension-4.4.1.jar = 1

reference\:file\:org/ops4j/pax/url/pax-url-aether/2.6.11/pax-url-aether-2.6.11.jar = 5

reference\:file\:org/ops4j/pax/logging/pax-logging-logback/2.1.3/pax-logging-logback-2.1.3.jar = 8

reference\:file\:org/ops4j/pax/logging/pax-logging-api/2.1.3/pax-logging-api-2.1.3.jar = 8

reference\:file\:org/osgi/org.osgi.util.function/1.2.0/org.osgi.util.function-1.2.0.jar = 9

reference\:file\:org/osgi/org.osgi.util.promise/1.2.0/org.osgi.util.promise-1.2.0.jar = 9

reference\:file\:org/apache/felix/org.apache.felix.coordinator/1.0.2/org.apache.felix.coordinator-1.0.2.jar = 9

reference\:file\:org/apache/felix/org.apache.felix.converter/1.0.14/org.apache.felix.converter-1.0.14.jar = 9

reference\:file\:org/apache/felix/org.apache.felix.configadmin/1.9.24/org.apache.felix.configadmin-1.9.24.jar = 10

reference\:file\:org/apache/felix/org.apache.felix.configurator/1.0.14/org.apache.felix.configurator-1.0.14.jar = 11

reference\:file\:org/apache/sling/org.apache.sling.commons.johnzon/1.2.14/org.apache.sling.commons.johnzon-1.2.14.jar = 11

reference\:file\:org/apache/felix/org.apache.felix.configadmin.plugin.interpolation/1.2.4/org.apache.felix.configadmin.plugin.interpolation-1.2.4.jar = 11

reference\:file\:org/apache/felix/org.apache.felix.cm.json/1.0.6/org.apache.felix.cm.json-1.0.6.jar = 11

reference\:file\:org/apache/felix/org.apache.felix.fileinstall/3.7.4/org.apache.felix.fileinstall-3.7.4.jar = 12

reference\:file\:org/apache/karaf/features/org.apache.karaf.features.core/4.4.1/org.apache.karaf.features.core-4.4.1.jar = 15

 

When I tried to replace the <startupFeatures> with <bootFeatures> Karaf failed to start (the log file is completely empty).

I would really appreciate if you could point me to a good documentation on startupFeatures and bootFeatures.

 

Best regards

Martin Zukal

 

From: Grzegorz Grzybek <gr...@gmail.com> 
Sent: Thursday, November 3, 2022 11:04 AM
To: user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
Subject: Re: webconsole and pax-web-http-tomcat

 

Hi

 

about "pax-web-http-jetty", just get rid of "<startupFeature>http</startupFeature>" because it's quite legacy/convenient feature defined like this:

 

    <feature name="http" description="Transition feature for backward compatibility" version="8.0.6">
        <feature>pax-web-http</feature>
    </feature>

 

and "pax-web-http" (notice that the feature name doesn't specify the runtime to choose: jetty, tomcat or undertow) is:

 

    <feature name="pax-web-http" description="Pax Web OSGi HTTP Service" version="8.0.6">
        <feature>pax-web-http-jetty</feature>
        <bundle start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
        <capability>http-service;provider:=pax-http</capability>
        <conditional>
            <condition>webconsole</condition>
            <bundle start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
        </conditional>
    </feature>

 

So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or "pax-web-http-undertow") specified explicitly.

 

Webconsole is listed in the bootFeatures (see above). […]

 

Actually, it's specified in <startupFeatures> :) that's big difference - you're effectively doing (karaf-maven-plugin is doing) the resolution at build time, so you simply get a big list of bundles inside etc/startup.properties. This makes uninstalling the features a bit harder.

In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle vs feature. With "startup features" you're "flattening" the features into a list of bundles. It may speed things up, but generally I'm not recommending it.

 

And finally, to see what's the problem, you can increase logging level of "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of information about ServletContainerInitializers and annotated classes being discovered.

 

I still hope that removing pax-web-http-jetty (by not including "http" feature) will solve your problem.

 

regards

Grzegorz Grzybek

 

 

czw., 3 lis 2022 o 10:36 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hello and thank you for a quick response!

Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1 which comes with Pax Web 8.0.6.

I looked at the samples and they already helped me a lot but I will look at them once again, maybe I missed something. Basically, I followed: https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml

 

 

You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.

 

I have the following dependencies in my pom.xml (used to build custom Karaf distribution)

<dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <type>kar</type>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>standard</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

And I listed the following features in startupFeatures:

<startupFeatures>

                                                                                              <startupFeature>framework-logback</startupFeature>

                                                                                              <startupFeature>instance</startupFeature>

                                                                                              <startupFeature>package</startupFeature>

                                                                                              <startupFeature>log</startupFeature>

                                                                                              <startupFeature>ssh</startupFeature>

                                                                                              <startupFeature>system</startupFeature>

                                                                                              <startupFeature>feature</startupFeature>

                                                                                              <startupFeature>shell</startupFeature>

                                                                                              <startupFeature>management</startupFeature>

                                                                                              <startupFeature>service</startupFeature>

                                                                                              <startupFeature>jaas</startupFeature>

                                                                                              <startupFeature>deployer</startupFeature>

                                                                                              <startupFeature>diagnostic</startupFeature>

                                                                                              <startupFeature>wrap</startupFeature>

                                                                                              <startupFeature>bundle</startupFeature>

                                                                                              <startupFeature>config</startupFeature>

                                                                                              <startupFeature>http</startupFeature>

                                                                                              <startupFeature>webconsole</startupFeature>

                                                                                              <startupFeature>pax-web-http-tomcat</startupFeature>

                                                                               </startupFeatures>

This results in the above declared features listed in bootFeatures in etc/org.apache.karaf.features.cfg.

When I start Karaf with this set up without my application the webconsole works fine and I can see the following on the features page:

pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6              Installed

pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6              Installed

Therefore I asked whether it i possible to uninstall pax-web-http-jetty.

 

2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.

 

Webconsole is listed in the bootFeatures (see above). My application consists of a lot of bundles but the one with the UI is a WAB (war packaging with manifest which includes: Web-ContextPath: /main). Primefaces and JSF are wired using the Require-Bundle header in manifest:

<Require-Bundle>

javax.faces-api,

org.primefaces

</Require-Bundle>

All the bundles and their dependencies (JSF, primefaces etc.) are listed in a feature.xml file which I place in the deploy directory in Karaf. The application loads and works fine. I am just having problem with the webconsole.

I unfortunately cannot share the code of the bundles. But I am happy to provide more information if necessary.

 

Let me know if you need more information.

Best regards

Martin Zukal

 

 

From: Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > 
Sent: Thursday, November 3, 2022 9:56 AM
To: user@karaf.apache.org <ma...@karaf.apache.org> ; Martin Zukal <martin.zukal@stabilit.ch <ma...@stabilit.ch> >
Subject: Re: webconsole and pax-web-http-tomcat

 

Hello

 

First - which Karaf version are you using?

Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.

 

Pax Web 8 is highly refactored major version of the project where we've tried to make sure that things like JSF (which rely heavily on ServletContainerInitializers) work smoothly.

There are dedicated tests both for webconsole and for JSF (MyFaces, Primefaces) and even for techs like Vaadin.

 

Check the JSF samples at https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf

 

Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?

 

You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.

 

2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.

 

kind regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 09:46 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hello everyone,
I am experiencing strange behavior with webconsole of Apache Karaf. I have an application deployed using a custom feature file in Apache Karaf. The application is based on Spring and is using Primefaces (and Mojarra JSF implementation version 2.2.15). When I run it with standard war feature (which by default installs pax-web-http-jetty) I am getting the following error messages in the log file:
Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI? 
Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f <ma...@5005965f>  because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?
However, the webconsole works perfectly in this case.
When I install the pax-web-http-tomcat feature the above mentioned error messages are gone but the webconsole is not working properly (the resources from res and lib are not loaded so I see allmost an empty page - see attachment).
I can see the following errors in the log file:

[2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10 o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable 
[2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10 o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] javax.servlet.UnavailableException: No static resources were found
        at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
        at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
        at javax.servlet.GenericServlet.init(GenericServlet.java:180)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
        at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
        at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
        at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .SocketProcessorBase.run(SocketProcessorBase.java:49)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
        at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
        at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
        at java.base/sun.nio.ch <http://sun.nio.ch> .AsynchronousChannelGroupImpl$1.run(Unknown Source)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Unknown Source)


Does it mean that the webconsole works only with pax-web-http-jetty? 

I can also see that both pax-web-http-jetty and pax-web-http-tomcat features are installed. Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
Any help with this issue will be appreciated.

Best regards
Martin Zukal






RE: webconsole and pax-web-http-tomcat

Posted by Martin Zukal via user <us...@karaf.apache.org>.
Hi,

Again thanks for a quick response. I tried to remove the http feature from startupFeatures but then Karaf does not start and I can see the following error in the log file:

Error resolving artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6: [Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/), Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)]

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.configureIOException(AetherBasedResolver.java:803)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:774)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:657)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:598)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:565)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:555)

                at org.ops4j.pax.url.mvn.internal.Connection.getInputStream(Connection.java:123)

                at java.base/java.net.URL.openStream(Unknown Source)

                at org.apache.karaf.features.internal.service.FeatureConfigInstaller.installConfigurationFile(FeatureConfigInstaller.java:304)

                at org.apache.karaf.features.internal.service.FeatureConfigInstaller.installFeatureConfigs(FeatureConfigInstaller.java:173)

                at org.apache.karaf.features.internal.service.BundleInstallSupportImpl.installConfigs(BundleInstallSupportImpl.java:301)

                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.installConfigs(FeaturesServiceImpl.java:1185)

                at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:961)

                at org.apache.karaf.features.internal.service.Deployer.handlePrerequisites(Deployer.java:1121)

                at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:394)

                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1069)

                at org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:1004)

                at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

                at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

                at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

                at java.base/java.lang.Thread.run(Unknown Source)

                Suppressed: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in defaultlocal (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)

                               at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)

                               at shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)

                               at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)

                               at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)

                               ... 19 more

                Suppressed: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6 in local.repository (file:/opt/apache-karaf-STABILIT-4.4.1/repository/)

                               at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:48)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:368)

                               at shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:75)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:642)

                               at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:262)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:489)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:390)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)

                               at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)

                               at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)

                               at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)

                               ... 19 more

Caused by: shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Error resolving artifact org.ops4j.pax.web:pax-web-features:xml:config-jetty:8.0.6

                at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:413)

                at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:215)

                at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:192)

                at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:247)

                at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:767)

 

I guess that there is still some other feature which requires jetty. Looking at the standard features I believe it is the war feature. War feature is specified in my feature.xml file as follows: <feature prerequisite="true">war</feature>.

Is there a way how to deploy WAB file and use tomcat as the container?

 

Best Regards

Martin Zukal

 

P.S.: I am going to send another email regarding the startup and boot features.

 

 

 

 

From: Grzegorz Grzybek <gr...@gmail.com> 
Sent: Thursday, November 3, 2022 11:04 AM
To: user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
Subject: Re: webconsole and pax-web-http-tomcat

 

Hi

 

about "pax-web-http-jetty", just get rid of "<startupFeature>http</startupFeature>" because it's quite legacy/convenient feature defined like this:

 

    <feature name="http" description="Transition feature for backward compatibility" version="8.0.6">
        <feature>pax-web-http</feature>
    </feature>

 

and "pax-web-http" (notice that the feature name doesn't specify the runtime to choose: jetty, tomcat or undertow) is:

 

    <feature name="pax-web-http" description="Pax Web OSGi HTTP Service" version="8.0.6">
        <feature>pax-web-http-jetty</feature>
        <bundle start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
        <capability>http-service;provider:=pax-http</capability>
        <conditional>
            <condition>webconsole</condition>
            <bundle start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
        </conditional>
    </feature>

 

So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or "pax-web-http-undertow") specified explicitly.

 

Webconsole is listed in the bootFeatures (see above). […]

 

Actually, it's specified in <startupFeatures> :) that's big difference - you're effectively doing (karaf-maven-plugin is doing) the resolution at build time, so you simply get a big list of bundles inside etc/startup.properties. This makes uninstalling the features a bit harder.

In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle vs feature. With "startup features" you're "flattening" the features into a list of bundles. It may speed things up, but generally I'm not recommending it.

 

And finally, to see what's the problem, you can increase logging level of "org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of information about ServletContainerInitializers and annotated classes being discovered.

 

I still hope that removing pax-web-http-jetty (by not including "http" feature) will solve your problem.

 

regards

Grzegorz Grzybek

 

 

czw., 3 lis 2022 o 10:36 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hello and thank you for a quick response!

Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1 which comes with Pax Web 8.0.6.

I looked at the samples and they already helped me a lot but I will look at them once again, maybe I missed something. Basically, I followed: https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml

 

 

You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.

 

I have the following dependencies in my pom.xml (used to build custom Karaf distribution)

<dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <type>kar</type>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>standard</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

And I listed the following features in startupFeatures:

<startupFeatures>

                                                                                              <startupFeature>framework-logback</startupFeature>

                                                                                              <startupFeature>instance</startupFeature>

                                                                                              <startupFeature>package</startupFeature>

                                                                                              <startupFeature>log</startupFeature>

                                                                                              <startupFeature>ssh</startupFeature>

                                                                                              <startupFeature>system</startupFeature>

                                                                                              <startupFeature>feature</startupFeature>

                                                                                              <startupFeature>shell</startupFeature>

                                                                                              <startupFeature>management</startupFeature>

                                                                                              <startupFeature>service</startupFeature>

                                                                                              <startupFeature>jaas</startupFeature>

                                                                                              <startupFeature>deployer</startupFeature>

                                                                                              <startupFeature>diagnostic</startupFeature>

                                                                                              <startupFeature>wrap</startupFeature>

                                                                                              <startupFeature>bundle</startupFeature>

                                                                                              <startupFeature>config</startupFeature>

                                                                                              <startupFeature>http</startupFeature>

                                                                                              <startupFeature>webconsole</startupFeature>

                                                                                              <startupFeature>pax-web-http-tomcat</startupFeature>

                                                                               </startupFeatures>

This results in the above declared features listed in bootFeatures in etc/org.apache.karaf.features.cfg.

When I start Karaf with this set up without my application the webconsole works fine and I can see the following on the features page:

pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6              Installed

pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6              Installed

Therefore I asked whether it i possible to uninstall pax-web-http-jetty.

 

2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.

 

Webconsole is listed in the bootFeatures (see above). My application consists of a lot of bundles but the one with the UI is a WAB (war packaging with manifest which includes: Web-ContextPath: /main). Primefaces and JSF are wired using the Require-Bundle header in manifest:

<Require-Bundle>

javax.faces-api,

org.primefaces

</Require-Bundle>

All the bundles and their dependencies (JSF, primefaces etc.) are listed in a feature.xml file which I place in the deploy directory in Karaf. The application loads and works fine. I am just having problem with the webconsole.

I unfortunately cannot share the code of the bundles. But I am happy to provide more information if necessary.

 

Let me know if you need more information.

Best regards

Martin Zukal

 

 

From: Grzegorz Grzybek <gr.grzybek@gmail.com <ma...@gmail.com> > 
Sent: Thursday, November 3, 2022 9:56 AM
To: user@karaf.apache.org <ma...@karaf.apache.org> ; Martin Zukal <martin.zukal@stabilit.ch <ma...@stabilit.ch> >
Subject: Re: webconsole and pax-web-http-tomcat

 

Hello

 

First - which Karaf version are you using?

Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.

 

Pax Web 8 is highly refactored major version of the project where we've tried to make sure that things like JSF (which rely heavily on ServletContainerInitializers) work smoothly.

There are dedicated tests both for webconsole and for JSF (MyFaces, Primefaces) and even for techs like Vaadin.

 

Check the JSF samples at https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf

 

Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?

 

You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.

 

2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.

 

kind regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 09:46 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hello everyone,
I am experiencing strange behavior with webconsole of Apache Karaf. I have an application deployed using a custom feature file in Apache Karaf. The application is based on Spring and is using Primefaces (and Mojarra JSF implementation version 2.2.15). When I run it with standard war feature (which by default installs pax-web-http-jetty) I am getting the following error messages in the log file:
Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI? 
Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f <ma...@5005965f>  because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?
However, the webconsole works perfectly in this case.
When I install the pax-web-http-tomcat feature the above mentioned error messages are gone but the webconsole is not working properly (the resources from res and lib are not loaded so I see allmost an empty page - see attachment).
I can see the following errors in the log file:

[2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10 o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable 
[2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10 o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] javax.servlet.UnavailableException: No static resources were found
        at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
        at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
        at javax.servlet.GenericServlet.init(GenericServlet.java:180)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
        at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
        at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
        at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .SocketProcessorBase.run(SocketProcessorBase.java:49)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
        at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
        at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
        at java.base/sun.nio.ch <http://sun.nio.ch> .AsynchronousChannelGroupImpl$1.run(Unknown Source)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Unknown Source)


Does it mean that the webconsole works only with pax-web-http-jetty? 

I can also see that both pax-web-http-jetty and pax-web-http-tomcat features are installed. Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
Any help with this issue will be appreciated.

Best regards
Martin Zukal






Re: webconsole and pax-web-http-tomcat

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Hi

about "pax-web-http-jetty", just get rid of
"<startupFeature>http</startupFeature>" because it's quite
legacy/convenient feature defined like this:

    <feature name="http" description="Transition feature for backward
compatibility" version="8.0.6">
        <feature>pax-web-http</feature>
    </feature>

and "pax-web-http" (notice that the feature name doesn't specify the
runtime to choose: jetty, tomcat or undertow) is:

    <feature name="pax-web-http" description="Pax Web OSGi HTTP Service"
version="8.0.6">
        <feature>pax-web-http-jetty</feature>
        <bundle
start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/4.4.1</bundle>
        <capability>http-service;provider:=pax-http</capability>
        <conditional>
            <condition>webconsole</condition>
            <bundle
start-level="30">mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.http/4.4.1</bundle>
        </conditional>
    </feature>

So you just need "pax-web-http-tomcat" (or "pax-web-http-jetty" or
"pax-web-http-undertow") specified explicitly.

*Webconsole is listed in the bootFeatures (see above). […]*
>

Actually, it's specified in <startupFeatures> :) that's big difference -
you're effectively doing (karaf-maven-plugin is doing) the resolution at
build time, so you simply get a big list of bundles inside
etc/startup.properties. This makes uninstalling the features a bit harder.
In other words - "<startupFeatures>" vs. "<bootFeatures>"  is like bundle
vs feature. With "startup features" you're "flattening" the features into a
list of bundles. It may speed things up, but generally I'm not recommending
it.

And finally, to see what's the problem, you can increase logging level of
"org.ops4j.pax.web.extender.war" (to DEBUG or even TRACE) to get a lot of
information about ServletContainerInitializers and annotated classes being
discovered.

I still hope that removing pax-web-http-jetty (by not including "http"
feature) will solve your problem.

regards
Grzegorz Grzybek


czw., 3 lis 2022 o 10:36 Martin Zukal via user <us...@karaf.apache.org>
napisał(a):

> Hello and thank you for a quick response!
>
> Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1
> which comes with Pax Web 8.0.6.
>
> I looked at the samples and they already helped me a lot but I will look
> at them once again, maybe I missed something. Basically, I followed:
> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml
>
>
>
>
>
> *You actually don't uninstall features using karaf-maven-plugin - you
> declare features you want, and karaf-maven-plugin will put the features
> into boot features (etc/org.apache.karaf.features.cfg - when in runtime
> scope) or into startup bundles (etc/startup.properties - when in compile
> scope). So definitely you have to fix your <configuration> for
> karaf-maven-plugin.*
>
>
>
> I have the following dependencies in my pom.xml (used to build custom
> Karaf distribution)
>
> <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>framework</artifactId>
>
>
> <version>${karaf.version}</version>
>
>                                                <type>kar</type>
>
>                                </dependency>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>framework</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <classifier>features</classifier>
>
>                                                <type>xml</type>
>
>                                                <scope>runtime</scope>
>
>                                </dependency>
>
>                                <dependency>
>
>
> <groupId>org.apache.karaf.features</groupId>
>
>
> <artifactId>standard</artifactId>
>
>
> <version>${karaf.version}</version>
>
>
> <classifier>features</classifier>
>
>                                                <type>xml</type>
>
>                                                <scope>runtime</scope>
>
>                                </dependency>
>
> And I listed the following features in startupFeatures:
>
> <startupFeatures>
>
>
> <startupFeature>framework-logback</startupFeature>
>
>
> <startupFeature>instance</startupFeature>
>
>
> <startupFeature>package</startupFeature>
>
>
> <startupFeature>log</startupFeature>
>
>
> <startupFeature>ssh</startupFeature>
>
>
> <startupFeature>system</startupFeature>
>
>
> <startupFeature>feature</startupFeature>
>
>
> <startupFeature>shell</startupFeature>
>
>
> <startupFeature>management</startupFeature>
>
>
> <startupFeature>service</startupFeature>
>
>
> <startupFeature>jaas</startupFeature>
>
>
> <startupFeature>deployer</startupFeature>
>
>
> <startupFeature>diagnostic</startupFeature>
>
>
> <startupFeature>wrap</startupFeature>
>
>
> <startupFeature>bundle</startupFeature>
>
>
> <startupFeature>config</startupFeature>
>
>
> <startupFeature>http</startupFeature>
>
>
> <startupFeature>webconsole</startupFeature>
>
>
> <startupFeature>pax-web-http-tomcat</startupFeature>
>
>
> </startupFeatures>
>
> This results in the above declared features listed in bootFeatures in
> etc/org.apache.karaf.features.cfg.
>
> When I start Karaf with this set up without my application the webconsole
> works fine and I can see the following on the features page:
>
> pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6
> Installed
>
> pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6
> Installed
>
> Therefore I asked whether it i possible to uninstall pax-web-http-jetty.
>
>
>
> *2nd - how do you install the webconsole and/or your JSF bundle? Are then
> installed as WAR (WAB) files? May I see them? I don't claim that the
> problem is only at your side - maybe Pax Web didn't anticpate some setup
> and I'd be happy to help solving this problem.*
>
>
>
> Webconsole is listed in the bootFeatures (see above). My application
> consists of a lot of bundles but the one with the UI is a WAB (war
> packaging with manifest which includes: Web-ContextPath: /main). Primefaces
> and JSF are wired using the Require-Bundle header in manifest:
>
> <Require-Bundle>
>
> javax.faces-api,
>
> org.primefaces
>
> </Require-Bundle>
>
> All the bundles and their dependencies (JSF, primefaces etc.) are listed
> in a feature.xml file which I place in the deploy directory in Karaf. The
> application loads and works fine. I am just having problem with the
> webconsole.
>
> I unfortunately cannot share the code of the bundles. But I am happy to
> provide more information if necessary.
>
>
>
> Let me know if you need more information.
>
> Best regards
>
> Martin Zukal
>
>
>
>
>
> *From:* Grzegorz Grzybek <gr...@gmail.com>
> *Sent:* Thursday, November 3, 2022 9:56 AM
> *To:* user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
> *Subject:* Re: webconsole and pax-web-http-tomcat
>
>
>
> Hello
>
>
>
> First - which Karaf version are you using?
>
> Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.
>
>
>
> Pax Web 8 is highly refactored major version of the project where we've
> tried to make sure that things like JSF (which rely heavily on
> ServletContainerInitializers) work smoothly.
>
> There are dedicated tests both for webconsole and for JSF (MyFaces,
> Primefaces) and even for techs like Vaadin.
>
>
>
> Check the JSF samples at
> https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf
>
>
>
> *Is it possible that the behavior is caused by conflict between
> pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall
> pax-web-http-jetty using karaf-maven-plugin?*
>
>
>
> You actually don't uninstall features using karaf-maven-plugin - you
> declare features you want, and karaf-maven-plugin will put the features
> into boot features (etc/org.apache.karaf.features.cfg - when in runtime
> scope) or into startup bundles (etc/startup.properties - when in compile
> scope). So definitely you have to fix your <configuration> for
> karaf-maven-plugin.
>
>
>
> 2nd - how do you install the webconsole and/or your JSF bundle? Are then
> installed as WAR (WAB) files? May I see them? I don't claim that the
> problem is only at your side - maybe Pax Web didn't anticpate some setup
> and I'd be happy to help solving this problem.
>
>
>
> kind regards
>
> Grzegorz Grzybek
>
>
>
> czw., 3 lis 2022 o 09:46 Martin Zukal via user <us...@karaf.apache.org>
> napisał(a):
>
> Hello everyone,
> I am experiencing strange behavior with webconsole of Apache Karaf. I have
> an application deployed using a custom feature file in Apache Karaf. The
> application is based on Spring and is using Primefaces (and Mojarra JSF
> implementation version 2.2.15). When I run it with standard war feature
> (which by default installs pax-web-http-jetty) I am getting the following
> error messages in the log file:
> Unable to obtain InjectionProvider from init time FacesContext. Does this
> container implement the Mojarra Injection SPI?
> Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f
> because no InjectionProvider can be found. Does this container implement
> the Mojarra Injection SPI?
> However, the webconsole works perfectly in this case.
> When I install the pax-web-http-tomcat feature the above mentioned error
> messages are gone but the webconsole is not working properly (the resources
> from res and lib are not loaded so I see allmost an empty page - see
> attachment).
> I can see the following errors in the log file:
>
> [2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10
> o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking
> servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable
> [2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10
> o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate
> exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469]
> javax.servlet.UnavailableException: No static resources were found
>         at
> org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
>         at
> org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
>         at javax.servlet.GenericServlet.init(GenericServlet.java:180)
>         at
> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
>         at
> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
>         at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>         at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
>         at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
>         at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>         at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
>         at org.apache.tomcat.util.net
> .SocketProcessorBase.run(SocketProcessorBase.java:49)
>         at org.apache.tomcat.util.net
> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
>         at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
>         at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
>         at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown
> Source)
>         at
> org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>         at
> org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>         at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>         at java.base/java.lang.Thread.run(Unknown Source)
>
>
> Does it mean that the webconsole works only with pax-web-http-jetty?
>
> I can also see that both pax-web-http-jetty and pax-web-http-tomcat
> features are installed. Is it possible that the behavior is caused by
> conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way
> how to uninstall pax-web-http-jetty using karaf-maven-plugin?
> Any help with this issue will be appreciated.
>
> Best regards
> Martin Zukal
>
>
>

RE: webconsole and pax-web-http-tomcat

Posted by Martin Zukal via user <us...@karaf.apache.org>.
Hello and thank you for a quick response!

Sorry, I forgot to include the versions. I am running Apache Karaf 4.4.1 which comes with Pax Web 8.0.6.

I looked at the samples and they already helped me a lot but I will look at them once again, maybe I missed something. Basically, I followed: https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.11/samples/samples-jsf/war-primefaces-wired/pom.xml

 

 

You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.

 

I have the following dependencies in my pom.xml (used to build custom Karaf distribution)

<dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <type>kar</type>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>framework</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

                               <dependency>

                                               <groupId>org.apache.karaf.features</groupId>

                                               <artifactId>standard</artifactId>

                                               <version>${karaf.version}</version>

                                               <classifier>features</classifier>

                                               <type>xml</type>

                                               <scope>runtime</scope>

                               </dependency>

And I listed the following features in startupFeatures:

<startupFeatures>

                                                                                              <startupFeature>framework-logback</startupFeature>

                                                                                              <startupFeature>instance</startupFeature>

                                                                                              <startupFeature>package</startupFeature>

                                                                                              <startupFeature>log</startupFeature>

                                                                                              <startupFeature>ssh</startupFeature>

                                                                                              <startupFeature>system</startupFeature>

                                                                                              <startupFeature>feature</startupFeature>

                                                                                              <startupFeature>shell</startupFeature>

                                                                                              <startupFeature>management</startupFeature>

                                                                                              <startupFeature>service</startupFeature>

                                                                                              <startupFeature>jaas</startupFeature>

                                                                                              <startupFeature>deployer</startupFeature>

                                                                                              <startupFeature>diagnostic</startupFeature>

                                                                                              <startupFeature>wrap</startupFeature>

                                                                                              <startupFeature>bundle</startupFeature>

                                                                                              <startupFeature>config</startupFeature>

                                                                                              <startupFeature>http</startupFeature>

                                                                                              <startupFeature>webconsole</startupFeature>

                                                                                              <startupFeature>pax-web-http-tomcat</startupFeature>

                                                                               </startupFeatures>

This results in the above declared features listed in bootFeatures in etc/org.apache.karaf.features.cfg.

When I start Karaf with this set up without my application the webconsole works fine and I can see the following on the features page:

pax-web-http-jetty         8.0.6      org.ops4j.pax.web-8.0.6              Installed

pax-web-http-tomcat    8.0.6      org.ops4j.pax.web-8.0.6              Installed

Therefore I asked whether it i possible to uninstall pax-web-http-jetty.

 

2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.

 

Webconsole is listed in the bootFeatures (see above). My application consists of a lot of bundles but the one with the UI is a WAB (war packaging with manifest which includes: Web-ContextPath: /main). Primefaces and JSF are wired using the Require-Bundle header in manifest:

<Require-Bundle>

javax.faces-api,

org.primefaces

</Require-Bundle>

All the bundles and their dependencies (JSF, primefaces etc.) are listed in a feature.xml file which I place in the deploy directory in Karaf. The application loads and works fine. I am just having problem with the webconsole.

I unfortunately cannot share the code of the bundles. But I am happy to provide more information if necessary.

 

Let me know if you need more information.

Best regards

Martin Zukal

 

 

From: Grzegorz Grzybek <gr...@gmail.com> 
Sent: Thursday, November 3, 2022 9:56 AM
To: user@karaf.apache.org; Martin Zukal <ma...@stabilit.ch>
Subject: Re: webconsole and pax-web-http-tomcat

 

Hello

 

First - which Karaf version are you using?

Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.

 

Pax Web 8 is highly refactored major version of the project where we've tried to make sure that things like JSF (which rely heavily on ServletContainerInitializers) work smoothly.

There are dedicated tests both for webconsole and for JSF (MyFaces, Primefaces) and even for techs like Vaadin.

 

Check the JSF samples at https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf

 

Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?

 

You actually don't uninstall features using karaf-maven-plugin - you declare features you want, and karaf-maven-plugin will put the features into boot features (etc/org.apache.karaf.features.cfg - when in runtime scope) or into startup bundles (etc/startup.properties - when in compile scope). So definitely you have to fix your <configuration> for karaf-maven-plugin.

 

2nd - how do you install the webconsole and/or your JSF bundle? Are then installed as WAR (WAB) files? May I see them? I don't claim that the problem is only at your side - maybe Pax Web didn't anticpate some setup and I'd be happy to help solving this problem.

 

kind regards

Grzegorz Grzybek

 

czw., 3 lis 2022 o 09:46 Martin Zukal via user <user@karaf.apache.org <ma...@karaf.apache.org> > napisał(a):

Hello everyone,
I am experiencing strange behavior with webconsole of Apache Karaf. I have an application deployed using a custom feature file in Apache Karaf. The application is based on Spring and is using Primefaces (and Mojarra JSF implementation version 2.2.15). When I run it with standard war feature (which by default installs pax-web-http-jetty) I am getting the following error messages in the log file:
Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI? 
Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f <ma...@5005965f>  because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?
However, the webconsole works perfectly in this case.
When I install the pax-web-http-tomcat feature the above mentioned error messages are gone but the webconsole is not working properly (the resources from res and lib are not loaded so I see allmost an empty page - see attachment).
I can see the following errors in the log file:

[2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10 o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable 
[2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10 o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] javax.servlet.UnavailableException: No static resources were found
        at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
        at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
        at javax.servlet.GenericServlet.init(GenericServlet.java:180)
        at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
        at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
        at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
        at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .SocketProcessorBase.run(SocketProcessorBase.java:49)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
        at org.apache.tomcat.util.net <http://org.apache.tomcat.util.net> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
        at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
        at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
        at java.base/sun.nio.ch <http://sun.nio.ch> .AsynchronousChannelGroupImpl$1.run(Unknown Source)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Unknown Source)


Does it mean that the webconsole works only with pax-web-http-jetty? 

I can also see that both pax-web-http-jetty and pax-web-http-tomcat features are installed. Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
Any help with this issue will be appreciated.

Best regards
Martin Zukal







Re: webconsole and pax-web-http-tomcat

Posted by Grzegorz Grzybek <gr...@gmail.com>.
Hello

First - which Karaf version are you using?
Assuming it's Karaf 4.4.x with Pax Web 8.0.x I can try helping.

Pax Web 8 is highly refactored major version of the project where we've
tried to make sure that things like JSF (which rely heavily on
ServletContainerInitializers) work smoothly.
There are dedicated tests both for webconsole and for JSF (MyFaces,
Primefaces) and even for techs like Vaadin.

Check the JSF samples at
https://github.com/ops4j/org.ops4j.pax.web/tree/web-8.0.11/samples/samples-jsf

*Is it possible that the behavior is caused by conflict between
> pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall
> pax-web-http-jetty using karaf-maven-plugin?*
>

You actually don't uninstall features using karaf-maven-plugin - you
declare features you want, and karaf-maven-plugin will put the features
into boot features (etc/org.apache.karaf.features.cfg - when in runtime
scope) or into startup bundles (etc/startup.properties - when in compile
scope). So definitely you have to fix your <configuration> for
karaf-maven-plugin.

2nd - how do you install the webconsole and/or your JSF bundle? Are then
installed as WAR (WAB) files? May I see them? I don't claim that the
problem is only at your side - maybe Pax Web didn't anticpate some setup
and I'd be happy to help solving this problem.

kind regards
Grzegorz Grzybek

czw., 3 lis 2022 o 09:46 Martin Zukal via user <us...@karaf.apache.org>
napisał(a):

> Hello everyone,
> I am experiencing strange behavior with webconsole of Apache Karaf. I have
> an application deployed using a custom feature file in Apache Karaf. The
> application is based on Spring and is using Primefaces (and Mojarra JSF
> implementation version 2.2.15). When I run it with standard war feature
> (which by default installs pax-web-http-jetty) I am getting the following
> error messages in the log file:
> Unable to obtain InjectionProvider from init time FacesContext. Does this
> container implement the Mojarra Injection SPI?
> Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f
> because no InjectionProvider can be found. Does this container implement
> the Mojarra Injection SPI?
> However, the webconsole works perfectly in this case.
> When I install the pax-web-http-tomcat feature the above mentioned error
> messages are gone but the webconsole is not working properly (the resources
> from res and lib are not loaded so I see allmost an empty page - see
> attachment).
> I can see the following errors in the log file:
>
> [2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10
> o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking
> servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable
> [2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10
> o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate
> exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469]
> javax.servlet.UnavailableException: No static resources were found
>         at
> org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
>         at
> org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
>         at javax.servlet.GenericServlet.init(GenericServlet.java:180)
>         at
> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
>         at
> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
>         at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
>         at
> org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
>         at
> org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
>         at
> org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
>         at
> org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
>         at org.apache.tomcat.util.net
> .SocketProcessorBase.run(SocketProcessorBase.java:49)
>         at org.apache.tomcat.util.net
> .AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
>         at org.apache.tomcat.util.net
> .Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
>         at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
>         at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
>         at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown
> Source)
>         at
> org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
>         at
> org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
>         at
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
>         at java.base/java.lang.Thread.run(Unknown Source)
>
>
> Does it mean that the webconsole works only with pax-web-http-jetty?
>
> I can also see that both pax-web-http-jetty and pax-web-http-tomcat
> features are installed. Is it possible that the behavior is caused by
> conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way
> how to uninstall pax-web-http-jetty using karaf-maven-plugin?
> Any help with this issue will be appreciated.
>
> Best regards
> Martin Zukal
>
>
>
>

webconsole and pax-web-http-tomcat

Posted by Martin Zukal via user <us...@karaf.apache.org>.
Hello everyone,
I am experiencing strange behavior with webconsole of Apache Karaf. I have an application deployed using a custom feature file in Apache Karaf. The application is based on Spring and is using Primefaces (and Mojarra JSF implementation version 2.2.15). When I run it with standard war feature (which by default installs pax-web-http-jetty) I am getting the following error messages in the log file:
Unable to obtain InjectionProvider from init time FacesContext. Does this container implement the Mojarra Injection SPI? 
Unable to inject com.sun.faces.application.ApplicationFactoryImpl@5005965f because no InjectionProvider can be found. Does this container implement the Mojarra Injection SPI?
However, the webconsole works perfectly in this case.
When I install the pax-web-http-tomcat feature the above mentioned error messages are gone but the webconsole is not working properly (the resources from res and lib are not loaded so I see allmost an empty page - see attachment).
I can see the following errors in the log file:

[2022-11-03 09:29:26.358] INFO  tp-nio2-0.0.0.0-8080-exec-10 o.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/]  Marking servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] as unavailable 
[2022-11-03 09:29:26.360] ERROR tp-nio2-0.0.0.0-8080-exec-10 o.a.c.c.C.[.[.[/].[default-56ee4de3-f9f8-44c8-96ea-4580393e6469] Allocate exception for servlet [default-56ee4de3-f9f8-44c8-96ea-4580393e6469] javax.servlet.UnavailableException: No static resources were found
	at org.apache.catalina.servlets.DefaultServlet.init(DefaultServlet.java:384)
	at org.ops4j.pax.web.service.tomcat.internal.web.TomcatResourceServlet.init(TomcatResourceServlet.java:87)
	at javax.servlet.GenericServlet.init(GenericServlet.java:180)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1164)
	at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:804)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:128)
	at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardWrapperValve.invoke(PaxWebStandardWrapperValve.java:50)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.ops4j.pax.web.service.tomcat.internal.PaxWebStandardContextValve.invoke(PaxWebStandardContextValve.java:98)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
	at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1701)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at org.apache.tomcat.util.net.AbstractEndpoint.processSocket(AbstractEndpoint.java:1190)
	at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:633)
	at org.apache.tomcat.util.net.Nio2Endpoint$Nio2SocketWrapper$2.completed(Nio2Endpoint.java:611)
	at java.base/sun.nio.ch.Invoker.invokeUnchecked(Unknown Source)
	at java.base/sun.nio.ch.Invoker$2.run(Unknown Source)
	at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(Unknown Source)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Unknown Source)


Does it mean that the webconsole works only with pax-web-http-jetty? 

I can also see that both pax-web-http-jetty and pax-web-http-tomcat features are installed. Is it possible that the behavior is caused by conflict between pax-web-http-jetty and pax-web-http-tomcat? Is there a way how to uninstall pax-web-http-jetty using karaf-maven-plugin?
Any help with this issue will be appreciated.

Best regards
Martin Zukal




RE: Aspectj in Apache Karaf 4.4.1

Posted by Martin Zukal <ma...@stabilit.ch>.
Hi JB,
No I did not try that, but I believe it would work. I was able to find a work around with Spring AOP. I was able to get the aspects working when I defined the aspects in XML configuration instead of using the @Aspect annotation.
However, Spring AOP approach as well as embeding AspectJ in the bundle have the problem that it will work just within that one bundle. I need to be able to weave also classes from other bundles. And as far as I know there is no other solution than load-time weaving with AspectJ provided by the framework itself (using the hooks).
Or am I missing something and there is some other was how to achieve that?
BR
Martin

-----Original Message-----
From: Jean-Baptiste Onofré <jb...@nanthrax.net> 
Sent: Wednesday, September 7, 2022 10:06 AM
To: user@karaf.apache.org
Subject: Re: Aspectj in Apache Karaf 4.4.1

Hi,

I don't use aspectj in Karaf. So, unfortunately, I can't help so much.

Did you try to embed aspectj in your spring bundle ?

Regards
JB

On Mon, Sep 5, 2022 at 5:10 PM Martin Zukal <ma...@stabilit.ch> wrote:
>
> Hello everyone!
>
> I am sorry to reply to my own email but I would really like to know whether there is somebody who was able to get aspectj and load-time weaving running with Apache Karaf.
>
> I am really stuck on this so any hint would be hihgly appreciated!
>
> Best Regards
>
> Martin Zukal
>
>
>
>
>
> From: Martin Zukal <ma...@stabilit.ch>
> Sent: Saturday, August 27, 2022 11:42 AM
> To: 'user@karaf.apache.org' <us...@karaf.apache.org>
> Subject: Aspectj in Apache Karaf 4.4.1
>
>
>
> Hello everyone!
>
> I am trying to enable aspectj in Apache Karaf version 4.4.1 and I am unable to get it to work. I have a project based on Spring which I want to run in Apache Karaf. This project contains the aspects and includes the following lines in the configuration:
>
> <context:load-time-weaver aspectj-weaving="on" />
>
> <aop:aspectj-autoproxy />
>
> Which is why I need aspectj in the runtime.
>
> What I should probably also mention is that the project uses Gemini Blueprint version 3.0.0.M01 to publish the Spring services into the OSGi context.
>
>
>
> I was not able to find any recent tutorial how to enable aspects in Apache Karaf so I followed this blog post: http://dywicki.pl/2011/11/running-aspects-under-osgi-4-2-with-karaf/ and adapted the procedure slightly. What I did so far is:
>
> Changed the framework from felix to equinox Placed the three bundles 
> (org.eclipse.equinox.weaving.aspectj, 
> org.eclipse.equinox.weaving.caching and 
> org.eclipse.equinox.weaving.hook) into the system directory Added 
> entries for the above mentioned bundles to startup.properties
>
> Apache karaf starts fine with the above described configuration and I can see all weaving bundles as active in the console (org.eclipse.equinox.weaving.hook is a fragment so there it says fragment).
>
>
>
> However, when I try to deploy the bundle with my Spring project I get the following exception:
>
> org.springframework.beans.factory.BeanCreationException: Error 
> creating bean with name 
> 'org.springframework.context.config.internalAspectJWeavingEnabler': 
> Initialization of bean failed; nested exception is 
> org.springframework.beans.factory.BeanCreationException: Error 
> creating bean with name 'loadTimeWeaver': Initialization of bean 
> failed; nested exception is java.lang.IllegalStateException: 
> ClassLoader 
> [org.eclipse.gemini.blueprint.util.BundleDelegatingClassLoader] does 
> NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify 
> a custom LoadTimeWeaver or start your Java virtual machine with 
> Spring's agent: -javaagent:spring-instrument-{version}.jar
>
> I tried to start Apache Karaf with the -javaagent option but it did not help.
>
> I am coming from Eclipse Virgo and the aspects were working there 
> quite fine. One of the settings which was needed to add was
>
> osgi.framework.extensions = org.eclipse.equinox.weaving.hook.
>
> Is there a possibility how to add this setting to Apache Karaf?
>
>
>
> Is there any recent tutorial how to get aspects working in Apache Karaf? I would really appreciate any help with this topic!
>
> Best Regards
>
> Martin Zukal




Re: Aspectj in Apache Karaf 4.4.1

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

I don't use aspectj in Karaf. So, unfortunately, I can't help so much.

Did you try to embed aspectj in your spring bundle ?

Regards
JB

On Mon, Sep 5, 2022 at 5:10 PM Martin Zukal <ma...@stabilit.ch> wrote:
>
> Hello everyone!
>
> I am sorry to reply to my own email but I would really like to know whether there is somebody who was able to get aspectj and load-time weaving running with Apache Karaf.
>
> I am really stuck on this so any hint would be hihgly appreciated!
>
> Best Regards
>
> Martin Zukal
>
>
>
>
>
> From: Martin Zukal <ma...@stabilit.ch>
> Sent: Saturday, August 27, 2022 11:42 AM
> To: 'user@karaf.apache.org' <us...@karaf.apache.org>
> Subject: Aspectj in Apache Karaf 4.4.1
>
>
>
> Hello everyone!
>
> I am trying to enable aspectj in Apache Karaf version 4.4.1 and I am unable to get it to work. I have a project based on Spring which I want to run in Apache Karaf. This project contains the aspects and includes the following lines in the configuration:
>
> <context:load-time-weaver aspectj-weaving="on" />
>
> <aop:aspectj-autoproxy />
>
> Which is why I need aspectj in the runtime.
>
> What I should probably also mention is that the project uses Gemini Blueprint version 3.0.0.M01 to publish the Spring services into the OSGi context.
>
>
>
> I was not able to find any recent tutorial how to enable aspects in Apache Karaf so I followed this blog post: http://dywicki.pl/2011/11/running-aspects-under-osgi-4-2-with-karaf/ and adapted the procedure slightly. What I did so far is:
>
> Changed the framework from felix to equinox
> Placed the three bundles (org.eclipse.equinox.weaving.aspectj, org.eclipse.equinox.weaving.caching and org.eclipse.equinox.weaving.hook) into the system directory
> Added entries for the above mentioned bundles to startup.properties
>
> Apache karaf starts fine with the above described configuration and I can see all weaving bundles as active in the console (org.eclipse.equinox.weaving.hook is a fragment so there it says fragment).
>
>
>
> However, when I try to deploy the bundle with my Spring project I get the following exception:
>
> org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.config.internalAspectJWeavingEnabler': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadTimeWeaver': Initialization of bean failed; nested exception is java.lang.IllegalStateException: ClassLoader [org.eclipse.gemini.blueprint.util.BundleDelegatingClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:spring-instrument-{version}.jar
>
> I tried to start Apache Karaf with the -javaagent option but it did not help.
>
> I am coming from Eclipse Virgo and the aspects were working there quite fine. One of the settings which was needed to add was
>
> osgi.framework.extensions = org.eclipse.equinox.weaving.hook.
>
> Is there a possibility how to add this setting to Apache Karaf?
>
>
>
> Is there any recent tutorial how to get aspects working in Apache Karaf? I would really appreciate any help with this topic!
>
> Best Regards
>
> Martin Zukal