java - Apache FELIX JAX-RS Change context path -


i develop rest web service , expose in bundle under felix. i'm using jax-rs connector web service. service works fine if want access resource template url

http://ip:port/services/path/to/my/resource

the goal change context path services access resource url http://ip:port/path/to/my/resource

i tried change admin config has been described in faq of jax-rs connector still have problem

servicereference configurationadminreference = bundlecontext.getservicereference(configurationadmin.class.getname()); if(configurationadminreference != null) {     configurationadmin confadmin = (configurationadmin) bundlecontext.getservice(configurationadminreference);     if(confadmin != null) {         configuration configconnector = confadmin.getconfiguration("com.eclipsesource.jaxrs.connector",null);          dictionary<string, string> props = configconnector.getproperties()         if (props == null) {             dictionary<string, string> props = new hashtable<string,string>();          }         props.put("root","/");             configconnector.update(props);     } } 

i have seen have problem in forum in case doesn't solve problem can see in felix web console following error message

error: pid "com.eclipsesource.jaxrs.connector" bound "file:/c:/dev/tools/apache/felix/bundle/mybundle-1.0.0.jar" actual managed service registered "inputstream:publisher-4.3.jar" bundle

any idea ?

your code results in nullpointerexception when configconnector.getproperties() returns null, you're declaring new variable props in if-clause rather assigning new hashtable instance existing variable.

once fixed might run issue: https://github.com/hstaudacher/osgi-jax-rs-connector/issues/114

the following code works:

    org.osgi.service.cm.configuration configuration = configurationadmin.getconfiguration("com.eclipsesource.jaxrs.connector", null);     dictionary props = configuration.getproperties();     if (props == null) {         props = new hashtable();     }     props.put("root", "/jaxrs");     configuration.update(props); 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -