Re: Karaf CXF SCR REST example...

2019-11-19 Thread Jean-Baptiste Onofré
Hi

Good point, I forgot to destroy the CXF RS server.

I created https://issues.apache.org/jira/browse/KARAF-6523 for the
tracking and I'm fixing that.

Thanks
Regards
JB

On 20/11/2019 00:54, Ranx0r0x wrote:
> I noticed that when I stopped/uninstalled the bundle the CXF endpoint was
> still up and the bundle couldn't be reinstalled. By saving the Server and
> destroying it on @Deactivate it correctly went away. There may be a more
> elegant or better way to do this but it may be that it should be part of the
> sample code.
> 
> @Component
> public class RestServiceBootstrap {
> 
>   private MyInjectedService injectedService;
>   private Server server;
>   @Activate
>   public void activate() throws Exception {
>   System.out.println("Activate the MemberServiceImpl");
>   JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
>   bean.setAddress("/foo");
>   bean.setBus(BusFactory.getDefaultBus());
>   bean.setServiceBean(new RestServiceImpl(injectService));
>   server = bean.create();
>   }
> 
>   @Deactivate
>   public void deactivate() {
>   System.out.println("Deactivating server: " + server);
>   server.destroy();
>   }
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com


Re: Karaf CXF SCR REST example...

2019-11-19 Thread Ranx0r0x
I noticed that when I stopped/uninstalled the bundle the CXF endpoint was
still up and the bundle couldn't be reinstalled. By saving the Server and
destroying it on @Deactivate it correctly went away. There may be a more
elegant or better way to do this but it may be that it should be part of the
sample code.

@Component
public class RestServiceBootstrap {

private MyInjectedService injectedService;
private Server server;
@Activate
public void activate() throws Exception {
System.out.println("Activate the MemberServiceImpl");
JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
bean.setAddress("/foo");
bean.setBus(BusFactory.getDefaultBus());
bean.setServiceBean(new RestServiceImpl(injectService));
server = bean.create();
}

@Deactivate
public void deactivate() {
System.out.println("Deactivating server: " + server);
server.destroy();
}



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Karaf CXF SCR REST example...

2019-11-19 Thread Ranx0r0x
https://github.com/apache/karaf/tree/master/examples/karaf-rest-example/karaf-rest-example-scr

I was just checking out this latest example and have to say I like it quite
a bit. One thing I'm trying to focus on is being able to set up more than
one Bus in a bus-centric bundle and then reuse them via injection. It would
seem that this mechanism should permit that if I export the Busses to the
registry with a JNDI filter name and then inject it here instead of using
the BusFactory.getDefaultBus()

Would this be on the right track? I know that with Hibernate and PAX JDBC I
have to set a "capability" statement in the features file but that may be
because of Hibernate and PAX JDBC interoperation and be unnecessary in this
case. If I set up the Busses and use an @Service with a name. I'm a bit
uncertain though about the Service/Refence syntax that would be correct. 



osgi.service;effective:=active;objectClass=javax.sql.DataSource;osgi.jndi.service.name=jdbc/fooDS



@Component
public class RestService {

@Reference(target = "(&(objectclass=org.cxf.Bus)(bus.name=foo))"))
Bus bus;
@Activate
public void activate() throws Exception {
JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
bean.setAddress("/booking");
   // bean.setBus(BusFactory.getDefaultBus());
bean.setBus(bus);
   // Providers, interceptors set up in Bus bundle...
   // bean.setProvider(new JacksonJsonProvider());
bean.setServiceBean(new BookingServiceRest());
bean.create();
}

}





--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: Review of jackson features

2019-11-19 Thread Steinar Bang
> Jean-Baptiste Onofré :

> Hi Steinar,
> I started to review the different branches
> (https://github.com/steinarb/jackson-parent/tree/add-apache-karaf-features-to-jackson,
> ...).

> I have some comments and improvements.

> Do you want me to create PR on your branches or do you want to chat on
> Slack about that ?

> Please let me know the most convenient for you.

Thanks, JB!  PRs on the branches will be simplest.



Re: Aries jax-rs whiteboard

2019-11-19 Thread Matthias Leinweber
Well thank you for all the explanations I finally went for Olegs solution.
I also tried to create a component service factory for a
PrototypeServiceFactory with the required
properties to select my application, but I failed.

Best regards and thank you,
Matthias

Am Mo., 18. Nov. 2019 um 11:34 Uhr schrieb Tim Ward :

> Hi,
>
> Ok, but why and how does it work for the default application?… I can not
> see that JsonProviderPrototypeServiceFactory somehow adds a property for
> the default app.
>
>
> The reason that it works in the default application is that, by default,
> whiteboard resources and extensions target the default application. Note
> that in the JavaDoc for the application select property
> 
>  it
> says that *"Services without this service property are bound to the
> default Application.” *
>
> The reason that this works is therefore that the
> MessageBodyReader/MessageBodyWriter service supplying JSON support in your
> application is now targeting the same application as your whiteboard
> resource. The other option that I outlined was effectively the reverse
> approach to reach the same goal, namely adding an application select filter
> to the JSON extension service.
>
> There i don't need to select an extension in the resource but
> serialization works?
>
>
> Technically you *do* still need to select the extension in order for
> things to work 100% reliably. You can see this by investigating what
> happens when you stop the Aries Jackson bundle. You will see that your
> resource service is still hosted by the whiteboard, but that it explodes
> because there is no JSON support. What the extension select filter does is
> to tell the whiteboard not to host your whiteboard service until an
> appropriate extension is also present. In the absence of this filter your
> resource will always be hosted, whether the JSON support is available or
> not. Most of the time, however (basically at all times after startup has
> finished) your application will have both services and everything will work
> fine.
>
> Or is there some voodoo with SERVICE_RANKING?
>
>
> There isn’t any voodoo with service ranking in the spec, except to say
> that if you have two services that could provide the same endpoint (or the
> same extension support) then the higher ranked service will win. Service
> ranking plays no role in the examples that we’ve been working with.
>
> Tbh i don't even find the point where the configuration for
> pid org.apache.aries.jax.rs.jackson is created.
>
>
> That’s because there isn’t one. The service starts up with its default
> configuration (which is good enough for many cases) and doesn’t require
> configuration admin in order to run.
>
> Besides the versioning of org.apache.aries.jax.rs.jackson seems broken and
> the feature has a hardcoded dep on version 1.0.0 which source i cant find
> at all.. and the artifacts in current source aren't build at all.
>
>
> This is the CI job for the Aries JAX-RS Whiteboard integration projects,
> which are built separately from the whiteboard because they evolve at
> different speeds.
>
> https://builds.apache.org/job/Aries-JAX-RS-Whiteboard-Integrations/
>
> I see releases 1.0.0 to 1.0.2 in Maven Central, all of them with source
> jars.
>
>
> https://mvnrepository.com/artifact/org.apache.aries.jax.rs/org.apache.aries.jax.rs.jackson
>
> I hope this helps, all the best,
>
> Tim
>
> On 17 Nov 2019, at 17:27, Matthias Leinweber 
> wrote:
>
> Hello Tim,
>
> thank you, again you improved my knowledge. I just stripped my code for
> simplicity.
>
> Ok, but why and how does it work for the default application?
> There i don't need to select an extension in the resource but
> serialization works? I can not see that JsonProviderPrototypeServiceFactory
> somehow adds a property for the default app. Or is there some voodoo with
> SERVICE_RANKING?. Tbh i don't even find the point where the configuration
> for pid org.apache.aries.jax.rs.jackson is created.
>
> Besides the versioning of org.apache.aries.jax.rs.jackson seems broken and
> the feature has a hardcoded dep on version 1.0.0 which source i cant find
> at all.. and the artifacts in current source aren't build at all.
>
> kr,
> Matthias
>
> So somehow the extension selection logic looks odd. Or is this made
> media-type mapping?
>
>
> Tim Ward  schrieb am Fr., 15. Nov. 2019, 17:23:
>
>> Hi Matthias,
>>
>> So from the example that you’ve given I’m not sure why you have the
>> whiteboard application at all. Providing an empty whiteboard application
>> doesn’t really give you any benefit - the primary use case is for
>> registering existing non-OSGi JAX-RS applications, or for where you already
>> have a bunch of resource classes.
>>
>> In any event, the reason that what you have isn’t working for you is that
>> the JSON extension isn’t targeting your application. It’s not enough to
>> jus

Re: Review of jackson features

2019-11-19 Thread Jean-Baptiste Onofré
Hi Steinar,

I started to review the different branches
(https://github.com/steinarb/jackson-parent/tree/add-apache-karaf-features-to-jackson,
...).

I have some comments and improvements.

Do you want me to create PR on your branches or do you want to chat on
Slack about that ?

Please let me know the most convenient for you.

Thanks,
Regards
JB

On 18/11/2019 23:38, Steinar Bang wrote:
>> Jean-Baptiste Onofré :
> 
>> Hi Steinar,
>> I'm on it tonight.
> 
> Hi, again JB! Great! Thanks! :-)
> 

