openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.58k forks source link

cometvisu's manifest misses imports #533

Closed maggu2810 closed 8 years ago

maggu2810 commented 8 years ago

The package imports do miss some stuff. e.g. the bundled quercus library (that is added to the classpath of cometvisu) imports javax.sql.DataSource but the cometvisu bundle's manifest miss that part.

12:53:12.208 [ERROR] [org.openhab.ui.cometvisu            ] - [org.openhab.cometvisu(126)] The activate method has thrown an exception
java.lang.NoClassDefFoundError: javax/sql/DataSource
    at com.caucho.quercus.QuercusEngine.<init>(QuercusEngine.java:58)
    at org.openhab.ui.cometvisu.servlet.CometVisuServlet.<init>(CometVisuServlet.java:141)
    at org.openhab.ui.cometvisu.servlet.CometVisuApp.registerServlet(CometVisuApp.java:196)
    at org.openhab.ui.cometvisu.servlet.CometVisuApp.activate(CometVisuApp.java:176)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_66]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_66]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_66]
    at java.lang.reflect.Method.invoke(Method.java:497)[:1.8.0_66]
    at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:222)
    at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:37)
    at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:615)
    at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:499)
    at org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:295)
    at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:302)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:113)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:866)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:833)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:774)[33:org.apache.felix.scr:2.0.2]
    at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse$1.run(ServiceFactoryUse.java:212)
    at java.security.AccessController.doPrivileged(Native Method)[:1.8.0_66]
    at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:210)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.getService(ServiceFactoryUse.java:111)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.serviceregistry.ServiceConsumer$2.getService(ServiceConsumer.java:45)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:496)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.getService(ServiceRegistry.java:461)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.framework.BundleContextImpl.getService(BundleContextImpl.java:619)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at com.eclipsesource.jaxrs.publisher.internal.ResourceTracker.addingService(ResourceTracker.java:39)[13:com.eclipsesource.jaxrs.publisher:5.2.0.201511120713]
    at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)[org.osgi.core-6.0.0.jar:]
    at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)[org.osgi.core-6.0.0.jar:]
    at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[org.osgi.core-6.0.0.jar:]
    at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)[org.osgi.core-6.0.0.jar:]
    at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:901)[org.osgi.core-6.0.0.jar:]
    at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:914)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:869)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:857)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:133)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:915)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:715)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:399)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.config.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:676)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:339)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:360)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.Activator.access$000(Activator.java:53)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:260)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)[33:org.apache.felix.scr:2.0.2]
    at org.apache.felix.utils.extender.AbstractExtender.addingBundle(AbstractExtender.java:192)[33:org.apache.felix.scr:2.0.2]
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469)[org.osgi.core-6.0.0.jar:]
    at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:415)[org.osgi.core-6.0.0.jar:]
    at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[org.osgi.core-6.0.0.jar:]
    at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)[org.osgi.core-6.0.0.jar:]
    at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)[org.osgi.core-6.0.0.jar:]
    at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:902)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:165)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:75)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:67)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:102)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.container.Module.publishEvent(Module.java:466)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.container.Module.start(Module.java:457)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:454)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.container.ModuleContainer.applyDelta(ModuleContainer.java:717)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.container.ModuleContainer.resolveAndApply(ModuleContainer.java:491)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:437)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:427)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.eclipse.osgi.container.ModuleContainer$ContainerWiring.resolveBundles(ModuleContainer.java:1267)[org.eclipse.osgi-3.10.2.v20150203-1939.jar:]
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl.resolveBundles(FeaturesServiceImpl.java:1267)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:823)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1079)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:975)[9:org.apache.karaf.features.core:4.0.3]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_66]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_66]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_66]
    at java.lang.Thread.run(Thread.java:745)[:1.8.0_66]
Caused by: java.lang.ClassNotFoundException: javax.sql.DataSource cannot be found by org.openhab.ui.cometvisu_2.0.0.201512091015
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.8.0_66]
    ... 83 more
12:53:12.223 [ERROR] [org.openhab.ui.cometvisu            ] - [org.openhab.cometvisu(126)] Failed creating the component instance; see log for reason
kaikreuzer commented 8 years ago

@peuter Could you have a look?

peuter commented 8 years ago

