You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@johnzon.apache.org by Robert Munteanu <ro...@apache.org> on 2016/11/23 22:37:27 UTC
Using johnzon-core in an OSGi container
Hi,
I noticed that Johnzon has OSGi headers, which is nice :-)
I am trying to setup Johnzon in a minimal OSGi container. I have a
bundle which performs a very simple JSON rendering:
��������try ( JsonGenerator g =
Json.createGenerator(resp.getOutputStream())) {
������������resp.setContentType("application/json");
������������g.writeStartObject()
�������������.write("enabled", routerAdmin.isWlanEnabled() )
�������������.writeEnd();
��������} catch (AuthException e) {
������������resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR
);
��������}
I am deploying the following bundles to my container:
- Johnzon :: Core (0.9.4) - org.apache.johnzon:johnzon-core:0.9.4
- Apache Geronimo JSon Spec 1.0 (1.0.0.alpha-1) -
org.apache.geronimo.specs:geronimo-json_1.0_spec:1.0-alpha-1
The code fails with
javax.json.JsonException: org.apache.johnzon.core.JsonProviderImpl
not found
(full stack trace at the end ).
My question is - is this a supported scenario? Looking at the bundle
headers I don't see how the wiring could happen between these the JSON
API and Johnzon Core bundles, as they know nothing about each other.
(Please keep me in CC, I am not subscribed).
Thanks,
Robert
javax.json.JsonException: org.apache.johnzon.core.JsonProviderImpl not
found
��������at
javax.json.spi.JsonProvider.doLoadProvider(JsonProvider.java:132)
��������at javax.json.spi.JsonProvider.provider(JsonProvider.java:64)
��������at javax.json.Json.createGenerator(Json.java:48)
��������at
ro.lmn.routeradmin.web.impl.AdminServlet.doGet(AdminServlet.java:33)
��������at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
��������at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
��������at
org.apache.felix.http.base.internal.handler.ServletHandler.handle(Servl
etHandler.java:85)
��������at
org.apache.felix.http.base.internal.dispatch.InvocationChain.doFilter(I
nvocationChain.java:79)
��������at
org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispat
cher.java:124)
��������at
org.apache.felix.http.base.internal.DispatcherServlet.service(Dispatche
rServlet.java:61)
��������at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
��������at
org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:845)
��������at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:5
83)
��������at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler
.java:224)
��������at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler
.java:1174)
��������at
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:51
1)
��������at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.
java:185)
��������at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.
java:1106)
��������at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.jav
a:141)
��������at
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(Contex
tHandlerCollection.java:213)���
��������at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.j
ava:134)
��������at org.eclipse.jetty.server.Server.handle(Server.java:524)
��������at
org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:319)
��������at
org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:
253)
��������at
org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(Abstract
Connection.java:273)
��������at
org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
��������at
org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.
java:93)
��������at
org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executePro
duceConsume(ExecuteProduceConsume.java:303)
��������at
org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceCon
sume(ExecuteProduceConsume.java:148)
��������at
org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(Execut
eProduceConsume.java:136)
��������at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.
java:671)
��������at
org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.j
ava:589)
��������at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException:
org.apache.johnzon.core.JsonProviderImpl
��������at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
��������at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
��������at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
��������at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
��������at
javax.json.spi.JsonProvider.doLoadProvider(JsonProvider.java:129)
��������... 32 more
Re: Using johnzon-core in an OSGi container
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Robert,
as mentionned on the ticket I will let you try to propose and test a patch
matching OSGi need. But here if you need help or anything in this code/area
is unclear.
Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> | Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>
2016-12-06 14:44 GMT+01:00 Robert Munteanu <rm...@adobe.com>:
> Filed
>
> https://issues.apache.org/jira/browse/GERONIMO-6560
>
> Thanks,
>
> Robert
Re: Using johnzon-core in an OSGi container
Posted by Robert Munteanu <ro...@apache.org>.
Filed
https://issues.apache.org/jira/browse/GERONIMO-6560
Thanks,
Robert
Re: Using johnzon-core in an OSGi container
Posted by Robert Munteanu <rm...@adobe.com>.
Filed
https://issues.apache.org/jira/browse/GERONIMO-6560
Thanks,
Robert
Re: Using johnzon-core in an OSGi container
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Yep on geronimo spec project
Le 5 déc. 2016 21:35, "Robert Munteanu" <ro...@apache.org> a écrit :
> Hi,
>
> Should I file a Jira feature request for this?
>
> Robert
>
Re: Using johnzon-core in an OSGi container
Posted by Robert Munteanu <ro...@apache.org>.
Hi,
Should I file a Jira feature request for this?
Robert
Re: Using johnzon-core in an OSGi container
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Think this json api doesnt use yet providerlocator but should
Le 24 nov. 2016 00:07, "Mark Struberg" <st...@yahoo.de.invalid> a écrit :
> Hi Robert!
>
> I guess our lookup code does pretty much the same like with every other
> Geronimo spec.
>
> We first try to pickup a JsonProvider via the ServiceLoader mechanism. Of
> course that means that META-INF/services/javax.json.spi.JsonProvider
> needs to be 'visible' via OSGi tricks.
> If we don't find that then we try to load the hardcoded default provider
> which is
> DEFAULT_PROVIDER = "org.apache.johnzon.core.JsonProviderImpl";
> I assume since we do not OSGi-import johnzon in the
> geronimo-json_1.1-spec.jar, we also don't see the JsonProviderImpl from
> Johnzon from the spec jar?
> I'm not really deep into OSGi, but I assume Romain can help you.
>
> LieGrue,
> strub
>
>
>
> > Am 23.11.2016 um 23:37 schrieb Robert Munteanu <ro...@apache.org>:
> >
> > Hi,
> >
> > I noticed that Johnzon has OSGi headers, which is nice :-)
> >
> > I am trying to setup Johnzon in a minimal OSGi container. I have a
> > bundle which performs a very simple JSON rendering:
> >
> > try ( JsonGenerator g =
> > Json.createGenerator(resp.getOutputStream())) {
> > resp.setContentType("application/json");
> > g.writeStartObject()
> > .write("enabled", routerAdmin.isWlanEnabled() )
> > .writeEnd();
> > } catch (AuthException e) {
> > resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR
> > );
> > }
> >
> > I am deploying the following bundles to my container:
> >
> > - Johnzon :: Core (0.9.4) - org.apache.johnzon:johnzon-core:0.9.4
> > - Apache Geronimo JSon Spec 1.0 (1.0.0.alpha-1) -
> > org.apache.geronimo.specs:geronimo-json_1.0_spec:1.0-alpha-1
> >
> > The code fails with
> >
> > javax.json.JsonException: org.apache.johnzon.core.JsonProviderImpl
> > not found
> >
> > (full stack trace at the end ).
> >
> > My question is - is this a supported scenario? Looking at the bundle
> > headers I don't see how the wiring could happen between these the JSON
> > API and Johnzon Core bundles, as they know nothing about each other.
> >
> > (Please keep me in CC, I am not subscribed).
> >
> > Thanks,
> >
> > Robert
> >
> > javax.json.JsonException: org.apache.johnzon.core.JsonProviderImpl not
> > found
> > at
> > javax.json.spi.JsonProvider.doLoadProvider(JsonProvider.java:132)
> > at javax.json.spi.JsonProvider.provider(JsonProvider.java:64)
> > at javax.json.Json.createGenerator(Json.java:48)
> > at
> > ro.lmn.routeradmin.web.impl.AdminServlet.doGet(AdminServlet.java:33)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
> > at
> > org.apache.felix.http.base.internal.handler.ServletHandler.handle(Servl
> > etHandler.java:85)
> > at
> > org.apache.felix.http.base.internal.dispatch.InvocationChain.doFilter(I
> > nvocationChain.java:79)
> > at
> > org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispat
> > cher.java:124)
> > at
> > org.apache.felix.http.base.internal.DispatcherServlet.service(Dispatche
> > rServlet.java:61)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
> > at
> > org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:845)
> > at
> > org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:5
> > 83)
> > at
> > org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler
> > .java:224)
> > at
> > org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler
> > .java:1174)
> > at
> > org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:51
> > 1)
> > at
> > org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.
> > java:185)
> > at
> > org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.
> > java:1106)
> > at
> > org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.jav
> > a:141)
> > at
> > org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(Contex
> > tHandlerCollection.java:213)
> > at
> > org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.j
> > ava:134)
> > at org.eclipse.jetty.server.Server.handle(Server.java:524)
> > at
> > org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:319)
> > at
> > org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:
> > 253)
> > at
> > org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(Abstract
> > Connection.java:273)
> > at
> > org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
> > at
> > org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.
> > java:93)
> > at
> > org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executePro
> > duceConsume(ExecuteProduceConsume.java:303)
> > at
> > org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceCon
> > sume(ExecuteProduceConsume.java:148)
> > at
> > org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(Execut
> > eProduceConsume.java:136)
> > at
> > org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.
> > java:671)
> > at
> > org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.j
> > ava:589)
> > at java.lang.Thread.run(Thread.java:745)
> > Caused by: java.lang.ClassNotFoundException:
> > org.apache.johnzon.core.JsonProviderImpl
> > at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> > at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> > at
> > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
> > at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> > at
> > javax.json.spi.JsonProvider.doLoadProvider(JsonProvider.java:129)
> > ... 32 more
>
>
Re: Using johnzon-core in an OSGi container
Posted by Mark Struberg <st...@yahoo.de.INVALID>.
Hi Robert!
I guess our lookup code does pretty much the same like with every other Geronimo spec.
We first try to pickup a JsonProvider via the ServiceLoader mechanism. Of course that means that META-INF/services/javax.json.spi.JsonProvider needs to be 'visible' via OSGi tricks.
If we don't find that then we try to load the hardcoded default provider which is
DEFAULT_PROVIDER = "org.apache.johnzon.core.JsonProviderImpl";
I assume since we do not OSGi-import johnzon in the geronimo-json_1.1-spec.jar, we also don't see the JsonProviderImpl from Johnzon from the spec jar?
I'm not really deep into OSGi, but I assume Romain can help you.
LieGrue,
strub
> Am 23.11.2016 um 23:37 schrieb Robert Munteanu <ro...@apache.org>:
>
> Hi,
>
> I noticed that Johnzon has OSGi headers, which is nice :-)
>
> I am trying to setup Johnzon in a minimal OSGi container. I have a
> bundle which performs a very simple JSON rendering:
>
> try ( JsonGenerator g =
> Json.createGenerator(resp.getOutputStream())) {
> resp.setContentType("application/json");
> g.writeStartObject()
> .write("enabled", routerAdmin.isWlanEnabled() )
> .writeEnd();
> } catch (AuthException e) {
> resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR
> );
> }
>
> I am deploying the following bundles to my container:
>
> - Johnzon :: Core (0.9.4) - org.apache.johnzon:johnzon-core:0.9.4
> - Apache Geronimo JSon Spec 1.0 (1.0.0.alpha-1) -
> org.apache.geronimo.specs:geronimo-json_1.0_spec:1.0-alpha-1
>
> The code fails with
>
> javax.json.JsonException: org.apache.johnzon.core.JsonProviderImpl
> not found
>
> (full stack trace at the end ).
>
> My question is - is this a supported scenario? Looking at the bundle
> headers I don't see how the wiring could happen between these the JSON
> API and Johnzon Core bundles, as they know nothing about each other.
>
> (Please keep me in CC, I am not subscribed).
>
> Thanks,
>
> Robert
>
> javax.json.JsonException: org.apache.johnzon.core.JsonProviderImpl not
> found
> at
> javax.json.spi.JsonProvider.doLoadProvider(JsonProvider.java:132)
> at javax.json.spi.JsonProvider.provider(JsonProvider.java:64)
> at javax.json.Json.createGenerator(Json.java:48)
> at
> ro.lmn.routeradmin.web.impl.AdminServlet.doGet(AdminServlet.java:33)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
> at
> org.apache.felix.http.base.internal.handler.ServletHandler.handle(Servl
> etHandler.java:85)
> at
> org.apache.felix.http.base.internal.dispatch.InvocationChain.doFilter(I
> nvocationChain.java:79)
> at
> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispat
> cher.java:124)
> at
> org.apache.felix.http.base.internal.DispatcherServlet.service(Dispatche
> rServlet.java:61)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
> at
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:845)
> at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:5
> 83)
> at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler
> .java:224)
> at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler
> .java:1174)
> at
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:51
> 1)
> at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.
> java:185)
> at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.
> java:1106)
> at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.jav
> a:141)
> at
> org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(Contex
> tHandlerCollection.java:213)
> at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.j
> ava:134)
> at org.eclipse.jetty.server.Server.handle(Server.java:524)
> at
> org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:319)
> at
> org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:
> 253)
> at
> org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(Abstract
> Connection.java:273)
> at
> org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
> at
> org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.
> java:93)
> at
> org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executePro
> duceConsume(ExecuteProduceConsume.java:303)
> at
> org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceCon
> sume(ExecuteProduceConsume.java:148)
> at
> org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(Execut
> eProduceConsume.java:136)
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.
> java:671)
> at
> org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.j
> ava:589)
> at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.johnzon.core.JsonProviderImpl
> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at
> sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> at
> javax.json.spi.JsonProvider.doLoadProvider(JsonProvider.java:129)
> ... 32 more