Re: Karaf 4.2.2, Java 11, OpenJFX 11 and PaxExam
Hi Freeman, I updated to the PAX version as advised but now I get a Karaf start up issue when I try to run my test and I get the same result when I remove my custom configuration of the Karaf container: [main] INFO org.ops4j.pax.exam.spi.DefaultExamSystem - Pax Exam System (Version: 4.13.1) created. [main] INFO org.ops4j.pax.exam.junit.impl.ProbeRunner - creating PaxExam runner for class com.javatechnics.flexfx.boot.DeployFlexFxTest [main] INFO org.ops4j.pax.exam.junit.impl.ProbeRunner - running test class com.javatechnics.flexfx.boot.DeployFlexFxTest [main] INFO org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer - Creating RMI registry server on 127.0.0.1:21000 [main] INFO org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer - Found 0 options when requesting OverrideJUnitBundlesOption.class [main] INFO org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer - Wait for test container to finish its initialization [ RelativeTimeout value = 18 ] [main] INFO org.ops4j.pax.exam.rbc.client.RemoteBundleContextClient - Waiting for remote bundle context.. on 21000 name: 572ce6a6-fc5b-4884-a699-2c7a0132875e timout: [ RelativeTimeout value = 18 ] WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.apache.felix.framework.ext.ClassPathExtenderFactory$DefaultClassLoaderExtender (file:/home/kerry/intellijprojects/flexfx/it/tests/target/paxexam/unpack/106f6824-a4ac-4a12-af4b-aecdd0b6bd9c/system/org/apache/felix/org.apache.felix.framework/5.6.10/org.apache.felix.framework-5.6.10.jar) to method java.net.URLClassLoader.addURL(java.net.URL) WARNING: Please consider reporting this to the maintainers of org.apache.felix.framework.ext.ClassPathExtenderFactory$DefaultClassLoaderExtender WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release java.lang.RuntimeException: Container never came up at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.stop(KarafTestContainer.java:629) at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.tearDown(EagerSingleStagedReactor.java:118) at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.afterClass(EagerSingleStagedReactor.java:132) at org.ops4j.pax.exam.spi.reactors.ReactorManager.afterClass(ReactorManager.java:441) at org.ops4j.pax.exam.junit.impl.ProbeRunner.run(ProbeRunner.java:107) at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:93) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Process finished with exit code 254 java.lang.RuntimeException: Cannot get the remote bundle context at org.ops4j.pax.exam.rbc.client.intern.RemoteBundleContextClientImpl.getRemoteBundleContext(RemoteBundleContextClientImpl.java:261) at org.ops4j.pax.exam.rbc.client.intern.RemoteBundleContextClientImpl.waitForState(RemoteBundleContextClientImpl.java:218) at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.waitForState(KarafTestContainer.java:659) at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.startKaraf(KarafTestContainer.java:262) at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.start(KarafTestContainer.java:194) at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.setUp(EagerSingleStagedReactor.java:86) at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.beforeClass(EagerSingleStagedReactor.java:136) at org.ops4j.pax.exam.spi.reactors.ReactorManager.beforeClass(ReactorManager.java:457) at org.ops4j.pax.exam.junit.impl.ProbeRunner.run(ProbeRunner.java:97) at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:93) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Caused by: java.rmi.NotBoundException: 572ce6a6-fc5b-4884-a699-2c7a0132875e at java.rmi/sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:234) at java.rmi/sun.rmi.registry.RegistryImpl_Skel.dispatch(RegistryImpl_Skel.java:115) at java.rmi/sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:467) at java.rmi/sun.rmi.server.UnicastServerRef.dispatch
Re: Karaf 4.2.2, Java 11, OpenJFX 11 and PaxExam
Thanks Freeman. I've ended up using new VMOption("-p"), new VMOption("/usr/lib/jvm/jfx1.11.0/lib"), new VMOption("--add-modules"), new VMOption("javafx.base,javafx.controls,javafx.fxml,javafx.graphics") Which seems to do the trick but I've got a Karaf start up issue now to solve: Cannot access RandomAccessFile java.io.FileNotFoundException: /karaf.log (Permission denied) java.io.FileNotFoundException: /karaf.log (Permission denied) Looks like it's looking in the root directory for the log file so something must be different about the configuration and need to work out what has changed (I've previously had the tests working under earlier versions of Karaf and Java) Kerry On 23/12/2018 23:21, Freeman Fang wrote: > > - > Freeman(Yue) Fang > > Red Hat, Inc. > > > > > >> On Dec 24, 2018, at 4:38 AM, Kerry > <mailto:karaf-u...@avionicengineers.com>> wrote: >> >> Hi, >> >> I'm trying to to get my project FlexFx to work on Java 11 with OpenJFX 11 >> inside Karaf 4.2.2 and have so far managed to get it to work by manually >> deploying the OpenJFX jars to the `jdk9plus` folder of Karaf. >> >> I am now trying to update the integration tests which use Pax Exam and >> because JavaFX is no longer part of the JDK-11 I need to include these in >> the Karaf configuration. To begin with I tried this: >> >> bootClasspathLibraries( >> new >> BootClasspathLibraryOption(mavenBundle().artifactId(OPENJFX_BASE_ARTIFACT_ID).groupId(OPENJFX_GROUP_ID).version(OPENFX_VERSION)), >> new >> BootClasspathLibraryOption(mavenBundle().artifactId(OPENJFX_CONTROLS_ARTIFACT_ID).groupId(OPENJFX_GROUP_ID).version(OPENFX_VERSION)), >> new >> BootClasspathLibraryOption(mavenBundle().artifactId(OPENJFX_FXML_ARTIFACT_ID).groupId(OPENJFX_GROUP_ID).version(OPENFX_VERSION))) >> >> but this only put the artifacts into the lib folder not `lib/jdk9plus` > > Then I think you can add > > new VMOption("-classpath"), > new VMOption(“lib/whatever_yourlib_is") > >> >> Also (and this is where I am still new and confused with the Java9 + module >> system) the above artifacts are not the actual ones I used when I manually >> installed OpenJFX to Karaf. I manually installed the SDK from gluon >> (https://gluonhq.com/products/javafx/) and this zip file includes native >> libraries as well as JARs. These are what I think I should be installing >> automatically but I'm uncertain how I can go about this with PaxExam. >> >> Does anyone have any suggestions? >> >> Thanks, Kerry. >> >> >
Karaf 4.2.2, Java 11, OpenJFX 11 and PaxExam
Hi, I'm trying to to get my project FlexFx to work on Java 11 with OpenJFX 11 inside Karaf 4.2.2 and have so far managed to get it to work by manually deploying the OpenJFX jars to the `jdk9plus` folder of Karaf. I am now trying to update the integration tests which use Pax Exam and because JavaFX is no longer part of the JDK-11 I need to include these in the Karaf configuration. To begin with I tried this: bootClasspathLibraries( new BootClasspathLibraryOption(mavenBundle().artifactId(OPENJFX_BASE_ARTIFACT_ID).groupId(OPENJFX_GROUP_ID).version(OPENFX_VERSION)), new BootClasspathLibraryOption(mavenBundle().artifactId(OPENJFX_CONTROLS_ARTIFACT_ID).groupId(OPENJFX_GROUP_ID).version(OPENFX_VERSION)), new BootClasspathLibraryOption(mavenBundle().artifactId(OPENJFX_FXML_ARTIFACT_ID).groupId(OPENJFX_GROUP_ID).version(OPENFX_VERSION))) but this only put the artifacts into the lib folder not `lib/jdk9plus` Also (and this is where I am still new and confused with the Java9 + module system) the above artifacts are not the actual ones I used when I manually installed OpenJFX to Karaf. I manually installed the SDK from gluon (https://gluonhq.com/products/javafx/) and this zip file includes native libraries as well as JARs. These are what I think I should be installing automatically but I'm uncertain how I can go about this with PaxExam. Does anyone have any suggestions? Thanks, Kerry.
Re: Running Camel in a Karaf OSGi container
Hi John, You might like to cast your eye over a camel example I made for myself a little while ago: https://github.com/jtkb/cameltest It might help give you a few pointers in the right direction. I haven't used if for a while so it might not work 'out-of-the-box' but the code might help you. Kerry On 16/10/18 20:36, John F. Berry wrote: > I'd love to share my code.. just make sure to have your Alka-Seltzer ready :P > This is my original route using Java DSL to solve a small route issue. (I did > anonymize a few things in the code before sending it out to public view) > I've tried to "fortify" it with dependencies and configurations to try and > flip it over to something Karaf can make heads or tails of. > Thanks! > > > > From: Kerry > To: user@karaf.apache.org > Sent: Tuesday, October 16, 2018 3:03 PM > Subject: Re: Running Camel in a Karaf OSGi container > > > > Hi John, > Are you able to share any of your code or an example project? also are you > familiar already with OSGi or is it only Karaf that you are new to? > thanks > Kerry > > > On 16/10/18 19:54, John F. Berry wrote: > > New user to Karaf due to the fact that my development work in Apache Camel is > wanted by people to be installed on a Windows server and to be installed as a > service. This led me to the Karaf product. > I've asked the Camel users forum about migration steps, but now I think this > is more of a Karaf and/or maven deployment thing than a Camel issue. > I have developed a route in Camel using maven and hand writing >a Java DSL route (no Eclipse or other tool). I can run the >jar as a standalone execution fine from a command line. > I did create a OSGi service wrapper in karaf and did have a >window service instance installed. > I just cannot seem to get Karaf to "deploy" it (a.k.a. pick up >and run with it under that OSGi container that is running. > Sorry for the generalities, new to the open source community >and the idea that you need to be fully immersed in every >Apache offering (Camel, Maven, Felix, ServiceMix, Karaf, >etc.) to utilize any one of them :PI have felix and >blueprint dependencies in my POM.. but they been through many >different forms in an attempt to run it. It is a Java DSL >Camel archetype that has been built, but cannot seem to >generate supporting files for Karaf to recognize my little >creation. > Ideas? > Later I attempted to make an "empty" project with maven selecting > "org.apache.camel.archetypes:camel-archetype-blueprint", but I cannot even > get that base package to run (the small Hello World code) without java > blowing up. The one I built, compiled, ran, tested and "jar"ed was from the > "org.apache.camel.archetypes:camel-archetype-java" maven archetype skeleton. > I attempted to merge the two.. but no luck so far! > > Thanks!
Re: Running Camel in a Karaf OSGi container
Hi John, Are you able to share any of your code or an example project? also are you familiar already with OSGi or is it only Karaf that you are new to? thanks Kerry On 16/10/18 19:54, John F. Berry wrote: > New user to Karaf due to the fact that my development work in Apache Camel is > wanted by people to be installed on a Windows server and to be installed as a > service. This led me to the Karaf product. > I've asked the Camel users forum about migration steps, but now I think this > is more of a Karaf and/or maven deployment thing than a Camel issue. > I have developed a route in Camel using maven and hand writing a Java DSL > route (no Eclipse or other tool). I can run the jar as a standalone > execution fine from a command line. > I did create a OSGi service wrapper in karaf and did have a window service > instance installed. > I just cannot seem to get Karaf to "deploy" it (a.k.a. pick up and run with > it under that OSGi container that is running. > Sorry for the generalities, new to the open source community and the idea > that you need to be fully immersed in every Apache offering (Camel, Maven, > Felix, ServiceMix, Karaf, etc.) to utilize any one of them :P I have > felix and blueprint dependencies in my POM.. but they been through many > different forms in an attempt to run it. It is a Java DSL Camel archetype > that has been built, but cannot seem to generate supporting files for Karaf > to recognize my little creation. > Ideas? > Later I attempted to make an "empty" project with maven selecting > "org.apache.camel.archetypes:camel-archetype-blueprint", but I cannot even > get that base package to run (the small Hello World code) without java > blowing up. The one I built, compiled, ran, tested and "jar"ed was from the > "org.apache.camel.archetypes:camel-archetype-java" maven archetype skeleton. > I attempted to merge the two.. but no luck so far! > > Thanks! >
Re: JPA (Hibernate) with Apache Karaf 4.2
Alex, Yes exactly as François says. I was trying to find a mail post/stackoverflow question I asked on exactly the same thing but unfortunately I couldn't find it. On 05/06/18 04:36, Francois Papon wrote: Hi Alex, I think it's because you are mixing Blueprint and SCR. The @Reference annotation is used by SCR. François Papon fpa...@apache.org Open3m - https://www.open3m.io Le 05/06/2018 à 00:13, alex09 a écrit : Hi Kerry, nice examples, I like playing around with this and it's well structured and comprehensible. Just for interest: I realised that it doesn't matter here @Reference(optional = false) private BookServiceDao bookService; what I put in the DAO as optional, all bundles are always ACTIVE, but if I exclude the DAO from the blueprint, the command is (correctly) not recognized in the Karaf console, still the bundle is ACTIVE (in the log, the service is waiting: Command registration delayed for bundle com.javatechnics.jpa.simple-commands/1.0.0.SNAPSHOT. Missing dependencies: [com.javatechnics.jpa.dao.BookServiceDao]) Do you know why optional doesn't work in this case? Where can I address these questions? Thanks! Alex -- Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: JPA (Hibernate) with Apache Karaf 4.2
Cheers Alex will make a note of that. I see you're using Karaf 4.2.X which I didn't test against. Kerry On 02/06/18 18:18, alex09 wrote: Hi Kerry, thanks, it's working now. However, from a plain Karaf installation I had to `feature:install aries-blueprint`would be good to mention somewhere in the docs. Alex -- Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: JPA (Hibernate) with Apache Karaf 4.2
Hi JB, Is DEV_GUIDE branch available in the Github Karaf repo? Kerry On 02/06/18 12:10, Jean-Baptiste Onofré wrote: Hi I encourage you guys to take a look in the DEV_GUIDE branch. Please let me know if you want additional examples. I'm working on it during the weekend. Regards JB Le 2 juin 2018, à 12:54, Kerry mailto:karaf-u...@avionicengineers.com>> a écrit: Alex, thanks for letting me know. I didn't rename a dependency in the simple-commands module when I renamed 'simple' to 'simple-dao'. I've pushed up a fix to master. Kerry On 01/06/18 21:12, alex09 wrote: Hi Kerry, yes, I cloned master of jpatest and started building with `mvn clean install` with this result: [INFO] BUILD FAILURE [INFO] -- [INFO] Total time: 13.522 s [INFO] Finished at: 2018-06-01T22:10:45+02:00 [INFO] -- [ERROR] Failed to execute goal on project simple-commands: Could not resolve dependencies for project com.javatechnics.jpa:simple-commands:bundle:1.0.0-SNAPSHOT: Could not find artifact com.javatechnics.jpa:simple:jar:1.0.0-SNAPSHOT -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn -rf :simple-commands -- Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: JPA (Hibernate) with Apache Karaf 4.2
Alex, thanks for letting me know. I didn't rename a dependency in the simple-commands module when I renamed 'simple' to 'simple-dao'. I've pushed up a fix to master. Kerry On 01/06/18 21:12, alex09 wrote: Hi Kerry, yes, I cloned master of jpatest and started building with `mvn clean install` with this result: [INFO] BUILD FAILURE [INFO] [INFO] Total time: 13.522 s [INFO] Finished at: 2018-06-01T22:10:45+02:00 [INFO] [ERROR] Failed to execute goal on project simple-commands: Could not resolve dependencies for project com.javatechnics.jpa:simple-commands:bundle:1.0.0-SNAPSHOT: Could not find artifact com.javatechnics.jpa:simple:jar:1.0.0-SNAPSHOT -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn -rf :simple-commands -- Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: JPA (Hibernate) with Apache Karaf 4.2
Alex, Are you building on the master branch from the top-level pom? Kerry On 30/05/18 11:57, alex09 wrote: Thanks Kerry! When building simple-commands, an artefact is missing: com.javatechnics.jpa simple 1.0.0-SNAPSHOT provided Does this have to be installed seperately? -- Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: JPA (Hibernate) with Apache Karaf 4.2
Hi Alex, I've created a simple project that shows how to use JPA in Karaf although it uses OpenJPA as the JPA provider: https://github.com/jtkb/jpatest Hopefully it will be straight forward enough for you to get to grips with JPA in an OSGi environment. Kerry On 29/05/18 19:54, alex09 wrote: Hi there, being new to OSGi, I have difficulties getting demos/examples/tutorials to run (esp. with JPA) with Apache Karaf 4.2. I tried all these resources: * Apache Aries 2.7 JPA examples: https://github.com/apache/aries-jpa/tree/master/examples (also user documentation is not accurate for the current Karaf versions) * Tutorials at http://karaf.apache.org/documentation.html#tutorials, which don't work as liquid-reality.de has not been available for weeks now (I found some of them here, but still they don't work: https://github.com/cschneider/Karaf-Tutorial) * Apache Aries 2.7: The Blog Example: http://aries.apache.org/modules/samples/blog-sample.html * Hibernate Demos: https://github.com/hibernate/hibernate-demos/tree/master/hibernate-orm/osgi (also reflecting the outdated user documentation) * also the Entwicklerpress 143 book "OSGi Entwicklung" and Enterprise OSGi in Action All without success, the sample are really dated and there is a lot more to do than just simple changes - this is difficult for someone coming new to this topic. I'd certainly volunteer for helping with this, but as there is no starting point currently, this is complicated. So my question is: are there any plans to create a new, sound description/documentation/tutorial/example for JPA/Hibernate on Apache Karaf 4.x? Or isn't this supposed to work anymore as there are better practices for persistence in OSGi? Thanks & Best Alex -- Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: Recommanded way to use an XML parser in OSGi ?
I'm a bit puzzled why it works with a Karaf command as this will be executed with a differing classloader but as I don't have your code it's hard for me to visualise your imports etc correctly. I would temporarily change the classloader to that of a class that is in your bundle, typically I would make it that of the class which is the entry point from the 'outside world' into your bundle. Don't forget to reset the classloader before the thread leaves your bundle and do this inside a finally clause. Kerry On 27/03/18 22:16, Nicolas Brasey wrote: Ideally I would like to avoid overloading too much from the vanilla karaf to avoid too much dependencies to ease the future karaf version upgrades, but since I'm blocked at the moment I can give it a try. The best for me would be to find a nasty workaround with the classloader just to make it work. Which classloader can I set on the current thread to make this work? Thanks a lot Guillaume for your help! Cheers, Nicolas On Tue, Mar 27, 2018 at 8:09 PM, Guillaume Nodet mailto:gno...@apache.org>> wrote: You're right, I think the current setup on 4.1 is not optimal and a bit too sensitive to the thread context class loader. Can you simply remove the xalan and xerces jars from the lib/endorsed folder and the corresponding export packages in etc/config.properties ? If you want to use xalan and xerces, deploy them as bundles instead. Also, please raise a JIRA so that we can fix that. 2018-03-27 18:35 GMT+02:00 Nicolas Brasey mailto:nicolas.bra...@gmail.com>>: Yes that was also my understanding and this is what I'm doing. Like I said before, it works well from the karaf command but not when the call is initiated from somewhere else. On Tue, Mar 27, 2018 at 6:21 PM, Guillaume Nodet mailto:gno...@apache.org>> wrote: In Karaf, we ensure that you can use DocumentBuilderFactory#newInstance(). That's the standard java api to create a Parser and it works well in Karaf. 2018-03-27 18:11 GMT+02:00 Nicolas Brasey mailto:nicolas.bra...@gmail.com>>: Hi Guillaume, Thanks for those infos. I'm running Karaf 4.1.2. So I tried to lookup a DocumentBuilderFactory service but no one are availably in standard in this karaf version. What do you exactly mean by "it should already work" ? If it can help, I actually based my implementation on the example I found in Karaf, in the Kar service implementation, the class FeatureDetector. It is parsing an XML feature file, which is exactly what I'm trying to do as well. My implementation is 1 to 1. So the code seems perfectly working when a karaf command is calling it, but badly failing when coming from a jetty thread (REST endpoint). I would be happy to get away with a nasty workaround, I'm not looking by a by-the-book implementation :-) Thanks again! Nicolas On Tue, Mar 27, 2018 at 5:02 PM, Guillaume Nodet mailto:gno...@apache.org>> wrote: Here's the way to solve the problem for Karaf 4.2, hopefully I can merge it before the release is done: https://github.com/apache/karaf/pull/481 <https://github.com/apache/karaf/pull/481> For 4.1, the distribution should already work. The OSGi 133 (Service Loader) and 702 (XML Parser) are clearly not sufficient when working with libraries that have not been built solely for OSGi and which use the standard way to use the XML apis. Fwiw, the openjdk code contains code specific to glassfish osgi environment, in a similar way than the above PR. 2018-03-27 16:57 GMT+02:00 Nicolas Brasey mailto:nicolas.bra...@gmail.com>>: Hi Kerry, Yes it executes in another thread (jetty http executor thread pool), so the context is different. The code actually fails quite deep in the abyss of the java service loader: Caused by: java.util.ServiceConfigurationError: javax.xml.parsers.DocumentBuilderFactory: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found at java.util.ServiceLoader.fail(ServiceLoader.java:239) ~[?:?] I should switch the current thread classloader to use the classloader of the class java.util.ServiceLoader? Thanks!! Nicolas On Tue, Mar 27, 2018 at 3:38 PM, Kerry mailto:karaf-u...@avionicengineers.com>> wrote: Hazarding a guess at this but when it fails when called by the camel route it will be executing on a different thread when the
Re: Recommanded way to use an XML parser in OSGi ?
Hazarding a guess at this but when it fails when called by the camel route it will be executing on a different thread when then when executed by karaf command. You could try and confirm this by surrounding the code that is failing with a thread context switch so that it switches to the context of the class that has the failing code. Kerry Sent from BlueMail On 27 Mar 2018, 14:17, at 14:17, Nicolas Brasey wrote: >Hi, > >I'm feeling frustrated because like everytime I'm adventuring with XML >in >an OSGi context, I end up with classloading issues, and this time is no >exception :-) So I would like to know what/how you guys are doing it... > >My use case is extremely simple, yet I can't figure out what I'm doing >wrong. I need to use an XML parser to get a Document object from an XML >file. This XML parsing code is embedded inside a service (DS). The >weird >thing is that If I invoke this service with a karaf command, then it >works >fine. If the same code is invoked through a REST endpoint (another >bundle), >then I get the following class not found: > >Caused by: java.util.ServiceConfigurationError: >javax.xml.parsers.DocumentBuilderFactory: Provider >org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not found >at java.util.ServiceLoader.fail(ServiceLoader.java:239) ~[?:?] >at java.util.ServiceLoader.access$300(ServiceLoader.java:185) ~[?:?] >at >java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:372) >~[?:?] > > >AFAIK, Karaf is pulling the servicemix implementation of Xerces, and I >doubled check that the package is available in karaf: > > >dms@root>exports | grep org.apache.xerces.jaxp >org.apache.xerces.jaxp.datatype > │ 2.11.0 │ 348 │ >org.apache.servicemix.bundles.xerces >org.apache.xerces.jaxp.validation > │ 2.11.0 │ 348 │ >org.apache.servicemix.bundles.xerces >org.apache.xerces.jaxp > │ 2.11.0 │ 348 │ >org.apache.servicemix.bundles.xerces > > > >So, I don't know what I'm doing wrong here. > >Any clue ? > > >Thanks, >Nicolas
Re: Travis CI, Karaf & PAX Exam integration test failure
Hi JB, Just an update on this one. I didn't find the exact reason while my build was failing but I was originally using PAX 4.8.0 but updated to 4.11.0 and the issue went away. Kerry On 08/01/18 18:38, Jean-Baptiste Onofré wrote: OK, weird if the system.properties and/or jre.properties are exporting those packages. On 01/08/2018 07:11 PM, Kerry wrote: I use Travis to use Oracle JDK so should be available. Also TestFX itself is tested on Travis so I expect that the package is available. I'll try a few other things. Kerry On 08/01/18 05:35, Jean-Baptiste Onofré wrote: cum.sun.glass.ui should be an optional import as it's not provided by all JDK. Probably the JDK used by Travis and your machine are different, no ? Regards JB On 01/07/2018 09:16 PM, Kerry wrote: Hi JB, I think the reason for the ClassNotfoundException is because the TestFX-core bundle is not resolved - see line 2825 of the log: Unresolved requirements: [[org.testfx.core [10](R 10.0)] osgi.wiring.package; (osgi.wiring.package=com.sun.glass.ui)] TestFx is OSGi compatible so not using Dynamic Package. The package com.sun.glass.ui is an internal package and I make it available by modifying the Karaf config.properties: https://github.com/jtkb/flexfx/blob/master/it/tests/src/test/resources/etc/config.properties this is a very strange issue because the same integration tests run OK on my local dev machine.. for some reason my config.properties isn't being applied when in Travis? (guessing here). Kerry On 07/01/18 19:43, Jean-Baptiste Onofré wrote: Hi Kerry, I never used Travis with Karaf (we are using Jenkins for the itests). However, your issue doesn't look related to Travis. I can see java.lang.ClassNotFoundException: org.testfx.osgi.service.TestFx in the log. I think you are using Dynamic Package. Can you check that the bundle providing the org.testfx.osgi.service package is part of startup.properties ? Regards JB On 01/07/2018 06:41 PM, JT wrote: Hi, I'm trying to set up Travis CI for my GitHub project. I have some integration tests using PAX exam and execute these in a Karaf instance. I use a modified config.properties file which adds the package'com.sun.glass.ui' to the 'org.osgi.framework.system.packages.extra'property. When I run the integration tests locally there are issue. When the integration tests are run on Travis, they fail because the package com.sun.glass.ui is not exported: https://travis-ci.org/jtkb/flexfx Does anyone have experience of using Travis CI and configuring Karaf to run in it or any idea why the config.properties is not being applied? Thanks, Kerry.
Re: Travis CI, Karaf & PAX Exam integration test failure
I use Travis to use Oracle JDK so should be available. Also TestFX itself is tested on Travis so I expect that the package is available. I'll try a few other things. Kerry On 08/01/18 05:35, Jean-Baptiste Onofré wrote: cum.sun.glass.ui should be an optional import as it's not provided by all JDK. Probably the JDK used by Travis and your machine are different, no ? Regards JB On 01/07/2018 09:16 PM, Kerry wrote: Hi JB, I think the reason for the ClassNotfoundException is because the TestFX-core bundle is not resolved - see line 2825 of the log: Unresolved requirements: [[org.testfx.core [10](R 10.0)] osgi.wiring.package; (osgi.wiring.package=com.sun.glass.ui)] TestFx is OSGi compatible so not using Dynamic Package. The package com.sun.glass.ui is an internal package and I make it available by modifying the Karaf config.properties: https://github.com/jtkb/flexfx/blob/master/it/tests/src/test/resources/etc/config.properties this is a very strange issue because the same integration tests run OK on my local dev machine.. for some reason my config.properties isn't being applied when in Travis? (guessing here). Kerry On 07/01/18 19:43, Jean-Baptiste Onofré wrote: Hi Kerry, I never used Travis with Karaf (we are using Jenkins for the itests). However, your issue doesn't look related to Travis. I can see java.lang.ClassNotFoundException: org.testfx.osgi.service.TestFx in the log. I think you are using Dynamic Package. Can you check that the bundle providing the org.testfx.osgi.service package is part of startup.properties ? Regards JB On 01/07/2018 06:41 PM, JT wrote: Hi, I'm trying to set up Travis CI for my GitHub project. I have some integration tests using PAX exam and execute these in a Karaf instance. I use a modified config.properties file which adds the package'com.sun.glass.ui' to the 'org.osgi.framework.system.packages.extra'property. When I run the integration tests locally there are issue. When the integration tests are run on Travis, they fail because the package com.sun.glass.ui is not exported: https://travis-ci.org/jtkb/flexfx Does anyone have experience of using Travis CI and configuring Karaf to run in it or any idea why the config.properties is not being applied? Thanks, Kerry.
Re: Travis CI, Karaf & PAX Exam integration test failure
Hi JB, I think the reason for the ClassNotfoundException is because the TestFX-core bundle is not resolved - see line 2825 of the log: Unresolved requirements: [[org.testfx.core [10](R 10.0)] osgi.wiring.package; (osgi.wiring.package=com.sun.glass.ui)] TestFx is OSGi compatible so not using Dynamic Package. The package com.sun.glass.ui is an internal package and I make it available by modifying the Karaf config.properties: https://github.com/jtkb/flexfx/blob/master/it/tests/src/test/resources/etc/config.properties this is a very strange issue because the same integration tests run OK on my local dev machine.. for some reason my config.properties isn't being applied when in Travis? (guessing here). Kerry On 07/01/18 19:43, Jean-Baptiste Onofré wrote: Hi Kerry, I never used Travis with Karaf (we are using Jenkins for the itests). However, your issue doesn't look related to Travis. I can see java.lang.ClassNotFoundException: org.testfx.osgi.service.TestFx in the log. I think you are using Dynamic Package. Can you check that the bundle providing the org.testfx.osgi.service package is part of startup.properties ? Regards JB On 01/07/2018 06:41 PM, JT wrote: Hi, I'm trying to set up Travis CI for my GitHub project. I have some integration tests using PAX exam and execute these in a Karaf instance. I use a modified config.properties file which adds the package'com.sun.glass.ui' to the 'org.osgi.framework.system.packages.extra'property. When I run the integration tests locally there are issue. When the integration tests are run on Travis, they fail because the package com.sun.glass.ui is not exported: https://travis-ci.org/jtkb/flexfx Does anyone have experience of using Travis CI and configuring Karaf to run in it or any idea why the config.properties is not being applied? Thanks, Kerry.
Re: Include Karaf feature in POM dependency
On 30/11/17 17:00, Steinar Bang wrote: Kerry : Yes that is what I meant, I have to use a template to create a features.xml. I've looked at the code for GenerateDescriptorMojo and searched the Karaf source for an example of what I need but couldn't find anything. I've created a feature request for this: https://issues.apache.org/jira/browse/KARAF-5512 Using the template technique I've also discovered that when I deployed my feature it can fail. For example if I have 3 of my bundles A, B and C in the feature such that: B depends on a service from C and A depends on B deployment can fail due to a required service from C not being available 'in-time' for B - I think that's what happening. If I deploy the bundles individually everything works. I'll try playing around with it but this is obviously nothing to do with the GenerateDescriptorMojo. Hm... B should be robust enough to handle services arriving at any time and in any order. But if bundle B is outside of your control, then maybe you could force the correct load order in some way...? Maybe a hiearchy of feature dependencies would do the trick? Ie. make a feature for C that loads C. Then make a feature for B that loads bundle B and requires feature C. Then make a feature for A that loads bundle A and requires feature B. Then make your feature be dependent on feature A. Something like that...? Hi Steinar, Sorry taken me a while to get back to you. 1. thanks for raising up the JIRA ticket I also would like to keep my features specification within the POM if possible. 2. Regarding the resolving of bundles in a feature, I don't believe that it's because the bundles are not robust, it's more like the feature deployer within Karaf isn't flexible enough to allow services to become available that are provided within the same feature. I have created an example here : https://github.com/jtkb/jpatest/blob/feature/karaf_features/simple-datasource/src/main/feature/feature.xml If I try to deploy this feature I get the deployment error: resolution:=mandatory [caused by: Unable to resolve com.javatechnics.jpa.simple/1.0.0.SNAPSHOT: missing requirement [com.javatechnics.jpa.simple/1.0.0.SNAPSHOT] osgi.service; objectClass=javax.persistence.spi.PersistenceProvider; javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl; effective:=active]] Remove the last bundle from the features.xml ('simple'), deploy the feature and THEN install the 'simple' bundle manually it all works fine. Unless I am configuring my feature incorrectly there doesn't seem to be a way of including DAO/persistence unit bundle AND the datasource bundle within the same feature. Kerry
Re: Include Karaf feature in POM dependency
On 26/11/17 07:47, Steinar Bang wrote: Jean-Baptiste Onofré : The generate-descriptor MOJO (or if you use the feature packaging) will create a feature.xml. Yes. But what he was saying, was that the generate-descriptor doesn't use somefeature from the karaf-maven-plugin as dependencies. It only uses those dependencies found in a template.xml. And since I prefer to have all of the config in the POM instead of some in the POM and some in a different place, I thought that was a good idea. The OP offered to make a PR for the change. - Steinar Steinar, Yes that is what I meant, I have to use a template to create a features.xml. I've looked at the code for GenerateDescriptorMojo and searched the Karaf source for an example of what I need but couldn't find anything. Using the template technique I've also discovered that when I deployed my feature it can fail. For example if I have 3 of my bundles A, B and C in the feature such that: B depends on a service from C and A depends on B deployment can fail due to a required service from C not being available 'in-time' for B - I think that's what happening. If I deploy the bundles individually everything works. I'll try playing around with it but this is obviously nothing to do with the GenerateDescriptorMojo. Kerry
Re: Include Karaf feature in POM dependency
Thanks JB. I have a feeling I've asked this already but I think the plug-in options are aimed at building a KAR? I just want to create a features file with the included feature dependencies. I think the only way to do this is to provide a template features XML file? I was going to see if I can tweak the karaf-maven-plugin to do as I want. Would this be of interest as a possible PR? Kerry On 24/11/17 19:43, Jean-Baptiste Onofré wrote: Hi, The karaf-maven-plugin support tag. Regards JB On 11/24/2017 07:50 PM, Kerry wrote: Hi, I'm trying to specify Karaf feature dependencies in my POM so that I can generate a features XML for my own bundle that will install the features as well. How do I specify for example the pax-jdbc-mariadb feature with Maven coordinates? It's part of the enterprise feature I believe but I don't want to install all of enterprise, so how can I install individual features? thanks, Kerry
Include Karaf feature in POM dependency
Hi, I'm trying to specify Karaf feature dependencies in my POM so that I can generate a features XML for my own bundle that will install the features as well. How do I specify for example the pax-jdbc-mariadb feature with Maven coordinates? It's part of the enterprise feature I believe but I don't want to install all of enterprise, so how can I install individual features? thanks, Kerry
Re: Pax Exam - Install wrapped Bundle
Hi Oliver, Thanks for the link. In the end I found that all I needed to do was : mavenBundle(GUAVA_GROUP_ID, GUAVA_ARTIFACT_ID, GUAVA_VERSION), mavenBundle(TESTFX_GROUP_ID, TESTFX_ARTIFACT_ID, TESTFX_VERSION), (text in capitals are just static Strings holding the maven coordinates) And the bundles are wrapped for me automatically, so I am not sure what the purpose of the wrappedBundle method is, it doesn;t seem to work for me. I'll investigate the link further to see if there is anything different. Kerry On 28/08/17 10:14, Oliver Lietz wrote: On Saturday 26 August 2017 12:28:18 Kerry wrote: Hi, Hi Kerry, I'm trying to install TestFx standard JAR to run an integration test with PaxExam and because it's not OSGi by default I've tried supplying it in the Option array as a wrappedBundle: wrappedBundle(mavenBundle(TESTFX_GROUP_ID, TESTFX_ARTIFACT_ID, TESTFX_VERSION)), The test fails complaining that it cannot find a class within the TestFX JAR, and inspecting the Karaf instance after running the test, sure enough the JAR wasn't installed. There are no errors in the logs to say installation failed. Can anyone tell me what I am doing wrong? without any error from the logs I can't, but have a look at Sling Karaf and compare with your setup: https://github.com/apache/sling/blob/trunk/karaf/org.apache.sling.karaf-integration-tests/src/test/java/org/apache/sling/karaf/tests/bootstrap/SlingLaunchpadNosqlCouchbaseIT.java Regards, O. Kerry
Pax Exam - Install wrapped Bundle
Hi, I'm trying to install TestFx standard JAR to run an integration test with PaxExam and because it's not OSGi by default I've tried supplying it in the Option array as a wrappedBundle: wrappedBundle(mavenBundle(TESTFX_GROUP_ID, TESTFX_ARTIFACT_ID, TESTFX_VERSION)), The test fails complaining that it cannot find a class within the TestFX JAR, and inspecting the Karaf instance after running the test, sure enough the JAR wasn't installed. There are no errors in the logs to say installation failed. Can anyone tell me what I am doing wrong? Kerry
Register a Karaf Command Dynamically
Hi, I'd like to try and register a Karaf command dynamically i.e. not immediately at Bundle start up by at some unknown time in the future. I thought I could do this using the bundleContext.registerService() method like so: commandTwoServiceAction = bundleContext.registerService(Action.class, commandTwo, metaData) And the metadata object contains: metaData.put("scope", "command"); metaData.put("name", "two"); metaData.put("description", "Uses the consumer two"); But that doesn't work. Is there a way I can do this or examples in the Karaf code base of this?
Re: Executing a Karaf command in Pax Exam Test
Thanks Achim. I also discovered from that code the BootFinished class.. very useful to know. On 13/08/17 13:52, Achim Nierbeck wrote: Hi, take a look at these lines, they'll give you something similar I'm sure: https://github.com/ANierbeck/Karaf-Cassandra/blob/master/Karaf-Cassandra-ITest/src/test/java/de/nierbeck/cassandra/itest/TestBase.java#L150-L180 btw. if in doubt, there are a couple of tests around that class using it. So there should be plenty of samples ;) regards, Achim 2017-08-13 14:06 GMT+02:00 Kerry mailto:karaf-u...@avionicengineers.com>>: Hi, I'm writing an integration test and in it I want to execute the Karaf 'install' command. I don't want to provision the bundle at Karaf start-up but specifically attempt to install it in a test to ensure a certain behaviour occurs. I found this page: http://planet.jboss.org/post/advanced_integration_testing_with_pax_exam_karaf <http://planet.jboss.org/post/advanced_integration_testing_with_pax_exam_karaf> and it makes use of a 'CommandProcessor' interface but searching the current Karaf source code it appears this class no longer exists. Is there a way that I can achieve the above? Thanks Kerry -- Apache Member Apache Karaf <http://karaf.apache.org/> Committer & PMC OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer & Project Lead blog <http://notizblog.nierbeck.de/> Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS> Software Architect / Project Manager / Scrum Master
Executing a Karaf command in Pax Exam Test
Hi, I'm writing an integration test and in it I want to execute the Karaf 'install' command. I don't want to provision the bundle at Karaf start-up but specifically attempt to install it in a test to ensure a certain behaviour occurs. I found this page: http://planet.jboss.org/post/advanced_integration_testing_with_pax_exam_karaf and it makes use of a 'CommandProcessor' interface but searching the current Karaf source code it appears this class no longer exists. Is there a way that I can achieve the above? Thanks Kerry
Re: Features archetype - bundle start-level
Hi JB, Actually it's a mix of 4.0.3 and 4.0.1 I have been using. No particular reason for that other than I've not kept an eye on my IDE when it selects the version to use for the archetype. I've just tried 4.0.4 and I still get the same result. Below is the template features XML I have used: xmlns="http://karaf.apache.org/xmlns/features/v1.0.0";> version='${project.version}'> ${project.description} mvn:com.example/test-bundle/1.0.0 And the configuration in the POM is: org.apache.karaf.tooling karaf-maven-plugin 50 true (obr) true false true true As you can see the features template is the standard one except for the bundle. Do I need to include (in the template) a reference to the startLevel specified in the POM on each bundle entry? Regards Kerry On 11/02/16 12:52, Jean-Baptiste Onofré wrote: Hi Kerry, I guess you use archetype from Karaf 4.0.4, correct ? Regards JB On 02/11/2016 01:41 PM, Kerry Billingham wrote: Hello All, I'm using the Karaf features archetype but don't seem to be able to specify the start-level of the bundles in the features XML. In my POM I have set the property in the karaf-maven-plugin but that start level doesn't get propagated through to the features XML when I build the project. Is there something I'm doing wrong or missing an extra configuration? Thanks Kerry
Features archetype - bundle start-level
Hello All, I'm using the Karaf features archetype but don't seem to be able to specify the start-level of the bundles in the features XML. In my POM I have set the property in the karaf-maven-plugin but that start level doesn't get propagated through to the features XML when I build the project. Is there something I'm doing wrong or missing an extra configuration? Thanks Kerry
Karaf Features Maven archetype (karaf-feature-archetype)
Hi, I was wondering if I can use karaf-feature-archetype to build a features.xml where my feature has a dependency upon another feature? As far as I can work out I can specify only dependent bundles with artifact, group etc. but can I specify a dependent feature as well? Oddly for some reason I'm having problems picking up the latest version of this archetype (4.0.1?) through Netbeans but seems to work ok from commandline. (granted, this further issue is probably not directly related to this mailing list but if anyone else has experienced this it would be nice to know) Thanks Kerry