ServiceMix bundle status is "Active" even though bundle deployment fails - osgi

I have (intentionally created situation to test my CI setup) a bundle which does not have all dependencies configured correctly. When I deploy that the deployment fails with an exception as it should:
2014-02-07 09:17:15,738 | ERROR | rint Extender: 3 | BlueprintCamelContext | 103 - org.apache.camel.camel-blueprint - 2.10.7 | Error occurred during starting Camel: CamelContext(ura) due "org.xmlsoap.schemas.soap.envelope" doesnt contain ObjectFactory.class or jaxb.index
javax.xml.bind.JAXBException: "org.xmlsoap.schemas.soap.envelope" doesnt contain ObjectFactory.class or jaxb.index
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_11]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_11]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_11]
at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_11]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:143)[89:org.apache.servicemix.specs.jaxb-api-2.2:2.2.0]
at javax.xml.bind.ContextFinder.find(ContextFinder.java:310)[89:org.apache.servicemix.specs.jaxb-api-2.2:2.2.0]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:412)[89:org.apache.servicemix.specs.jaxb-api-2.2:2.2.0]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:375)[89:org.apache.servicemix.specs.jaxb-api-2.2:2.2.0]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:279)[89:org.apache.servicemix.specs.jaxb-api-2.2:2.2.0]
at org.apache.camel.dataformat.soap.SoapJaxbDataFormat.createContext(SoapJaxbDataFormat.java:303)[206:org.apache.camel.camel-soap:2.10.7]
at org.apache.camel.converter.jaxb.JaxbDataFormat.doStart(JaxbDataFormat.java:254)[187:org.apache.camel.camel-jaxb:2.10.7]
at org.apache.camel.dataformat.soap.SoapJaxbDataFormat.doStart(SoapJaxbDataFormat.java:101)[206:org.apache.camel.camel-soap:2.10.7]
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)[100:org.apache.camel.camel-core:2.10.7]
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
The problem is that the bundle status is still "Active". Why?
karaf#root> osgi:list
START LEVEL 100 , List Threshold: 50
ID State Blueprint Spring Level Name
[ 242] [Active ] [Created ] [ ] [ 80] integraatiot-foo (1.0.0.SNAPSHOT)
I would like to setup my CI builds to that they detect failed bundles using http://code.citytechinc.com/osgi-bundle-status-maven-plugin/. This idea fails since bundle status is always "Active".

The bundle is active because it has been activated. This is normal. If an error occurred in some code within the bundle, that is nothing to do with the OSGi active state.
So you need to work out some way to report your internal failure such that it can be picked up by a CI build. I suggest using the OSGi LogService.

You'll need to make sure all your dependencies are required and with the correct version.
In this case it might be that the package your importing does existing in the wrong version.
Or better did you make sure you only import the right version of the package with [2,3.0) for example. Especially the stack trace makes it suspicious to me that your using import without version range and therefore do import the JRE jaxb classes which usually do have version 0.0.0
To check which bundles are actually used for import log in the shell and do a bundle:header [bundleID]

Related

Karaf Bundle.getState() doesn't exactly match bundle's status in bundle:list

how does the karaf client's bundle:list command determine the bundles' states? When a bundle show "Failure" in bundle:list, programmatically running this bundle's getState() (to display on a gui) shows Active. Is there another api i can use to determine if the bundle is in Failure state? Karaf version is 4.1.5 although it shows on earlier versions too. Thanks.
I've had a similar situation. If you look at the Karaf sources for the bundle:list, you'll notice that they use org.apache.karaf.bundle.core.BundleInfo to get the state via org.apache.karaf.bundle.core.BundleService =>
org.apache.karaf.bundle.core.BundleInfo info = bundleService.getInfo(bundle.get());
info.getState();
More info: https://github.com/apache/karaf/blob/5144a1eba5687dab0f016a9bf95e58e6687a26ad/bundle/core/src/main/java/org/apache/karaf/bundle/command/List.java

JBoss Fuse: java.lang.IllegalStateException: Resource has no uri for installed bundle

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!

OSGI bundle status grace period

I am trying to install two bundles on Karaf. For one of the bundle i am getting error and when I see the bundle:diag i got below message. It is the same thing compaining in logs also. Similar kind of bundle already deploy and it has the same dependencies. first one is working but the for second bundle i am getting below error. any thoughts?
opendaylight-user#root>bundle:diag
videoweb (421)
Status: GracePeriod
Blueprint
2/10/16 6:07 PM
Missing dependencies:
(objectClass=org.osgi.service.http.HttpService)
2016-02-10 23:54:07.113 GMT+00:00 [Blueprint Extender: 3] ERROR o.a.a.b.c.BlueprintContainerImpl - Unable to start blueprint container for bundle com.xyz.videosdn.tesweb due to unresolved dependencies [(objectClass=org.osgi.service.http.HttpService)]
java.util.concurrent.TimeoutException: null
at org.apache.aries.blueprint.container.BlueprintContainerImpl$1.run(BlueprintContainerImpl.java:336) [org.apache.aries.blueprint.core:1.4.0]
at org.apache.aries.blueprint.utils.threading.impl.DiscardableRunnable.run(DiscardableRunnable.java:48) [org.apache.aries.blueprint.core:1.4.0]
The error means that your bundle has a mandatory reference to a service with the interface org.osgi.service.http.HttpService.
So you need to install a bundle that provides this service. In karaf this service is normally provided by pax-web. It can be installed using:
feature:install http

Grails 2.4.4 GGTS 3.6.3 not working in debug

bit more shinnangins
I have a project i'm trying to debug, using grails 2.4.4 and GGTS3.6.3
if run-app the project - works ok
when I try and set break point and the debug if get this error
|Loading Grails 2.4.4
Error |
There was an error loading the BuildConfig: argument type mismatch (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.IllegalArgumentException: argument type mismatch
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at grails.util.BuildSettings.getForkConfig(BuildSettings.groovy:1515)
at grails.util.BuildSettings.establishProjectStructure(BuildSettings.groovy:1389)
at grails.util.BuildSettings.postLoadConfig(BuildSettings.groovy:1121)
at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1116)
at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1088)
at grails.util.BuildSettings.loadConfig(BuildSettings.groovy)
at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1074)
at grails.util.BuildSettings.loadConfig(BuildSettings.groovy)
at grails.util.BuildSettings$loadConfig$0.callCurrent(Unknown Source)
at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1054)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
Error |
There was an error loading the BuildConfig: argument type mismatch
this looks like a repeat of this link on earlier version of grails
previous question
note says claimed fixed - but fails for me - any else got this issue
Brute force method. download fresh 'latest' copy of GGTS (I did 3.6.3-sr1). I then imported my project from previous workspace on 3.6.2 that i'd let get upgraded.
once imported into clean build and new workspace the problem seemed to go away.
I came across this same problem yesterday with ggts-3.4.0 and grails 2.4.3.
I can confirm that the -noreloading parameter has no effect.
I tried William's technique and implemented a clean install with ggts-3.6.4, alas to no avail.
In the end my solution/workaround is to leave one line of grails.project.fork uncommented out, namely:
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true]
This allows me to both: run and debug my Application.
Allan.

Unsatisfied dependency on javax.sql.DataSource

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

Resources