Closed fipro78 closed 5 years ago
Hi Wim. I've fixed this issue. It resulted in a simpler and more general structure in this support super class: JaxRSServerContainer. I tested with two instances of the same service.
Unfortunately, there is a problem with CXF's implementation that I haven't been able to figure out. CXF has a relatively complicated architecture that allows it to support multiple types of bindings (e.g. jaxrs, soap, etc). It was also created to do service export at startup time rather than runtime, and so I may have to implement a servlet class that allows runtime updates. CXF will still export a single service export...as are in the examples...but throws an exception when the second service is exported.
The Jersey distribution provider supports 2+ exports with no problems. Since CXF is not finished I will leave this issue open, but I've updated the title,
I've created a 1.6.0 release that includes these changes:
Sorry Dirk...not Wim.
But my example is using jersey and not cxf. So IMHO it is not only related to cxf.
Scott Lewis notifications@github.com schrieb am Fr., 19. Okt. 2018, 21:26:
Sorry Dirk...not Wim.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ECF/JaxRSProviders/issues/13#issuecomment-431472882, or mute the thread https://github.com/notifications/unsubscribe-auth/AC5qo9xn4p-EPcuRxPxZ5KrbDSHbWgksks5umidngaJpZM4XucRx .
Your multi-service example should now work fine with Jersey distribution provider. I've changed the subject back and closing this issue. I'll open a new issue for CXF's remaining issues.
Hi Dirk. I don't think I was clear enough about the fix applied just now. The fix was applied in the JaxRSServerContainer class, which is a superclass of both Jersey and CXF distribution provider impl. So that should fix any issues with multiple exports for Jersey...and it should have fixed them for CXF as well, but I uncovered another issue wrt multiple exports for CXF specifically and have opened issue 14 for that.
Hi Scott, I just updated and now get a NPE on startup.
java.lang.NullPointerException at org.eclipse.ecf.provider.jaxrs.server.JaxRSServerContainer.getHttpService(JaxRSServerContainer.java:95) at org.eclipse.ecf.provider.jaxrs.server.JaxRSServerContainer.exportRemoteService(JaxRSServerContainer.java:136) at org.eclipse.ecf.remoteservice.RSARemoteServiceContainerAdapter$RSARemoteServiceRegistration.publish(RSARemoteServiceContainerAdapter.java:53) at org.eclipse.ecf.remoteservice.RemoteServiceContainerAdapterImpl.registerRemoteService(RemoteServiceContainerAdapterImpl.java:123) at org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.exportService(RemoteServiceAdmin.java:2156)
Looks like a startup ordering issue. It started fine before. All bundles are started and org.apache.felix.http.jetty is up and running. Any ideas?
I agree it looks like a startup ordering issue with jetty and httpservice. I didn't see this in any of my tests, but I mostly tested in karaf and bndtools/felix which have their own launch assumptions. What environment are you running in and how are you launching? (e.g. eclipse, equinox w launch config, etc?).
Actually I use bndtools and felix. I updated my examples just now: https://github.com/fipro78/access_osgi_services
Ok I've loaded your projects and am (happily) also getting this NPE. I don't understand why yet, but I'll let you know when I do.
I created issue 15 for this. I've removed the HttpServiceHolder stuff, and as a result fixed issue 15 also. Created and released version 1.6.1.
With the new version (1.5.1) of org.eclipse.ecf.provider.jaxrs.server bundle, I'm able to launch your remote_server_launch.bndrun and have it successfully export the ModifierService with Jersey provider. In resolution I had to add some optional dependencies (in jersey) to your bndrun runbundles...here is the copy that worked properly for me (o.e.e.provider.jaxrs.server 1.5.1):
-runfw: org.apache.felix.framework;version='[6.0.1,6.0.1]' -runee: JavaSE-1.8
-runsystemcapabilities: ${native_capability}
-resolve.effective: active;skip:="osgi.service"
-runbundles: \ com.fasterxml.jackson.core.jackson-annotations;version='[2.9.2,2.9.3)',\ com.fasterxml.jackson.core.jackson-core;version='[2.9.2,2.9.3)',\ com.fasterxml.jackson.core.jackson-databind;version='[2.9.2,2.9.3)',\ com.fasterxml.jackson.jaxrs.jackson-jaxrs-base;version='[2.9.2,2.9.3)',\ com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider;version='[2.9.2,2.9.3)',\ javassist;version='[3.13.0,3.13.1)',\ javax.inject;version='[1.0.0,1.0.1)',\ javax.persistence;version='[2.2.0,2.2.1)',\ javax.validation.api;version='[1.1.0,1.1.1)',\ org.aopalliance;version='[1.0.0,1.0.1)',\ org.apache.felix.eventadmin;version='[1.5.0,1.5.1)',\ org.apache.felix.gogo.command;version='[1.0.2,1.0.3)',\ org.apache.felix.gogo.runtime;version='[1.1.0,1.1.1)',\ org.apache.felix.gogo.shell;version='[1.1.0,1.1.1)',\ org.apache.felix.http.jetty;version='[4.0.6,4.0.7)',\ org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\ org.apache.felix.scr;version='[2.1.10,2.1.11)',\ org.eclipse.core.jobs;version='[3.9.3,3.9.4)',\ org.eclipse.ecf;version='[3.9.2,3.9.3)',\ org.eclipse.ecf.discovery;version='[5.0.300,5.0.301)',\ org.eclipse.ecf.identity;version='[3.9.1,3.9.2)',\ org.eclipse.ecf.osgi.services.remoteserviceadmin;version='[4.6.800,4.6.801)',\ org.eclipse.ecf.osgi.services.remoteserviceadmin.proxy;version='[1.0.100,1.0.101)',\ org.eclipse.ecf.provider.jaxrs;version='[1.3.0,1.3.1)',\ org.eclipse.ecf.remoteservice;version='[8.13.1,8.13.2)',\ org.eclipse.ecf.remoteservice.asyncproxy;version='[2.1.0,2.1.1)',\ org.eclipse.equinox.common;version='[3.9.0,3.9.1)',\ org.eclipse.equinox.concurrent;version='[1.1.0,1.1.1)',\ org.eclipse.equinox.supplement;version='[1.7.0,1.7.1)',\ org.eclipse.osgi.services.remoteserviceadmin;version='[1.6.200,1.6.201)',\ org.glassfish.hk2.api;version='[2.5.0,2.5.1)',\ org.glassfish.hk2.locator;version='[2.5.0,2.5.1)',\ org.glassfish.hk2.osgi-resource-locator;version='[2.5.0,2.5.1)',\ org.glassfish.hk2.utils;version='[2.5.0,2.5.1)',\ org.glassfish.jersey.bundles.repackaged.jersey-guava;version='[2.22.1,2.22.2)',\ org.glassfish.jersey.containers.servlet.core;version='[2.22.1,2.22.2)',\ org.glassfish.jersey.core.jersey-client;version='[2.22.1,2.22.2)',\ org.glassfish.jersey.core.jersey-common;version='[2.22.1,2.22.2)',\ org.glassfish.jersey.core.jersey-server;version='[2.22.1,2.22.2)',\ org.glassfish.jersey.ext.entityfiltering;version='[2.22.1,2.22.2)',\ org.glassfish.jersey.media.jersey-media-json-jackson;version='[2.22.1,2.22.2)',\ org.eclipse.ecf.osgi.services.distribution;version='[2.1.200,2.1.201)',\ org.eclipse.ecf.provider.jmdns;version='[4.3.200,4.3.201)',\ org.fipro.modifier.api;version=snapshot,\ org.fipro.modifier.inverter;version=snapshot,\ org.fipro.modifier.remote.api;version=snapshot,\ org.fipro.modifier.remote.server;version=snapshot,\ org.fipro.modifier.uppercase;version=snapshot,\ org.osgi.util.function;version='[1.1.0,1.1.1)',\ org.eclipse.ecf.provider.jersey.server;version='[1.4.0,1.4.1)',\ org.apache.servicemix.specs.annotation-api-1.3;version='[1.3.0,1.3.1)',\ org.eclipse.ecf.provider.jaxrs.server;version='[1.5.1,1.5.2)',\ javax.ws.rs;version='[2.0.1,2.0.2)'
-runrequires: \ osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\ osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\ bnd.identity;id='org.eclipse.ecf.discovery',\ bnd.identity;id='org.eclipse.ecf.identity',\ bnd.identity;id='org.eclipse.ecf.osgi.services.remoteserviceadmin',\ bnd.identity;id='org.eclipse.ecf.provider.jaxrs',\ bnd.identity;id='org.eclipse.ecf.provider.jaxrs.server',\ bnd.identity;id='org.eclipse.ecf.provider.jersey.server',\ osgi.identity;filter:='(&(osgi.identity=javax.validation.api)(version>=1.1.0))',\ osgi.identity;filter:='(&(osgi.identity=org.glassfish.hk2.locator)(version>=2.5.0))',\ osgi.identity;filter:='(&(osgi.identity=org.glassfish.jersey.core.jersey-client)(version>=2.22.1))',\ bnd.identity;id='org.apache.felix.http.jetty',\ bnd.identity;id='org.eclipse.ecf.osgi.services.distribution',\ bnd.identity;id='org.eclipse.ecf.provider.jmdns',\ bnd.identity;version='latest';id='org.fipro.modifier.api',\ bnd.identity;version='latest';id='org.fipro.modifier.inverter',\ bnd.identity;version='latest';id='org.fipro.modifier.uppercase',\ bnd.identity;version='latest';id='org.fipro.modifier.remote.api',\ bnd.identity;version='latest';id='org.fipro.modifier.remote.server',\ osgi.identity;filter:='(&(osgi.identity=javax.ws.rs)(version>=2.0.1))' -runvm: -Dorg.osgi.service.http.port=8080
Please LMK if this doesn't work for you.
I verified this and updated my example. Thanks for the quick fix!
Hi Dirk.
Since you are using gogo, you might want to add the following ecf bundle to bndrun requirements: org.eclipse.ecf.osgi.services.remoteserviceadmin.console
it adds gogo console commands for listing/viewing RSA state as well as importing/unimporting and exporting/unexporting at runtime. And it allows for turning off/on endpoint events. More details here
https://wiki.eclipse.org/Gogo_Commands_for_Remote_Services_Development
Also...fyi I fixed something in the JaxRS server code that did not function properly in some environments...now 1.6.2 here: https://github.com/ECF/JaxRSProviders/releases
It does not work to export two services from one bundle via JAX-RS distribution provider. I simply tried to copy and slightly modify an existing service (different path and classname) and I even tried to export a different service. In both cases I get the following exception:
[log;+0200 2018.10.18 20:37:30:983;ERROR;org.eclipse.ecf.osgi.services.remoteserviceadmin;org.eclipse.core.runtime.Status[plugin=org.eclipse.ecf.osgi.services.remoteserviceadmin;code=4;message=org.eclipse.ecf.osgi.services.remoteserviceadmin.TopologyManagerImpl:handleRemoteAdminEvent.EXPORT_ERROR:Export error with event=RemoteServiceAdminEvent[containerID=null, getType()=6, getSource()=org.eclipse.ecf.osgi.services.remoteserviceadmin [23], getException()=java.lang.RuntimeException: JaxRSServerContainer=http://localhost:8080/ cannot has already exported registration=RemoteServiceRegistrationImpl[remoteServiceID=org.eclipse.ecf.remoteservice.RemoteServiceID[containerID=URIID [uri=http://localhost:8080/];containerRelativeID=1];rserviceranking=0;classes=[org.fipro.modifier.remote.api.ModifierService];state=0;properties={osgi.confidential=intent, ordered=intent, osgi.basic.timeout=50000, jaxrs=intent, osgi.private=intent, exactlyOnce=intent, osgi.async=intent, ecf.rsvc.id=1, passByValue=intent}], getImportReference()=null, getExportReference()=null];severity4;exception=null;children=[]]]
It looks like the containerRelativeID is not incremented per exported service.