How to share OSGi bundles between JBoss and Eclipse RCP? - eclipse

I am currently developing an application which has a server part based on JavaEE 6.0 on JBoss 7.1 and a client based on Eclipse RCP 3.7.
For a simple OSGi package for a shared API I already run into trouble due to some differences in versions and depdencenies. The API requires "org.osgi.framework." for the bundle activator and "org.slf4j." for the slf4j logging API.
Currently my client is working very well, but JBoss tells me that the expected version of the OSGi import and the also the imports for slf4j do not fit...
I there a best practice to share OSGi bundles between Eclipse and JBoss? Do I need to get back to simple import and export declarations or can I used Require-Bundle somehow? Do I need to create some compatibility bundles for JBoss to get it running? What is the best way to proceed here?
UPDATE
I solved the issue by using Import-Package exclusively. For the dependency like org.osgi.framework is use version="0.0" to explain it does not matter. :-( It is not very safe, but currently I do not see another option. Is there a better way?
UPDATE 2
One also needs to pay attention to implement the correct verion of the OSGi Framework. JBoss 7.1.x only has OSGi 4.2 implemented, which has no support for typesafe service retrieval.

The best practice would be to use an import package statement with a range from the minimum version which you're using to the next major increment.
For example, if RCP expects version 1.5 of a package and JBoss expects 1.3.6, import version="[1.3.6,2)".
The Semantic Versioning whitepaper (pdf) explains why this style of import is safe and wise.

Related

Who calls start() on the Bundle-Activator class in Eclipse?

My ultimate goal is Invoking Eclipse plugin from Java. I see that an Eclipse plugin registers a class as Bundle-Activator in MANIFEST.MF. The start(BundleContext context) method will be called on this class. Where does this call come from?
Eclipse is made up of many repos that are mostly mirrored on GitHub. Some are deprecated and point to other repos. And it's a programming IDE and an OSGi framework at the same time? I find it hard to find the code for this core part of the framework that handles plugin loading. Where is it?
The project to interact with OSGi bundles is Eclipse Equinox. It is an implementation of the OSGi framework. You start equinox and load the bundle jar from there instead of putting them into the regular classpath.
Here you find some information how to do this in general:
http://njbartlett.github.io/2011/07/03/embedding-osgi.html
You can then interact with the bundles from you plain java application. This is not an easy thing though.
What makes things even more complex is that Eclipse is not plain OSGi. Eclipse predates OSGi and many of the concepts are still not fully adapted to plain OSGi.
So using eclipse plugins from a plain java application may be very hard.
I recommend to ask on the mailing list of the plugin you want to use if there is experience with using it outside eclipse.

ClassNotFoundException:com.microsoft.sqlserver.jdbc.SQLServerDriver after migration to liferay 7 from liferay 6.2

I get below error in console when deploying each portlet after migration to liferay 7 which was working fine with liferay 6.2
ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver cannot be found by MAIPF_MyAccount-portlet_7.0.0.1
SQLException: No suitable driver found for jdbc:jtds:sqlserver://IDPLaptop/MAIPF2012_dev_VR7
My guess is that you fell into a common issue I keep seeing on StackOverflow when people try to upgrade to Liferay 7: libraries within the server's lib are not visible for all portlets.
With the ability to code OSGi modules,if one moves their portlet to an OSGi bundle, they need to keep track of the dependencies that module require.
As the jar you are using is not a bundle, you will need to create a uber bundle or use compileInclude to create a fat jar for your module.
Liferay 7, out of the box, does only support open source databases. As you state that you're using Service Builder, you might need to install Antonio's SQLServer integration or move to the commercial offering, Liferay DXP.
Check Victor's answer as well. I commonly use open source databases and DXP anyways, so the nitty-gritty-details that are hidden here are only my theoretical knowledge, I rarely get to experience this in practice.

auto-updating JavaFX/ScalaFX client installation

Is there any ready-made installer, component, api or any combination, that would let a JavaFX application, or any JVM based client for that matter, automatically and securely check for a new version of itself, and get, install and re-launch the new version?
Although not ideal, is it doable at least with sbt?
in the Moment there is only a feature request for Java 9
Take a Look at this aproach which seems straight forward
AutoUpdate by Reportmill
Install4J is a a tool for creating installers for JVM applications, it provides for creation of auto-updates
https://www.ej-technologies.com/products/install4j/features.html
You can also build Install4J projects from SBT using the sbt-install4j plugin (disclaimer: I am the author of the plugin).
I have come to believe that the most practical (partial) solution is Java Web Start. Mature, documented, and comes along with the JRE and JDK. I wonder if anyone had experience with it for ScalaFX or JavaFX applications.

Eclipse configuration to support dual Equinox/Felix environments

What are some configuration changes to make Eclipse PDE best support working with both Equinox and Felix?
Here's an example problem I'm currently having. I can run my application ok via the Eclipse OSGi Framework launcher. Similarly, there are no compilation problems in PDE. However, when running in Felix I will get NoClassDefFoundErrors:
java.lang.NoClassDefFoundError: org/w3c/dom/DOMException
My understanding is it's my Eclipse setup that is at fault here; org.w3c.dom is not a 'default' OSGi package and shouldn't be loaded when I run it in Eclipse. Similarly, the import in my code for org.w3c.dom.DOMException should be an error.
I know how to fix this for Felix: declare an Import-Package. But that's not my question. My question is how to force Eclipse PDE to take on a closer configuration to Felix... basically to make it stricter in loading packages?
I think Equinox does behave like Felix, if you run it stand alone. It's more of an Eclipse legacy thing than an Equinox thing, as stated on osgi.org.
As far as I know, there isn't any way to override the boot delegation from Eclipse, but I'd love to be proven wrong, as I've faced this problem often.
If you are developing a server application I recommend to not use the PDE at all. I am using maven and the maven bundle plugin to develop my bundles. Then I deploy on Apache karaf. Debugging also is quite simple by using the karaf dev:watch command and remote debugging. I never really missed the PDE features and they never worked well with my maven build.
This sounds like that launcher is setting bootdelegation to legacy mode. See the following page on the OSGi Wiki: http://wiki.osgi.org/wiki/Why_does_Eclipse_find_javax.swing_but_not_Felix%3F

Which XQuery engine JBoss AS 7 supports?

I am working on AVOS to camunda migration project and getting issues while using existing XQuery files in JBoss AS 7. Which engine/version of XQuery, JBoss AS 7 supports?
As far as I know, JBoss EAP does not provide any XQuery processor. It however embeds Xalan which provides an XSLT processor.
RedHat would probably propose you to use their JBoss Fuse product to implement XQuery transformations. I've never used the product so I won't be able to give you any feedback on it.
Of course a viable alternative is adding an XQuery processor like Saxon to your application or platform yourself. If you want to deploy it to the platform instead of to each application, see the module mechanism.