-- 
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com


Re: Error installing openjpa/3.0.0 in karaf 4.2.7

2019-11-19 Thread Jean-Baptiste Onofré
Hi,

OK, I remember now ;)

You should not use the openjpa feature provided by OpenJPA.

Instead, we create openjpa3 feature in Karaf that fix the asm/xbean issue.

If you do:

feature:install openjpa3

it should work smoothly (just tested it without problem).

Regards
JB

On 17/11/2019 12:49, tvogel wrote:
> I am unable to install openjpa/3.0.0 in a clean distribution of karaf 4.2.7.  
> 
> Similar / Same error as in this post 
> http://karaf.922171.n3.nabble.com/Openjpa-feature-resolution-error-on-Karaf-4-2-2-tp4054700.html
> 
>   
> 
> Is there a solution to this error?
> Thanks,
> Timothy
> 
> my full session:
> karaf@root(bundle)> feature:install -v jdbc jndi transaction jpa openjpa
> Adding features:
> jpa/[2.7.2,2.7.2],openjpa/[3.0.0,3.0.0],jndi/[4.2.7,4.2.7],transaction/[2.0.0,2.0.0],jdbc/[4.2.7,4.2.7]
> Changes to perform:
>   Region: root
> Bundles to install:
>   mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1
>  
> mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jasypt/1.9.3_1
>   mvn:org.ops4j.pax.jdbc/pax-jdbc/1.4.0
>   mvn:org.ops4j.pax.jdbc/pax-jdbc-config/1.4.0
>   mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/1.4.0
>   mvn:org.osgi/org.osgi.service.jdbc/1.0.0
> Installing bundles:
>   mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1
>  
> mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jasypt/1.9.3_1
>   mvn:org.ops4j.pax.jdbc/pax-jdbc/1.4.0
>   mvn:org.ops4j.pax.jdbc/pax-jdbc-config/1.4.0
>   mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/1.4.0
>   mvn:org.osgi/org.osgi.service.jdbc/1.0.0
> Starting bundles:
>   org.apache.geronimo.specs.geronimo-jta_1.1_spec/1.1.1
>   org.osgi.service.jdbc/1.0.0.201505202023
>   org.ops4j.pax.jdbc.pool.common/1.4.0
>   org.ops4j.pax.jdbc/1.4.0
>   org.apache.servicemix.bundles.jasypt/1.9.3.1
>   org.ops4j.pax.jdbc.config/1.4.0
> Done.
> org.apache.felix.resolver.reason.ReasonException: Unable to resolve root:
> missing requirement [root] osgi.identity; osgi.identity=openjpa;
> type=karaf.feature; version="[3.0.0,3.0.0]";
> filter:="(&(osgi.identity=openjpa)(type=karaf.feature)(version>=3.0.0)(version<=3.0.0))"
> [caused by: Unable to resolve openjpa/3.0.0: missing requirement
> [openjpa/3.0.0] osgi.identity; osgi.identity=org.apache.openjpa;
> type=osgi.bundle; version="[3.0.0,3.0.0]"; resolution:=mandatory [caused by:
> Unable to resolve org.apache.openjpa/3.0.0: missing requirement
> [org.apache.openjpa/3.0.0] osgi.wiring.package;
> filter:="(&(osgi.wiring.package=org.apache.xbean.asm6)(version>=6.1.0)(!(version>=7.0.0)))"]]
> at
> org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1343)
> at
> org.apache.felix.resolver.ResolverImpl.doResolve(ResolverImpl.java:392)
> at
> org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:378)
> at
> org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:332)
> at
> org.apache.karaf.features.internal.region.SubsystemResolver.resolve(SubsystemResolver.java:257)
> at
> org.apache.karaf.features.internal.service.Deployer.deploy(Deployer.java:393)
> at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(FeaturesServiceImpl.java:1062)
> at
> org.apache.karaf.features.internal.service.FeaturesServiceImpl.lambda$doProvisionInThread$13(FeaturesServiceImpl.java:998)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at java.lang.Thread.run(Thread.java:748)
> Caused by: org.apache.felix.resolver.reason.ReasonException: Unable to
> resolve openjpa/3.0.0: missing requirement [openjpa/3.0.0] osgi.identity;
> osgi.identity=org.apache.openjpa; type=osgi.bundle; version="[3.0.0,3.0.0]";
> resolution:=mandatory [caused by: Unable to resolve
> org.apache.openjpa/3.0.0: missing requirement [org.apache.openjpa/3.0.0]
> osgi.wiring.package;
> filter:="(&(osgi.wiring.package=org.apache.xbean.asm6)(version>=6.1.0)(!(version>=7.0.0)))"]
> at
> org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1343)
> ... 12 more
> Caused by: org.apache.felix.resolver.reason.ReasonException: Unable to
> resolve org.apache.openjpa/3.0.0: missing requirement
> [org.apache.openjpa/3.0.0] osgi.wiring.package;
> filter:="(&(osgi.wiring.package=org.apache.xbean.asm6)(version>=6.1.0)(!(version>=7.0.0)))"
> at
> org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1343)
> ... 13 more
> Error executing command: Unable to resolve root: missing requirement [root]
> osgi.identity; osgi.identity=openjpa; type=karaf.feature;
> version="