Since few days, I am playing around with apache felix. Everything works fine as it can be seen when lauching the lb command:
START LEVEL 2
ID|State |Level|Name
0|Active | 0|System Bundle (4.0.3)
1|Active | 2|Apache Felix Bundle Repository (1.6.6)
2|Active | 2|Apache Felix Configuration Admin Service (1.6.0)
3|Active | 2|Apache Felix Gogo Command (0.12.0)
4|Active | 2|Apache Felix Gogo Runtime (0.10.0)
5|Active | 2|Apache Felix Gogo Shell (0.10.0)
6|Active | 2|Apache Felix Http Bundle (2.2.0)
7|Active | 2|Apache Felix iPOJO (1.8.6)
8|Active | 2|Apache Felix iPOJO OSGi Junit Runner (1.0.0)
9|Active | 2|Apache Felix Shell Service (1.4.3)
10|Active | 2|Apache Felix Web Management Console (3.1.8)
11|Installed | 3|[Optimacs/OSGi] DataService - Hello World (1.1.0)
12|Active | 2|[Optimacs/OSGi] DataService Model (0.4.1.SNAPSHOT)
13|Active | 2|[Optimacs/OSGi] DataService Network API (0.4.1.SNAPSHOT)
14|Active | 2|[Optimacs/OSGi] DataService Container (0.4.1.SNAPSHOT)
According to this list, I can use the web management console. To this aim I have set the org.osgi.service.http.port option to 8080.
My problem occurs when I open my browser (Chrome, the latest version) and try accessing to the web console (url = http://localhost:8080/system/console). I get an error 102 (connection refused).
Is there any particular configuration step I have missed?
EDIT
Running inspect cap service through the gogo shell reports the following about the HttpService:
org.apache.felix.http.bundle [6] provides:
------------------------------------------
service; javax.servlet.http.HttpServlet with properties:
http.felix.dispatcher = org.apache.felix.http.base.internal.DispatcherServlet
service.description = Dispatcher for bridged request handling
service.id = 20
service.vendor = The Apache Software Foundation
service; java.util.EventListener with properties:
http.felix.dispatcher = org.apache.felix.http.base.internal.EventDispatcher
service.description = Dispatcher for bridged HttpSession events
service.id = 21
service.vendor = The Apache Software Foundation
There is no indication about the used port unfortunately.
The issue has been resolved thanks to Neil's comment:
I wonder if the HttpService is present, could you do inspect cap service from the shell and scan through for HttpService? If it's there it should also report what port number it is using.
Related
Using RedHat Fuse 7.5 for Apache Karaf platform on Windows 10. I'm defining the feature shown below:
...
<feature name="customers-data" version="${project.version}">
<feature>transaction</feature>
<feature>jndi</feature>
<feature>pax-jdbc-config</feature>
<feature>pax-jdbc-oracle</feature>
<feature>pax-jdbc-pool-dbcp2</feature>
<feature>jdbc</feature>
<feature dependency="true">aries-blueprint</feature>
<feature>jpa</feature>
<feature>hibernate</feature>
<bundle>...</bundle>
</feature>
...
Adding the the new repo works as expected but trying to install the feature:
karaf#root()> feature:install customers-data
raises the following exception:
2019-12-12 17:43:02,385 | WARN | ownloader-5-thread-7 | o.o.p.u.m.i.AetherBasedResolver | 5 - org.ops4j.pax.url.mvn - 2.6.1 | Error resolving artifact
org.apache.aries.jpa.javax.persistence:javax.persistence_2.1:jar:2.7.2: [Could not transfer artifact org.apache.aries.jpa.javax.persistence:javax.persistence_2.1:jar:2.7.2 from/to maven.central.repo
(https://repo1.maven.org/maven2/): Connect to repo1.maven.org:443 [repo1.maven.org/151.101.36.209] failed: connect timed out, Could not transfer artifact
org.apache.aries.jpa.javax.persistence:javax.persistence_2.1:jar:2.7.2 from/to redhat.ga.repo
(https://maven.repository.redhat.com/ga/): Connect to maven.repository.redhat.com:443
[maven.repository.redhat.com/23.60.31.183] failed: connect timed out
Looking up the features I got this:
karaf#root()> feature:list | grep aries-jpa
jpa | 2.7.2 | | Uninstalled | aries-jpa-2.7.2 | OSGi Persistence Container
karaf#root()>
So the feature aries-jpa-2.7.2 is registered. Trying to install it:
karaf#root()> feature:install jpa
raises the same exception as mentioned above.
Could any one please shad some light here ?
Many thanks in advance.
Kind regards,
Nicolas
The issue was caused by the fact that Karaf doesn't use the local maven install and its settings but its own one. So, when behind an HTTP proxy, as it was my case, one needs either to configure Karaf to use the HTTP proxy or to tell it to use the local maven settings. This happens in $KARAF_HOME/etc/org.ops4j.pax.url.mvn.cfg file.
I am using Apache Karaf 4.1.1 and Karaf Cellar. I have written two bundles. The first bundle provides a service of type ITrackerManager. The second bundle has a component that references ITrackerManager. My end goal is to witness the component in the second bundle successfully get a reference to the ITrackerManager service in the first bundle which is running on a different node. This is all part of my exploration of distributed OSGi.
What is actually happening when I install that second bundle is that it gets installed but fails to activate due to missing the service reference. I must be conducting my test incorrectly. Any ideas on how I would go about demonstrating my end goal; component in bundle on Node B successfully uses service on Node A?
Here is how I have run my test so far.
Node A
karaf#root()> cluster:node-list
| Id | Alias | Host Name | Port
--+-------------------+-------+--------------+-----
x | 159.4.251.58:5701 | | 159.4.251.58 | 5701
| 159.4.251.58:5702 | | 159.4.251.58 | 5702
Node B
karaf#root()> cluster:node-list
| Id | Alias | Host Name | Port
--+-------------------+-------+--------------+-----
| 159.4.251.58:5701 | | 159.4.251.58 | 5701
x | 159.4.251.58:5702 | | 159.4.251.58 | 5702
So far so good. I am running two karaf instances on my computer. Both instances see each other. Now I want to install that first bundle onto Node A ONLY. To accomplish that, I install the bundle into the cluster, then specifically remove it from Node B.
Node A
karaf#root()> cluster:bundle-install -s default mvn:myCompany/dosgi-example-part1/1.0-SNAPSHOT
karaf#root()> cluster:bundle-list default
Bundles in cluster group default
ID | State | Lvl | Located | Blocked | Version | Name
---+----------+-----+---------------+---------+----------------+--------------------------------------------------------------
0 | Active | | cluster/local | | 5.6.2 | System Bundle
...
67 | Active | | cluster/local | | 1.0.0.SNAPSHOT | Distributed OSGi Example Part 1
karaf#root()> cluster:service-list
Service Class | Provider Node
--------------------------+------------------
myCompany.ITrackerManager | 159.4.251.58:5701
| 159.4.251.58:5702
Still looking good. My bundle is in the cluster, is local on Node A (and Node B at this point), and the service is recognized by the cluster and is available on both Node A and Node B. Now to remove the bundle from Node B.
Node B
karaf#root()> cluster:bundle-list default
Bundles in cluster group default
ID | State | Lvl | Located | Blocked | Version | Name
---+----------+-----+---------------+---------+----------------+-------------------------------------------------------------
67 | Active | | cluster/local | | 1.0.0.SNAPSHOT | Distributed OSGi Example Part 1
karaf#root()> bundle:list
START LEVEL 100 , List Threshold: 50
ID | State | Lvl | Version | Name
---+--------+-----+----------------+-----------------------------------------------
75 | Active | 80 | 1.0.0.SNAPSHOT | Distributed OSGi Example Part 1
karaf#root()> bundle:uninstall 75
karaf#root()> cluster:bundle-list default
Bundles in cluster group default
ID | State | Lvl | Located | Blocked | Version | Name
---+----------+-----+---------------+---------+----------------+--------------------------------------------------------------
67 | Active | | cluster | | 1.0.0.SNAPSHOT | Distributed OSGi Example Part 1
karaf#root()> cluster:service-list
Service Class | Provider Node
--------------------------+------------------
myCompany.ITrackerManager | 159.4.251.58:5701
Excellent. The first bundle has been removed from Node B but still shows up as being in the cluster. Both nodes agree that my service is only available on Node A now (since the bundle was removed from Node B). Now I will load my second bundle on Node B only. This is where I run into problems. I don't load the second bundle using the cluster:bundle-install command because I don't want it ending up on Node A. So instead I install my second bundle using the normal bundle:install command. This results in an error about an unsatisfied reference.
Node B
karaf#root()> bundle:install -s mvn:otherCompany/dosgi-example-part2/1.0-SNAPSHOT
Bundle ID: 76
Error executing command: Error installing bundles:
Unable to start bundle mvn:otherCompany/dosgi-example-part2/1.0-SNAPSHOT: org.osgi.framework.BundleException: Unable to resolve otherCompany.dosgi-example-part2 [76](R 76.0): missing requirement [otherCompany.dosgi-example-part2 [76](R 76.0)] osgi.wiring.package; (&(osgi.wiring.package=myCompany)(version>=1.0.0)(!(version>=2.0.0))) Unresolved requirements: [[otherCompany.dosgi-example-part2 [76](R 76.0)] osgi.wiring.package; (&(osgi.wiring.package=myCompany)(version>=1.0.0)(!(version>=2.0.0)))]
karaf#root()> bundle:list
START LEVEL 100 , List Threshold: 50
ID | State | Lvl | Version | Name
---+-----------+-----+----------------+-----------------------------------------------------------------------------------------------------
76 | Installed | 80 | 1.0.0.SNAPSHOT | Distributed OSGi Example Part 2
So there it is. I install the second bundle on NodeB only, expecting that it is able to successfully use the required service which resides on Node A only. Unfortunately that does not happen. Instead I get error message stating there are unresolved requirements. It seems to behave as if DOSGI is not available. If I install both bundles on the same node, the second bundle activates without any errors. Any insights you may have would be appreciated.
My problem was two-fold.
Stuff to be sent over DOSGI needs to be serializable. In my case, I was calling a method on a remote service that took an argument. That argument was a class type defined in a common API. That class type was not serializable. Once I made it serializable, it starting getting different errors. Which brings me to...
Normal name space rules apply. I will elaborate below.
My API defined two interfaces.
ITracker
ITrackerManager
That API bundle was installed into the cluster so it is available on all nodes. My Service bundle had a concrete implementation of ITrackerManager. When that bundle is installed locally on Node A, the cluster:service-list command correctly shows that Node A has a service of type ITrackerManager.
My Client bundle has a concrete implementation of ITracker that had a reference to ITrackerManager which was installed on Node B. The first thing the ITracker instance did in its activate method was call ITrackerManager.addTracker(this). What should have happened was that the instance of ITracker on Node B provided itself to the ITrackerManager running on Node A. Initially this failed because ITracker was not serializable. Once that was solved, I started seeing classNotFound exceptions on Node A.
Node A was trying to deserialize the ITracker instance locally. It was attempting to deserailize a concrete class (TheirTracker) which was not defined locally, it was only defined on Node B in the client bundle. This failed.
So the normal namespace rules apply. Even though the client bundle on Node B has a reference to a service running in a bundle Node A, the service bundle in Node A cannot create (i.e. deserialize) an instance of a class that only exists in the client bundle on Node B.
I switched up my interfaces so that ITrackerManager method does not take an ITracker arguement. Instead it takes a string. Invoking that method over DOSGi works fine.
While I understand why this problem exists, this undermines a core capability I was hoping to use with DOSGi. I want clients to be able to register with a central controller which will actively control them. This won't work because even though the clients implement the interface the central controller is looking for, the specific serialization fails at the central controller. The client concrete classes exist in a namespace unknown to the central controller, hence the client cannot successfully pass itself to the central controller.
This must be a way to achieve what I am looking for in DSOGi without making each of the multiple clients an exported DSOGi service. Any ideas?
I'm working on JBossFuse 6.2, have a CXF endpoint for which I needed to setup some special properties through httpj:engine-factory configuration block. Upon trying that I hited this issue
MapMetadataImpl not found by org.apache.cxf.cxf-rt-transports-http-jetty
The error was the following
> ERROR | pool-43-thread-1 | BlueprintContainerImpl | 14 -
> org.apache.aries.blueprint.core - 1.4.2 | Unable to start blueprint
> container for bundle test-ws java.lang.NoClassDefFoundError:
> org/apache/aries/blueprint/reflect/MapMetadataImpl at
> org.apache.cxf.transport.http_jetty.blueprint.JettyServerEngineFactoryParser.parseEngineConnector(JettyServerEngineFactoryParser.java:110)
> at
> org.apache.cxf.transport.http_jetty.blueprint.JettyServerEngineFactoryParser.parse(JettyServerEngineFactoryParser.java:83)
It appeared when trying to add the httpj block for CXF definition.
<httpj:engine-factory bus="cxf">
<httpj:engine port="${port}" host="${host}">
<httpj:threadingParameters minThreads="${minThreads}" maxThreads="${maxThreads}"/>
</httpj:engine>
</httpj:engine-factory>
I tried the solution provided, in the referred posts that is installing the osgi bundle for Blueprint Core Compatibility.
osgi:install mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core.compatibility/1.0.0
However, after installing the bundle upon container start I get the following exception:
2016-06-22 11:01:13,279 | ERROR | 63859-1-thread-1 | DeploymentAgent | ?? | 83 - io.fabric8.fabric-agent - 1.2.0.redhat-133 | Unable to update agent
java.lang.IllegalStateException: Resource has no uri
at io.fabric8.agent.service.Deployer.getBundleInputStream(Deployer.java:1354)[83:io.fabric8.fabric-agent:1.2.0.redhat-133]
at io.fabric8.agent.service.Deployer.deploy(Deployer.java:714)[83:io.fabric8.fabric-agent:1.2.0.redhat-133]
at io.fabric8.agent.service.Agent.provision(Agent.java:348)[83:io.fabric8.fabric-agent:1.2.0.redhat-133]
at io.fabric8.agent.service.Agent.provision(Agent.java:194)[83:io.fabric8.fabric-agent:1.2.0.redhat-133]
at io.fabric8.agent.DeploymentAgent.doUpdate(DeploymentAgent.java:642)[83:io.fabric8.fabric-agent:1.2.0.redhat-133]
at io.fabric8.agent.DeploymentAgent$2.run(DeploymentAgent.java:256)[83:io.fabric8.fabric-agent:1.2.0.redhat-133]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_80]
at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_80]
at java.lang.Thread.run(Thread.java:745)[:1.7.0_80]
Has anybody ever applied the proposed solution in JbossFuse? I don't event understand that much why that exception is being fired.
Thanks in advanced!
I anybody falls into this, I got an answer from someone at Red Hat. The problem I was having is that I was on a Fabric environment, so I had to add the OSGi Blueprint Core Compatibility bundle to the Karaf profile in the Fabric. It can be done from the karaf console by running the following command
profile-edit --bundles mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core.compatibility/1.0.0 karaf 1.x
Where 1.x is current fabric version in use.
If you are NOT on a fabric environment, then the solution posted above should work just as is.
Hope this helps!
I downloaded the apache karaf 4.x and installed the 'war' feature and the karaf-doc bundle using following commands:
feature:install war
bundle:install -s mvn:org.apache.karaf/manual/4.0.0/war
but karaf failed to load that web bundle:
2016-01-17 17:16:36,167 | ERROR | pool-4-thread-1 | RegisterWebAppVisitorWC | 64 - org.ops4j.pax.web.pax-web-extender-war - 3.2.6 | Registration exception. Skipping.
java.lang.NoClassDefFoundError: javax/servlet/Filter
at java.lang.ClassLoader.defineClass1(Native Method)[:1.7.0_45]
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)[:1.7.0_45]
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.findClass(BundleWiringImpl.java:2279)
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1501)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_45]
at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1844)
at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:937)
at org.ops4j.pax.swissbox.core.BundleClassLoader.findClass(BundleClassLoader.java:176)
at org.ops4j.pax.swissbox.core.BundleClassLoader.loadClass(BundleClassLoader.java:194)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_45]
at org.ops4j.pax.web.extender.war.internal.RegisterWebAppVisitorHS.loadClass(RegisterWebAppVisitorHS.java:244)[64:org.ops4j.pax.web.pax-web-extender-war:3.2.6]
at org.ops4j.pax.web.extender.war.internal.RegisterWebAppVisitorWC.visit(RegisterWebAppVisitorWC.java:261)[64:org.ops4j.pax.web.pax-web-extender-war:3.2.6]
at org.ops4j.pax.web.extender.war.internal.model.WebApp.accept(WebApp.java:652)[64:org.ops4j.pax.web.pax-web-extender-war:3.2.6]
at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.register(WebAppPublisher.java:237)[64:org.ops4j.pax.web.pax-web-extender-war:3.2.6]
at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:182)[64:org.ops4j.pax.web.pax-web-extender-war:3.2.6]
at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:135)[64:org.ops4j.pax.web.pax-web-extender-war:3.2.6]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932)[karaf-org.osgi.core.jar:]
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:864)[karaf-org.osgi.core.jar:]
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[karaf-org.osgi.core.jar:]
at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)[karaf-org.osgi.core.jar:]
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:317)[karaf-org.osgi.core.jar:]
at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)[karaf-org.osgi.core.jar:]
at org.ops4j.pax.web.extender.war.internal.WebAppPublisher.publish(WebAppPublisher.java:101)[64:org.ops4j.pax.web.pax-web-extender-war:3.2.6]
at org.ops4j.pax.web.extender.war.internal.WebObserver.deploy(WebObserver.java:213)[64:org.ops4j.pax.web.pax-web-extender-war:3.2.6]
at org.ops4j.pax.web.extender.war.internal.WebObserver$1.doStart(WebObserver.java:175)[64:org.ops4j.pax.web.pax-web-extender-war:3.2.6]
at org.ops4j.pax.web.extender.war.internal.extender.SimpleExtension.start(SimpleExtension.java:58)[64:org.ops4j.pax.web.pax-web-extender-war:3.2.6]
at org.ops4j.pax.web.extender.war.internal.extender.AbstractExtender$1.run(AbstractExtender.java:266)[64:org.ops4j.pax.web.pax-web-extender-war:3.2.6]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_45]
at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_45]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_45]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_45]
at java.lang.Thread.run(Thread.java:744)[:1.7.0_45]
How can I fix this ?
The Karaf doc bundle in 4.0.0 actually had an issue if you do:
feature:install war
bundle:install -s mvn:org.apache.karaf/manual/4.0.3/war
it's working right away.
Just navigate to
http://localhost:8181/karaf-doc/
you're able to see the deployed applications via:
karaf#root()> web:list
ID | State | Web-State | Level | Web-ContextPath | Name
-----------------------------------------------------------------------------------------
97 | Active | Deployed | 80 | /karaf-doc | Apache Karaf :: Manual (4.0.3)
I doubt that OSGi is dying, actually the other way round, but that is a biased opinion.
Apache Karaf and ServiceMix based on it are ready for production, don't know about Virgo.
I have a maven + spring based application which I built and deployed in Servicemix.
However, when tried to start the bundle, it remained in the Waiting status for a long time before generating following exception:
16:25:52,219 | DEBUG | Timer-0 | DependencyServiceManager | startup.DependencyServiceManager 339 | 72 - org.springframework.osgi.extender - 1.2.0 | Deregistering service dependency dependencyDetector for OsgiBundleXmlApplicationContext(bundle= abc, config=osgibundle:/META-INF/spring/*.xml)
16:25:52,219 | ERROR | Timer-0 | WaiterApplicationContextExecutor | WaiterApplicationContextExecutor 432 | 72 - org.springframework.osgi.extender - 1.2.0 | Unable to create application context for [abc], unsatisfied dependencies: Dependency on [(objectClass=javax.sql.DataSource)] (from bean [&dataSource])
org.springframework.context.ApplicationContextException: Application context initialization for 'com.vetstreet.pet_mailer' has timed out
Appreciate any help or suggestion.
Spring Extender holds back the startup of an application (setting it's status to Waiting) if a service that you're referencing is unavailable at startup. The reason is that the availability attribute of every referenced service is set to mandatory, and
there's a default-timeout global attribute which is by default set to 5 seconds. If the service you're referring to doesn't appear in that amount of time, Spring Extender will throw an Exception like that you have.
So what I think is something wrong with the service publication of your DataSource. Do you have the corresponding tag in your other application?
<osgi:service ...>
Check out this link: http://static.springsource.org/osgi/docs/2.0.0.M1/reference/html/service-registry.html. It contains a lot of example. Ensure that in both osgi:service and both osgi:reference you have the javax.sql.DataSource interface set. And be aware of not publishing the same interface by 2 different bundles.
One more thing: just to be sure, import the javax.sql package in your manifest:
<Import-Package>javax.sql</Import-Package>
Hope this helps, Gergely