@maggu2810 Could you tell me how I can reproduce the Exception. I didn't ran into that problem my using/compiling the comtvisu bundle and I would like to check if adding 'javax.sql' to the import solves the problem before creating a pull request

maggu2810 commented 8 years ago

@peuter You have to use the Karaf branch. I believe the boot delegation Eclipse is using is a little bit weird. All that is not java.* and is used have to be added to the package imports. Eclipse is not so strict, but it will break bundles...

peuter commented 8 years ago

Sorry but I have zero experience with karaf yet. Just checked out the branch and all I can see from the cometvisu is:

[cometvisu.internal.CvActivator:46 ] - SSE API has been started.

No errors, no starting messages, nothing. And I have no idea how to solve that.

maggu2810 commented 8 years ago

I looked at the sources and did not found any information which version of Quercus is bundled. There is no reference in the about.html. I do not know, but shouldn't all third party libraries that are bundled added with their license and the version used? Is it correct that Quercus is using the GPL?

Looking at the v4.0.39 sources the constructor of QuercusEngine creates a new QuercusContext object.

QuercusContext is using e.g.

import javax.cache.Cache;
import javax.sql.DataSource;

and a private member of type DataSource.

peuter commented 8 years ago

Its the current release version 4.0.39 and it seems to be licensed under GPL.

If I have to add every package used by quercus which is not java.* it could be a very long list. Is there a way to configure Karaf in a way that this is not needed (as is the current master branch).

kaikreuzer commented 8 years ago

Its the current release version 4.0.39 and it seems to be licensed under GPL.

This is an aspect that I completely overlooked when reviewing the cometvisu PR. :-| It actually means we cannot keep it in our repository and we cannot bundle it with the openHAB 2 distribution at all, because GPL is not at all compatible with the EPL.... @peuter: Is this an integral part of the CometVisu, which cannot be removed or made an optional part?

peuter commented 8 years ago

The CometVisu can work without quercus (as it does before in the old openhab1 binding), it only adds some nice features so that the binding fully supports all CometVisu features. As I am not familiar with the licensing issues I have some questions how to proceed.

  1. Is it possible to remove the quercus.jar from the repository and only load/add is at build time (like its done with some of the maryTTS jars) or is that not prossible? Would be the easiest way for me?
  2. If 1. is not feasible solution I could try to move quercus to an separate Osgi container, which is hosted somewhere else. But I don't now how much work it is to squeeze the quercus lib into an Osgi container (or if it is possible at all, as far as I remember I tried that back in the days and failed doing so). Also from the user point of view, it would be easier to have all in one bundle.
  3. Any other suggestion I'm currently not aware of?

@kaikreuzer Let me know what you think.

peuter commented 8 years ago

Any updates about the licensing issue?

kaikreuzer commented 8 years ago

Sorry, I didn't reply yet, because I had no good ad-hoc suggestion :-/

  1. No, adding it at build time does not help. We simply cannot ship a binary that includes it
  2. Yes, it could be a separate bundle, which the user has to download and install by himself. So if you say that the visu is also fine without it, this might be an option.
  3. I think we will have to move it to a different repository, which then can contain non-EPL stuff. Add-ons from that repo could then be made available in the online distro (i.e. the add-ons are downloaded by the user), but being included in the offline distro. So together with option 2 this might make sense: The offline distro only contains the EPL-version and the user would have to get the GPL-jar himself and put it in addons, while the online distro could pull both at once automatically.
peuter commented 8 years ago

So my personal Todo list would be:

  1. Remove Quercus from the current bundle
  2. Create a Quercus Osgi container, if possible [3.] if 2. is not possible, maintain two versions of the cometvisu bundle: light (without quercus), full (with quercus) hosted in different repositories
peuter commented 8 years ago

Small update:

Extracting Quercus from the cometvisu bundle to an extra bundle seems to be easier than I thought. But I am using other third party libraries as well (rrd4j: Apache License 2.0, sqlite-jdbc: also Apache License 2.0). Are those allowed?

And as described here: https://github.com/openhab/openhab-distro/blob/master/docs/sources/development/bindings.md As long as I do not use the org.eclipse.smarthome namespace I do not have to worry about EPL-License compability or do I get that wrong?

maggu2810 commented 8 years ago

The following is just my meaning:

Your binding code is using the EPL, Querus is using GPL. If you mix that in one bundle I am sure you violates the EPL license. This does not matter of the project that hosts your code.

