Hi, thanks for your reply.
i tried to change my activator.java in the following way:
package rest.sample.greetings;
>
> import java.util.Dictionary;
> import java.util.Hashtable;
>
> import org.osgi.framework.BundleActivator;
> import org.osgi.framework.BundleContext;
> import org.osgi.framework.ServiceRegistration;
>
> import rest.sample.greetings.impl.ByeServiceImpl;
> import rest.sample.greetings.impl.HelloServiceImpl;
>
>
>
> public class Activator implements BundleActivator {
>
> private ServiceRegistration registration;
> private ServiceRegistration registration2;
>
> public void start(BundleContext context) throws Exception {
> System.out.println("START GREETINGS BUNDLE");
> Dictionary<String, Object> props1 = getProperties("/service1");
> registration =
> context.registerService(HelloServiceImpl.class.getName(), new
> HelloServiceImpl(context), props1);
> Dictionary<String, Object> props2 = getProperties("/service2");
> registration2 =
> context.registerService(ByeServiceImpl.class.getName(), new
> ByeServiceImpl(context), props2);
>
>
>
> }
>
>
> private Dictionary<String, Object> getProperties(String address) {
> Dictionary<String, Object> props = new Hashtable<String, Object>();
> props.put("service.exported.interfaces", "*");
> props.put("service.exported.configs", "org.apache.cxf.rs");
> props.put("service.exported.intents", "HTTP");
> props.put("org.apache.cxf.rs.address", address);
> return props;
> }
>
>
>
> public void stop(BundleContext context) throws Exception {
> registration.unregister();
> registration2.unregister();
>
> }
> }
>
the endpoints are now:
http://192.168.0.10:8181/cxf/service2/bye/sayBye
>
http://192.168.0.10:8181/cxf/service1/hello/sayHello
>
if i try to invoke them, in the shell when is running felix, nothing
happens, and the browser report me "Connection Failed" error.
it is possible that I'm doing something wrong?
Thanks for your attention
2014/1/9 Christian Schneider <[email protected]>
> You are using the same org.apache.cxf.rs.address for both services. This
> will not work. For each service the jetty transport is used in your case.
> Those jetties do not work together I think.
> You could either use two different port numbers or use addresses like
> "/service1" and "/service2". In the first case we have two different jetty
> instances in the second case we use the servlet transport and share the
> same default web port.
>
> Best regards
>
> Christian
>
>
>
> On 09.01.2014 16:46, Gavino Isoni wrote:
>
>> Hi,
>> Consider the following activator code:
>>
>> package rest.sample.greetings;
>>
>>> import java.util.Dictionary;
>>> import java.util.Hashtable;
>>>
>>> import org.osgi.framework.BundleActivator;
>>> import org.osgi.framework.BundleContext;
>>> import org.osgi.framework.ServiceRegistration;
>>>
>>> import rest.sample.greetings.impl.ByeServiceImpl;
>>> import rest.sample.greetings.impl.HelloServiceImpl;
>>>
>>>
>>>
>>> public class Activator implements BundleActivator {
>>>
>>> private ServiceRegistration registration;
>>> private ServiceRegistration registration2;
>>>
>>> public void start(BundleContext context) throws Exception {
>>> System.out.println("START GREETINGS BUNDLE");
>>> Dictionary<String, Object> props1 = getProperties();
>>> registration =
>>> context.registerService(HelloServiceImpl.class.getName(), new
>>> HelloServiceImpl(context), props1);
>>> Dictionary<String, Object> props2 = getProperties();
>>> registration2 =
>>> context.registerService(ByeServiceImpl.class.getName(), new
>>> ByeServiceImpl(context), props2);
>>>
>>>
>>>
>>> }
>>>
>>>
>>> private Dictionary<String, Object> getProperties() {
>>> Dictionary<String, Object> props = new Hashtable<String,
>>> Object>();
>>> props.put("service.exported.interfaces", "*");
>>> props.put("service.exported.configs", "org.apache.cxf.rs");
>>> props.put("service.exported.intents", "HTTP");
>>> props.put("org.apache.cxf.rs.address", "http://localhost:8181/
>>> ");
>>> return props;
>>> }
>>>
>>>
>>>
>>> public void stop(BundleContext context) throws Exception {
>>> registration.unregister();
>>> registration2.unregister();
>>>
>>> }
>>> }
>>>
>>>
>>
>>
>> package rest.sample.greetings.api;
>>
>>> import javax.ws.rs.GET;
>>> import javax.ws.rs.Path;
>>> import javax.ws.rs.Produces;
>>> import javax.ws.rs.core.MediaType;
>>>
>>> @Path("/bye")
>>> public interface ByeService {
>>>
>>> @GET
>>> @Path("/sayBye")
>>> @Produces(MediaType.TEXT_PLAIN)
>>> public String sayBye();
>>>
>>> }
>>>
>>>
>>> package rest.sample.greetings.api;
>>
>>> import javax.ws.rs.GET;
>>> import javax.ws.rs.Path;
>>> import javax.ws.rs.Produces;
>>> import javax.ws.rs.core.MediaType;
>>>
>>> @Path("/hello")
>>> public interface HelloService {
>>>
>>> @GET
>>> @Path("/sayHello")
>>> @Produces(MediaType.TEXT_PLAIN)
>>> public String sayHello();
>>>
>>> }
>>>
>>>
>>
>>
>> When the two services are registered, seems that the last one overwrite se
>> first one.
>>
>> if I try to invoke the services, with the following respective URI:
>>
>> http://localhost:8181/hello/sayHello
>>
>>
>> http://localhost:8181/bye/sayBye
>>
>>
>> only one works, and for the other one is reported the following error:
>>
>> [qtp22790308-54 - /hello/sayHello] WARN
>>
>>> org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor - No root resource
>>> matching request path /hello/sayHello has been found, Relative Path:
>>> /hello/sayHello.
>>>
>>> i'm using the multibundle-ditribution 1.5
>>
>> how can I invoke both services?
>>
>> thanks for your attention.
>>
>>
>
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> http://www.talend.com
>
>