Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse Communications Framework (ECF) » Setting endpoint URL context - JAX-RS, Jersey, Jetty(A "1" is being appended to the URI definition which I want to replace)
Setting endpoint URL context - JAX-RS, Jersey, Jetty [message #1793089] Tue, 31 July 2018 03:21 Go to next message
Eclipse UserFriend
There is a "1" being appended to the Jetty context definition. I don't know where that is coming from and I'd like to replace it with a context name of my choice. As it stands, I have to enter:
http://localhost:8080/1/helloworld/hello
to access my service.

I'm on Photon, with the following ECF bundles installed:
ECF Remote Services Examples Developer Resources	1.0.100.v20180502-2137	
    ECF Distributed EventAdmin Examples Developer Resources	1.0.100.v20180302-1843
    ECF Remote Services Examples Developer Resources	1.5.100.v20180502-2137

ECF Remote Services SDK	3.14.0.v20180518-0149
    ECF Discovery	1.0.100.v20180306-0211
    ECF Discovery SLP (RFC 2608) Provider	1.0.0.v20180426-1936
    ECF Discovery Zeroconf Provider	1.0.0.v20180306-0429
    ECF Discovery Zookeeper Provider	1.0.0.v20180302-2006
    ECF Distributed EventAdmin	2.0.100.v20180426-2032
    ECF Generic Provider Feature	1.0.100.v20180402-2103
    ECF Generic Provider RemoteService Feature	1.1.100.v20180516-2213
    ECF Generic Server	1.1.100.v20180302-2006	
    ECF Remote Services	2.5.0.v20180409-2248
    ECF Remote Services Admin	2.3.1.v20180518-0149
    ECF Remote Services R-OSGi Provider	1.1.0.v20180516-2213
    ECF Remote Services REST Support	1.0.100.v20180302-2006
    ECF Remote Services Servlet API Feature	1.0.100.v20180302-2006
    ECF SharedObject Feature	1.0.100.v20180404-2345
 ECF Remote Services SDK Developer Resources	3.14.0.v20180518-0149
    ECF Discovery Developer Resources	1.0.100.v20180306-0211
    ECF Discovery SLP (RFC 2608) Provider Developer Resources	1.0.0.v20180426-1936
    ECF Discovery Zeroconf Provider Developer Resources	1.0.0.v20180306-0429
    ECF Discovery Zookeeper Provider Developer Resources	1.0.0.v20180302-2006
    ECF Distributed EventAdmin Developer Resources	2.0.100.v20180426-2032
    ECF Generic Provider Feature Developer Resources	1.0.100.v20180402-2103	
    ECF Generic Provider RemoteService Feature Developer Resources	1.1.100.v20180516-2213
    ECF Generic Server Developer Resources	1.1.100.v20180302-2006	
    ECF Remote Services Admin Developer Resources	2.3.1.v20180518-0149
    ECF Remote Services Developer Resources	2.5.0.v20180409-2248
    ECF Remote Services R-OSGi Provider Developer Resources	1.1.0.v20180516-2213
    ECF Remote Services REST Support Developer Resources	1.0.100.v20180302-2006
    ECF Remote Services Servlet API Feature Developer Resources	1.0.100.v20180302-2006
    ECF SharedObject Feature Developer Resources	1.0.100.v20180404-2345
ECF SDK for Eclipse	3.14.0.v20180302-2126
    ECF Remote Services Examples	1.0.100.v20180502-2137
ECF SDK for Eclipse Developer Resources	3.14.0.v20180302-2126


My configuration file looks like this:

# Required OSGi Remote Service Property indicating that the StudentService should
# be exported
service.exported.interfaces=*
service.intents=osgi.async
# this one surprises me - ??
service.intents=jaxrs

# Optional OSGi Remote Service Property indicating that the ecf.jaxrs.jersey.server
# distribution provider should be used to export this service
service.exported.configs=ecf.jaxrs.jersey.server

# Distribution-provider property defining the alias prefix for the Jersey server
ecf.jaxrs.jersey.server.alias=/jersey

# this one I got from reading the code - it does change the separator
ecf.jaxrs.jersey.server.pathPrefix=/

# this seems to do nothing
ecf.jaxrs.jersey.server.urlPrefix=/server

# Other Jersey properties that could be defined
# got this one from reading code - it seems to do nothing
ecf.jaxrs.jersey.server.urlContext=/urlctx

# I think this might be a spelling mistake in the examples?
osgi.basic.timeoute=50000


However, the resulting exported registration looks as follows - notice the URL: http://localhost:8080/1

My question is - how to replace the "1" with a context of my choice?

19:10:08.955;EXPORT_REGISTRATION;exportedSR={com.dsct.test.jaxrs.IHelloWorld}={service.intents=jaxrs, service.exported.configs=ecf.jaxrs.jersey.server, ecf.jaxrs.jersey.server.alias=/jersey, service.id=37, service.bundleid=2, service.scope=bundle, ecf.jaxrs.jersey.server.urlPrefix=/server, ecf.jaxrs.jersey.server.urlContext=/urlctx, ecf.jaxrs.jersey.server.pathPrefix=/, component.name=com.dsct.test.jaxrs.HelloWorldImpl, service.exported.interfaces=*, component.id=2, osgi.basic.timeoute=50000};cID=URIID [uri=http://localhost:8080/1]; rsId=1
--Endpoint Description---
<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0">
  <endpoint-description>
    <property name="ecf.endpoint.id" value-type="String" value="http://localhost:8080/1"/>
    <property name="ecf.endpoint.id.ns" value-type="String" value="ecf.namespace.jaxrs"/>
    <property name="ecf.endpoint.ts" value-type="Long" value="1533003003466"/>
    <property name="ecf.jaxrs.jersey.server.alias" value-type="String" value="/jersey"/>
    <property name="ecf.jaxrs.jersey.server.pathPrefix" value-type="String" value="/"/>
    <property name="ecf.jaxrs.jersey.server.urlContext" value-type="String" value="/urlctx"/>
    <property name="ecf.jaxrs.jersey.server.urlPrefix" value-type="String" value="/server"/>
    <property name="ecf.rsvc.id" value-type="Long" value="1"/>
    <property name="endpoint.framework.uuid" value-type="String" value="f083dcba-3d98-4a20-8643-d340bb28f4d3"/>
    <property name="endpoint.id" value-type="String" value="636bdd3b-db26-41ec-af53-735ccad02385"/>
    <property name="endpoint.service.id" value-type="Long" value="37"/>
    <property name="objectClass" value-type="String">
      <array>
        <value>com.dsct.test.jaxrs.IHelloWorld</value>
      </array>
    </property>
    <property name="osgi.basic.timeoute" value-type="String" value="50000"/>
    <property name="remote.configs.supported" value-type="String">
      <array>
        <value>ecf.jaxrs.jersey.server</value>
      </array>
    </property>
    <property name="remote.intents.supported" value-type="String">
      <array>
        <value>passByValue</value>
        <value>exactlyOnce</value>
        <value>ordered</value>
        <value>osgi.async</value>
        <value>osgi.private</value>
        <value>osgi.confidential</value>
        <value>jaxrs</value>
      </array>
    </property>
    <property name="service.imported" value-type="String" value="true"/>
    <property name="service.imported.configs" value-type="String">
      <array>
        <value>ecf.jaxrs.jersey.server</value>
      </array>
    </property>
    <property name="service.intents" value-type="String" value="jaxrs"/>
  </endpoint-description>
</endpoint-descriptions>
---End Endpoint Description


Any help appreciated. I'm an ECF noobe so this may be a trivial question but I've spent hours trying to find docs or a combo of properties that work.
Re: Setting endpoint URL context - JAX-RS, Jersey, Jetty [message #1793155 is a reply to message #1793089] Tue, 31 July 2018 17:21 Go to previous messageGo to next message
Scott Lewis is currently offline Scott LewisFriend
Messages: 1038
Registered: July 2009
Senior Member
Dale Smith wrote on Mon, 30 July 2018 23:21
There is a "1" being appended to the Jetty context definition. I don't know where that is coming from and I'd like to replace it with a context name of my choice. As it stands, I have to enter:
http://localhost:8080/1/helloworld/hello
to access my service.

I'm on Photon, with the following ECF bundles installed:
ECF Remote Services Examples Developer Resources	1.0.100.v20180502-2137	
    ECF Distributed EventAdmin Examples Developer Resources	1.0.100.v20180302-1843
    ECF Remote Services Examples Developer Resources	1.5.100.v20180502-2137

ECF Remote Services SDK	3.14.0.v20180518-0149
    ECF Discovery	1.0.100.v20180306-0211
    ECF Discovery SLP (RFC 2608) Provider	1.0.0.v20180426-1936
    ECF Discovery Zeroconf Provider	1.0.0.v20180306-0429
    ECF Discovery Zookeeper Provider	1.0.0.v20180302-2006
    ECF Distributed EventAdmin	2.0.100.v20180426-2032
    ECF Generic Provider Feature	1.0.100.v20180402-2103
    ECF Generic Provider RemoteService Feature	1.1.100.v20180516-2213
    ECF Generic Server	1.1.100.v20180302-2006	
    ECF Remote Services	2.5.0.v20180409-2248
    ECF Remote Services Admin	2.3.1.v20180518-0149
    ECF Remote Services R-OSGi Provider	1.1.0.v20180516-2213
    ECF Remote Services REST Support	1.0.100.v20180302-2006
    ECF Remote Services Servlet API Feature	1.0.100.v20180302-2006
    ECF SharedObject Feature	1.0.100.v20180404-2345
 ECF Remote Services SDK Developer Resources	3.14.0.v20180518-0149
    ECF Discovery Developer Resources	1.0.100.v20180306-0211
    ECF Discovery SLP (RFC 2608) Provider Developer Resources	1.0.0.v20180426-1936
    ECF Discovery Zeroconf Provider Developer Resources	1.0.0.v20180306-0429
    ECF Discovery Zookeeper Provider Developer Resources	1.0.0.v20180302-2006
    ECF Distributed EventAdmin Developer Resources	2.0.100.v20180426-2032
    ECF Generic Provider Feature Developer Resources	1.0.100.v20180402-2103	
    ECF Generic Provider RemoteService Feature Developer Resources	1.1.100.v20180516-2213
    ECF Generic Server Developer Resources	1.1.100.v20180302-2006	
    ECF Remote Services Admin Developer Resources	2.3.1.v20180518-0149
    ECF Remote Services Developer Resources	2.5.0.v20180409-2248
    ECF Remote Services R-OSGi Provider Developer Resources	1.1.0.v20180516-2213
    ECF Remote Services REST Support Developer Resources	1.0.100.v20180302-2006
    ECF Remote Services Servlet API Feature Developer Resources	1.0.100.v20180302-2006
    ECF SharedObject Feature Developer Resources	1.0.100.v20180404-2345
ECF SDK for Eclipse	3.14.0.v20180302-2126
    ECF Remote Services Examples	1.0.100.v20180502-2137
ECF SDK for Eclipse Developer Resources	3.14.0.v20180302-2126


My configuration file looks like this:

# Required OSGi Remote Service Property indicating that the StudentService should
# be exported
service.exported.interfaces=*
service.intents=osgi.async
# this one surprises me - ??
service.intents=jaxrs



I added this intent to this distribution provider, since this distribution provider requires usage of the jaxrs annotations.

It's basically saying: This remote service needs a jaxrs distribution provider because of the annotations. It's currently satisfied by both Jersey and CXF distribution providers.

It's not standardized like osgi.async, but it does allow a constraint to be placed upon the export such that either Jersey or CXF (or other, potentially) can be selected.

Quote:

# Optional OSGi Remote Service Property indicating that the ecf.jaxrs.jersey.server
# distribution provider should be used to export this service
service.exported.configs=ecf.jaxrs.jersey.server

# Distribution-provider property defining the alias prefix for the Jersey server
ecf.jaxrs.jersey.server.alias=/jersey


This alias property is no longer valid. In an older version of the JaxRSDistributionProvider I had used '.alias' and I decided that it would be better to a) standardize the property names for both Jersey and CXF; b) move the code for those properties into a common superclass. That superclass is:

https://github.com/ECF/JaxRSProviders/blob/master/bundles/org.eclipse.ecf.provider.jaxrs.server/src/org/eclipse/ecf/provider/jaxrs/server/JaxRSServerContainerInstantiator.java

The public static final *_PROP are the prop names (relative to the <config id>.<propname>...e.g. ecf.jaxrs.jersey.server.pathPrefix. I need to document these fully:

https://github.com/ECF/JaxRSProviders/issues/11

Quote:

# this one I got from reading the code - it does change the separator
ecf.jaxrs.jersey.server.pathPrefix=/



Yes. It adds a path prefix e.g. http://localhost:8080<pathPrefix>/1

For example if ecf.jaxrs.jersey.server.pathPrefix=/foo, the servlet will be registered under:

http://localhost:8080/foo/1

However...there is a bug:

https://github.com/ECF/JaxRSProviders/issues/10

That puts the wrong endpoint id in the endpoint description...e.g. with the example above it puts:

http://localhost:8080/foo/foo/1

into the endpoint description even though it actually is exported at: http://localhost:8080/foo/1

Quote:

# this seems to do nothing
ecf.jaxrs.jersey.server.urlPrefix=/server



This is a bug. I've opened this issue:

https://github.com/ECF/JaxRSProviders/issues/9

If you can live with it temporarily, it will work if the System property with same name is set...e.g.

-Decf.jaxrs.jersey.server.urlPrefix=http://myhost:2222

What this does is replace the *entire* urlPrefix with the string value...no matter how the HttpService is configured. The other properties (protocol, hostname, port, pathPrefix) are ignored if this is set.

It's usually going to be desirable to set the protocol, hostname and port separately using the appropriate props, but urlPrefix is present to allow certain edge cases.

Quote:

# Other Jersey properties that could be defined
# got this one from reading code - it seems to do nothing
ecf.jaxrs.jersey.server.urlContext=/urlctx



urlContext was also previously used, and is no longer valid for the same reasons given above.

Quote:

# I think this might be a spelling mistake in the examples?
osgi.basic.timeoute=50000



Yes you are right. I think this has already been fixed, though, so if you create a new workspace with the latest bndtools template (I assume you are using the bndtools example project templates?), the extra 'e' should be gone.

For reference, the bndtools example templates are in this repo:

https://github.com/ECF/bndtools.templates

[quote]
However, the resulting exported registration looks as follows - notice the URL: [url]http://localhost:8080/1[/url]

My question is - how to replace the "1" with a context of my choice?


So...with the pathPrefix handling fixed as per issue

https://github.com/ECF/JaxRSProviders/issues/10

this will create an endpoint/url:

http://localhost:8080<pathPrefix>/<remoteserviceid>

e.g.

http://localhost:8080<pathPrefix>/<remoteserviceid>

The reason the remoteserviceid is currently required is that with the CXF distribution provider, there does not currently seem to be a way (I've asked on mailing list) to *remove* a path->resource mapping in the servlet class I'm using:

org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet

To work around this, and still support OSGi Remote Service dynamics (where multiple service instances can come and go dynamically) it currently registers/unregisters a Servlet instance for each separate service instance. The remoteserviceid uniquely identifies these service instances and so is the most natural/shortest to use.

I would be willing to create a CXF servlet class to fix this, but would need some more information wrt CXF on how this would be done.

I don't think Jersey jaxrs impl has the same issues, but just for simplicity I wanted to use the same strategy for both providers.

I will plan on fixing these two issues this week and producing a new release of JaxRS distribution providers (v1.5.1) by this coming weekend.

Quote:

<stuff deleted>

Any help appreciated. I'm an ECF noobe so this may be a trivial question but I've spent hours trying to find docs or a combo of properties that work.


My apologies about the properties. The JaxRSDistribution provider is quite new (as opposed to ECF Remote Services), and I still haven't been able to document all the configuration properties, but I have now opened an issue to that effect:

https://github.com/ECF/JaxRSProviders/issues/11

I will, however, fix these issues and update the JaxRSDistributionProvider as quickly as possible.
Re: Setting endpoint URL context - JAX-RS, Jersey, Jetty [message #1793160 is a reply to message #1793155] Tue, 31 July 2018 18:44 Go to previous messageGo to next message
Eclipse UserFriend
Gosh - this is great, thanks so much for your help and the information, way more than I expected....
Re: Setting endpoint URL context - JAX-RS, Jersey, Jetty [message #1793163 is a reply to message #1793160] Tue, 31 July 2018 19:32 Go to previous messageGo to next message
Scott Lewis is currently offline Scott LewisFriend
Messages: 1038
Registered: July 2009
Senior Member
Dale Smith wrote on Tue, 31 July 2018 14:44
Gosh - this is great, thanks so much for your help and the information, way more than I expected....


With the JaxRSProviders being relatively new, it's to be expected that there are some things to finish up...e.g. small bugs, documentation, etc and your patience is appreciated there.

I've fixed the two code issues that I opened:

https://github.com/ECF/JaxRSProviders/issues/10
https://github.com/ECF/JaxRSProviders/issues/9

but have something to ask you: Would you like a new release (1.5.1) right away or would you prefer to wait a short while (2 weeks) before 1.5.1 is done? Reason I ask is that after this week I'm going to be more occupied and so may not be able to get to things right away. But will still respond to new issues with this distribution provider since it's just getting going.
Re: Setting endpoint URL context - JAX-RS, Jersey, Jetty [message #1793173 is a reply to message #1793163] Tue, 31 July 2018 22:07 Go to previous messageGo to next message
Eclipse UserFriend
I'm happy to wait... this isn't stopping my development or forcing ugly workarounds, so no rush...
Re: Setting endpoint URL context - JAX-RS, Jersey, Jetty [message #1793235 is a reply to message #1793173] Wed, 01 August 2018 23:58 Go to previous message
Scott Lewis is currently offline Scott LewisFriend
Messages: 1038
Registered: July 2009
Senior Member
Dale Smith wrote on Tue, 31 July 2018 18:07
I'm happy to wait... this isn't stopping my development or forcing ugly workarounds, so no rush...


Turns out it was better for me to do right away as next week I'm going to be occupied

See https://github.com/ECF/JaxRSProviders

and the 1.5.1 release

https://github.com/ECF/JaxRSProviders/releases

I've also created a wiki page describing the Jersey and CXF configuration properties,value type, and defaults:

https://github.com/ECF/JaxRSProviders/wiki/JaxRS-Distribution-Provider-Configuration-Properties

Thanks.


Previous Topic:Setting endpoint URL context - JAX-RS, Jersey, Jetty
Next Topic:httpclient4 - Feature
Goto Forum:
  


Current Time: Fri Mar 29 15:16:20 GMT 2024

Powered by FUDForum. Page generated in 0.02247 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top