If this bundle is distributed in the openhab distro, also that software bundle violates licenses etc.

kaikreuzer commented 8 years ago

Are those allowed?

Yes, Apache license is compatible with the EPL, see also https://eclipse.org/legal/eplfaq.php#3RDPARTY.

As long as I do not use the org.eclipse.smarthome namespace I do not have to worry about EPL-License compability or do I get that wrong?

You get it wrong. Although openHAB is not an Eclipse project, it is still licensed under the EPL, so we to make sure that when including 3rd party stuff, this is in line with the EPL.

peuter commented 8 years ago

OK thanks for explaining the license stuff to me. Now some technical questions.

I have extracted the quercus related stuff to a new org.openhab,io.php bundle (is the chosen namespace ok or do you have a better suggestion?), this bundle provides the IQuercusEngine Interface, which the cometvisu bundle references (). But to allow that I have to import the org.openhab.io.php package in the cometvisu bundle. And then the cometvisu bundle depends on the quercus bundle and does not start, when that one is not available.

Long story short: How do I configure this in the right way? Maybe you can point me to another bundle where this case is handled and where I can see how its done.

kaikreuzer commented 8 years ago

I have extracted the quercus related stuff to a new org.openhab,io.php bundle

Thinking about it, it would be actually ideal to have the Quercus lib directly as an OSGi bundle (com.caucho.quercus). I just looked for it, but it seems it is only a plain jar and nobody yet took this effort. But since there is no openHAB specific code in it, we do not need to put it under the openHAB namespace at all. We could just put it up on Github and put it as a jar on JCenter.

And then the cometvisu bundle depends on the quercus bundle and does not start, when that one is not available.

You can mark it as an optional import. Then the bundle will start even if this dependency is not satisfied. See e.g. here, which is also a compile time dependency, which is not fulfilled at runtime.

peuter commented 8 years ago

Ok I moved the quercus bundle to com.caucho.quercus. The package is on github: https://github.com/peuter/quercus-osgi

The cometvisu uses this bundle as import if available. But I don't know how to put it on jcenter.

maggu2810 commented 8 years ago

IMHO you should not use the group id "com.caucho" if it is not owned by yourself.

kaikreuzer commented 8 years ago

I'd suggest to move it to openhab/quercus-osgi and we can put it under groupId org.openhab with artifact id com.caucho.quercus - I can then easily make it available on JCenter like the rest.

peuter commented 8 years ago

OK I changed the group id, feel free to move it to openhab.

kaikreuzer commented 8 years ago

You actually have to do the move - you can request it in the repo settings as "transfer repository". (I just tested it with a repo to be transferred to you - simply ignore that ;-))

peuter commented 8 years ago

So is there anything else I have to do, to import the bundle from jcenter. I would like to build and test evenrything before I create a pull request, but building failes because of the missing bundle.

kaikreuzer commented 8 years ago

No, sorry, I had to do that. I have uploaded the jar to bintray and requested to have it included on jcenter. This is manually approved, so I expect that to happen tomorrow. For the time being, you can add http://dl.bintray.com/openhab/mvn as a repo to your build and you should be fine.

kaikreuzer commented 8 years ago

This is manually approved, so I expect that to happen tomorrow.

Wrong assumption, here is the feedback, I got:

Jcenter hosts java applications that follow maven convention. In addition to the .jar and pom files , your version should include a sources jar, and optionally a javadoc jar.

As we do not have sources in this repo, but only wrap the binary, creating such jars probably does not make much sense. But the good news is: We do not really need it on JCenter, since we already have the bintray repo in our pom: https://github.com/openhab/openhab2-addons/blob/master/pom.xml#L329 So all you will need is a

<dependency>
<groupId>org.openhab</groupId>
<artifactId>com.caucho.quercus</artifactId>
<version>4.0.39</version>
<type>jar</type>
</dependency>

in your pom and you should be set.

peuter commented 8 years ago

Sorry that does not work:

[INFO] Scanning for projects... [INFO] Computing target platform for MavenProject: org.openhab.binding:org.openhab.binding.astro:2.0.0-SNAPSHOT @ /home/tobiasb/develop/openhab/openhab2-master2/git/openhab2-addons/addons/binding/org.openhab.binding.astro/pom.xml [INFO] Adding repository http://download.eclipse.org/smarthome/updates-stable [INFO] Adding repository https://dl.bintray.com/kaikreuzer/openhab-core/p2/2.0.0.b1 [INFO] Adding repository http://repository-openhab.forge.cloudbees.com/release/openhab-deps-repo/1.0.0 ... [INFO] Resolving dependencies of MavenProject: org.openhab.ui:org.openhab.ui.cometvisu:2.0.0-SNAPSHOT @ /home/tobiasb/develop/openhab/openhab2-master2/git/openhab2-addons/addons/ui/org.openhab.ui.cometvisu/pom.xml [INFO] {osgi.os=linux, osgi.ws=gtk, org.eclipse.update.install.features=true, osgi.arch=x86} [ERROR] Cannot resolve project dependencies: [ERROR] Software being installed: org.openhab.ui.cometvisu 2.0.0.qualifier [ERROR] Missing requirement: org.openhab.ui.cometvisu 2.0.0.qualifier requires 'package com.caucho.java 0.0.0' but it could not be found [ERROR] [ERROR] See http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting for help. [ERROR] Cannot resolve dependencies of MavenProject: org.openhab.ui:org.openhab.ui.cometvisu:2.0.0-SNAPSHOT @ /home/tobiasb/develop/openhab/openhab2-master2/git/openhab2-addons/addons/ui/org.openhab.ui.cometvisu/pom.xml: See log for details -> [Help 1]

kaikreuzer commented 8 years ago

@dvanherbergen Shouldn't it work now that Tycho resolves such a dependency from the pom.xml of the project? Do you have any hint?

dvanherbergen commented 8 years ago

I would expect so. @peuter, is this in a repo somewhere that I can clone to test?

peuter commented 8 years ago

@dvanherbergen Sure:

https://github.com/peuter/openhab2-addons/tree/cometvisu2-light

dvanherbergen commented 8 years ago

There is a problem with the jar. When I build the repo, it downloads https://dl.bintray.com/openhab/mvn/org/openhab/com.caucho.quercus/4.0.39/com.caucho.quercus-4.0.39.jar but this doesn't have any exports in the manifest:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: kai
Created-By: Apache Maven 3.3.3
Build-Jdk: 1.8.0_40
dvanherbergen commented 8 years ago

Keep in mind that if the jar is updated, then you'll need to build with the -U option to force it to reload the jar.

kaikreuzer commented 8 years ago

Good point! @peuter I created the jar by simply running mvn deploy on your project - I guess we will have to add OSGi specific building info to it, e.g. using the maven-bundle-plugin. Would you want to give it a try?

peuter commented 8 years ago

I tried to fix the problem. But I think it is still not right, at least the manifest with the right exports is used now. But I don't think that I included the quercus.jar in the right way. @kaikreuzer Can you do that, or explain what I have to do in detail?

peuter commented 8 years ago

Ok I think I fixed the pom now. At least mvn deploy/install generates a bundle with the correct manifest.

kaikreuzer commented 8 years ago

Congrats, looks good! I have just deployed the latest jar to Bintray!

peuter commented 8 years ago

Sorry but I'm stillhaving trouble to get it working. The IDE doesn't seem to find the coucho bundle and is complaining about missing com.caucho imports. Additionally it shows an 4 errors in my pom.xml like:

Plugin execution not covered by lifecycle configuration: org.eclipse.tycho:tycho-compiler-plugin:0.24.0:compile (execution: default-compile, phase: compile)

I have compared my pom.xml with others and can't find out what is causing this error. And when I build the whole project with mvn install the build completes without errors. Bunt when I start the offline distro, activate the cometvisu bundle all I see is this:

[ab.ui.cometvisu.servlet.CometVisuApp] - Started CometVisu UI at /cometvisu serving ../../develop/cometvisu/src/ [ab.ui.cometvisu.servlet.CometVisuApp] - Stopped CometVisu UI [smarthome.event.ExtensionEvent ] - Extension 'ui-cometvisu' has been installed.

The bundle is marked as active but the cometvisu is not running (and btw. the coucho bundle has not been loaded).

So a lot of problems and no clue how to solve any of them. Do you have any ideas?

kaikreuzer commented 8 years ago

The IDE doesn't seem to find the coucho bundle and is complaining about missing com.caucho imports.

What helps to make it compile in the IDE is to activate m2e (Configure->Convert to Maven project), which should download the dependency and add it to the build path.

Plugin execution not covered by lifecycle configuration

There is usually a quick fix option available that suppresses these messages.

The bundle is marked as active but the cometvisu is not running

Are all your components (in OSGI-INF) marked as immediate=true?

the coucho bundle has not been loaded

Did you include it as a second bundle in the cometvisu feature?

peuter commented 8 years ago

Ok I found at least one problem: The com.caucho.quercus bundle on bintray does not include the quercus.jar file. I am not able to configure the pom.xml correctly, that it includes the jar. I am pretty sure that it used to work once and have no idea what has happened.

kaikreuzer commented 8 years ago

That's indeed a problem, sorry that I didn't notice it either... I don't know either what needs to be changed in the pom.xml to have the jar correctly included, but I'd hope that it should not be too hard.

peuter commented 8 years ago

Ok, it wasn't that easy. The only thing worked, was creating a local repository, deploying the jar file to it and add it as a dependency that must be included. Not really straightforward, though!

I hope the local repository is working when you check out the changes and deploy the bundle, so "fingers-crossed".

peuter commented 8 years ago

@kaikreuzer Have you tried to build and Update the bundle on bintray yet?

kaikreuzer commented 8 years ago

Sorry, didn't try it yet, but now it is uploaded. This local repo workaround looks pretty weird, though. I am pretty sure that there is a simpler way, but since I do not have the time to look for it myself, it is ok for now as long as it works.

peuter commented 8 years ago

The workaround is not working either, because the bundle does not use the incuded jar. After spending two full days trying to solve this problem, it feels like I'm runnings against walls and I'm sick of it. I really have no idea how to get this running.

I commited the last version to quercus-osgi. It uses a maven-compatible fork from quercus from the maven repository. It can be build/installed fine, but is not useable by the cometvisu bundle because of missing dependencies. Manually adding those dependencies didn't work.

So I'm stuck here and I won't spend more of my time on this as I do not believe that I can find a solution. I'm wondering why I am running in so many problems when I try to generate a bundle from a jar, which I don't have when I use it directly. Anyway maybe a maven/osgi expert can find a solution for this, I won't!

kaikreuzer commented 8 years ago

Sorry to hear that you had to give up... Maybe an OSGi expert like @dvanherbergen can help on the right packaging?

dvanherbergen commented 8 years ago

I can have a look. How can I test this?

peuter commented 8 years ago

You can find the quercus-package here: https://github.com/openhab/quercus-osgi

And the openhab-binding that needs it here: https://github.com/peuter/openhab2-addons/tree/cometvisu2-light

in the addons/ui/org.openhab.ui.cometvisu folder. The current problem is, that I cannot build the cometvisu bundle due to dependency problems in the quercus-osgi package.

dvanherbergen commented 8 years ago

I've created a PR on the quercus repo. I've changed the build to use the caucho quercus. This one has fewer dependencies. I've also changed to build process so that it shades the original jar rather than trying to embed it. I've updated the build number to 1.0.0 as this is the first release of the openhab quercus, so it doesn't need to use the version number of quercus.

The new bundle loads fine in Karaf, but I haven't tested this with cometvisu. In OH2, the pom for cometvisu also doesn't have any dependencies on this jar, is this work in progress?

dvanherbergen commented 8 years ago

@peuter could you test the updated version? You will need to do the following:

<dependency>
    <groupId>org.openhab</groupId>
    <artifactId>com.caucho.quercus</artifactId>
    <version>1.0.0</version>
</dependency>
<bundle start-level="80">mvn:org.openhab/com.caucho.quercus/1.0.0</bundle>
dvanherbergen commented 8 years ago

FYI, it is possible that the karaf feature build will not find the dependency from the local maven repo. It may need to be deployed to bintray first.

maggu2810 commented 8 years ago

Why not using the maven-bundle-plugin to get IMHO better import and export package manifest entries? https://github.com/maggu2810/quercus-osgi/blob/maven-bundle-plugin/com.caucho.quercus/pom.xml

I set resolution to optional because I assume you do not use all that stuff.

dvanherbergen commented 8 years ago

@maggu2810, feel free to create PR...