Re: jaxb, OSGI com.sun.xml.bind -- Cannot be resolved and overwritten by Boot Delegation
My earlier claims of success were overly optimistic. Just getting everything to load into osgi was one hurdle, but getting jaxb running is a completely different story. With the configuration mentioned below, g! lb | grep -i jax 65|Active | 30|jaxb-api (2.2.11) 66|Active | 30|Old JAXB Core (2.2.11) attempting to instantiate a JAXBContext does not work, JAXBContext context = JAXBContext.newInstance(new Class[] {com.nim.content.formats.folio.schema.FolioType.class}); (syntax modification as indicated in [1]) fails with a ClassCastException: 04.02.2015 07:32:50.136 *ERROR* [pool-6-thread-1-main queue(incoming/file)] com.nim.ct.dam.ingest.jobs.ImportFileJobConsumer Exception: java.lang.NullPointerException java.lang.NullPointerException: null at javax.xml.bind.ContextFinder.handleClassCastException(ContextFinder.java:12 9) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:265) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:249) at javax.xml.bind.ContextFinder.find(ContextFinder.java:477) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:656) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:599) at com.nim.content.formats.folio.DefaultFolioReader.init(DefaultFolioReader. java:45) Then I tried to use the jaxb-osgi package. I could not even get this to load in sling. These were the sling import warnings on the bundle on the com.sun.xml.bind.jaxb-osgi bundle (jaxb-osgi-2.2.11.jar) com.sun.org.apache.xml.internal.resolver -- Cannot be resolved but is not required and overwritten by Boot Delegation com.sun.org.apache.xml.internal.resolver.tools -- Cannot be resolved but is not required and overwritten by Boot Delegation com.sun.source.tree -- Cannot be resolved and overwritten by Boot Delegation com.sun.source.util -- Cannot be resolved and overwritten by Boot Delegation javax.xml.bind,version=2.2.12.b1401091041 -- Cannot be resolved but is not required javax.xml.bind.annotation,version=2.2.12.b1401091041 -- Cannot be resolved but is not required javax.xml.bind.annotation.adapters,version=2.2.12.b1401091041 -- Cannot be resolved but is not required javax.xml.bind.attachment,version=2.2.12.b1401091041 -- Cannot be resolved but is not required javax.xml.bind.helpers,version=2.2.12.b1401091041 -- Cannot be resolved but is not required I’m a bit at a loss what to try next. -Bruce [1] http://blog.kusandriadi.com/problem-using-jaxb-marshallingunmarshalling-wit hin-osgi-container/ Thanks for the hints Stephan. They got me going in the right direction. My problems went away after I added these to my launchpad¹s list.xml: bundle groupIdjavax.xml.bind/groupId artifactIdjaxb-api/artifactId version2.2.11/version /bundle bundle groupIdcom.sun.xml.bind/groupId artifactIdjaxb-core/artifactId version2.2.11/version /bundle I¹m not entirely sure what was causing the problem, but there seems to be some inconsistency in module naming in this area. With the above bundles specified, the felix console bundles now include: Old JAXB Core com.sun.xml.bind.jaxb-core 2.2.11 Active jaxb-api jaxb-api 2.2.11 Active Manually forcing these to load at launchpad start time satisfied the later bundle load-time dependencies. -Bruce the packages javax.xml.bind.* are part of the java runtime (at least for the newer JDKs 7 and up), but not exported by the OSGi system bundle by default. if not done already please install the bundle org.apache.sling:org.apache.sling.fragment.xml:1.0.2 and restart the instance, this extends the list of exported packages of the java runtime for the XML-related packages. but this package currently only exports JAXB version 2.1.0, can you downgrade to this version? as a rule of thumb you should always try to use the packages von the java runtime if they are included in the version you use and install the appropriate fragment bundle that extends the export list. packages starting with com.sun.xml are internal-only packages, are not exported by the system bundle in general and should not be used. if you really have to update JAXB to a newer version than this can become cumbersome, because those libraries tend to import packages like com.sun.xml which are not exported and have dependencies which might be difficult to resolve. stefan I'm running into this error trying to use jaxb in a bundle: com.sun.xml.bind -- Cannot be resolved and overwritten by Boot Delegation com.sun.xml.bind.annotation -- Cannot be resolved and overwritten by Boot Delegation javax.xml.bind,version=[2.2,3) -- Cannot be resolved javax.xml.bind.annotation,version=[2.2,3) -- Cannot be resolved I assume I need to replace the standard jaxb-core and jaxb-api with the osgi variants (jaxb-osgi and jaxb-osgi-extra?), but I haven't found the magic incantation for the maven-bundle-plugin to get this to load in sling. What is the procedure for declaring jaxb as a
Re: jaxb, OSGI com.sun.xml.bind -- Cannot be resolved and overwritten by Boot Delegation
Forgot to mention, I did try the JAXB version 2.1.0 that Steffan recommended. This rippled through my application code and got to the point where it would no longer build with a versions so old of some of the dependencies. I wasn’t able to locate version 2.1.0 for all components either. Is there an example or test case using jaxb that I can follow/cargo cult? -Bruce From: Bruce Edge bruce.e...@nextissuemedia.com Reply-To: users@sling.apache.org users@sling.apache.org Date: Wednesday, February 4, 2015 at 8:32 AM To: users@sling.apache.org users@sling.apache.org Subject: Re: jaxb, OSGI com.sun.xml.bind -- Cannot be resolved and overwritten by Boot Delegation My earlier claims of success were overly optimistic. Just getting everything to load into osgi was one hurdle, but getting jaxb running is a completely different story. With the configuration mentioned below, g! lb | grep -i jax 65|Active | 30|jaxb-api (2.2.11) 66|Active | 30|Old JAXB Core (2.2.11) attempting to instantiate a JAXBContext does not work, JAXBContext context = JAXBContext.newInstance(new Class[] {com.nim.content.formats.folio.schema.FolioType.class}); (syntax modification as indicated in [1]) fails with a ClassCastException: 04.02.2015 07:32:50.136 *ERROR* [pool-6-thread-1-main queue(incoming/file)] com.nim.ct.dam.ingest.jobs.ImportFileJobConsumer Exception: java.lang.NullPointerException java.lang.NullPointerException: null at javax.xml.bind.ContextFinder.handleClassCastException(ContextFinder.java:1 2 9) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:265) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:249) at javax.xml.bind.ContextFinder.find(ContextFinder.java:477) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:656) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:599) at com.nim.content.formats.folio.DefaultFolioReader.init(DefaultFolioReader . java:45) Then I tried to use the jaxb-osgi package. I could not even get this to load in sling. These were the sling import warnings on the bundle on the com.sun.xml.bind.jaxb-osgi bundle (jaxb-osgi-2.2.11.jar) com.sun.org.apache.xml.internal.resolver -- Cannot be resolved but is not required and overwritten by Boot Delegation com.sun.org.apache.xml.internal.resolver.tools -- Cannot be resolved but is not required and overwritten by Boot Delegation com.sun.source.tree -- Cannot be resolved and overwritten by Boot Delegation com.sun.source.util -- Cannot be resolved and overwritten by Boot Delegation javax.xml.bind,version=2.2.12.b1401091041 -- Cannot be resolved but is not required javax.xml.bind.annotation,version=2.2.12.b1401091041 -- Cannot be resolved but is not required javax.xml.bind.annotation.adapters,version=2.2.12.b1401091041 -- Cannot be resolved but is not required javax.xml.bind.attachment,version=2.2.12.b1401091041 -- Cannot be resolved but is not required javax.xml.bind.helpers,version=2.2.12.b1401091041 -- Cannot be resolved but is not required I’m a bit at a loss what to try next. -Bruce [1] http://blog.kusandriadi.com/problem-using-jaxb-marshallingunmarshalling-wi t hin-osgi-container/ Thanks for the hints Stephan. They got me going in the right direction. My problems went away after I added these to my launchpad¹s list.xml: bundle groupIdjavax.xml.bind/groupId artifactIdjaxb-api/artifactId version2.2.11/version /bundle bundle groupIdcom.sun.xml.bind/groupId artifactIdjaxb-core/artifactId version2.2.11/version /bundle I¹m not entirely sure what was causing the problem, but there seems to be some inconsistency in module naming in this area. With the above bundles specified, the felix console bundles now include: Old JAXB Core com.sun.xml.bind.jaxb-core 2.2.11 Active jaxb-api jaxb-api 2.2.11 Active Manually forcing these to load at launchpad start time satisfied the later bundle load-time dependencies. -Bruce the packages javax.xml.bind.* are part of the java runtime (at least for the newer JDKs 7 and up), but not exported by the OSGi system bundle by default. if not done already please install the bundle org.apache.sling:org.apache.sling.fragment.xml:1.0.2 and restart the instance, this extends the list of exported packages of the java runtime for the XML-related packages. but this package currently only exports JAXB version 2.1.0, can you downgrade to this version? as a rule of thumb you should always try to use the packages von the java runtime if they are included in the version you use and install the appropriate fragment bundle that extends the export list. packages starting with com.sun.xml are internal-only packages, are not exported by the system bundle in general and should not be used. if you really have to update JAXB to a newer version than this can become cumbersome, because those libraries tend to import packages like com.sun.xml which are not
RE: jaxb, OSGI com.sun.xml.bind -- Cannot be resolved and overwritten by Boot Delegation
hello bruce. this can become tricky. my recommendation was to do not deploy any JAXB bundle, but to use the version embedded in the JDK and make sure the system bundle exports its packages as well. additionally JAXB is not fully OSGi-compatible concerning class loading, so some additional classloader magic might be required as well. some years ago i had a talk on this about apache CXF, which uses JAXB internally as well: http://adapt.to/2011/en/schedule/apache-cxf-and-sling--consuming-and-publishing-soap-services.html it may be a bit outdated by now, but basically the process is still the same. a matching fragment bundle that extends the exports of the system bundle with the JAXB and other XML packages is provided by sling itself: http://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.fragment.xml/1.0.2/ stefan -Original Message- From: Bruce Edge [mailto:bruce.e...@nextissuemedia.com] Sent: Wednesday, February 04, 2015 5:45 PM To: users@sling.apache.org Subject: Re: jaxb, OSGI com.sun.xml.bind -- Cannot be resolved and overwritten by Boot Delegation Forgot to mention, I did try the JAXB version 2.1.0 that Steffan recommended. This rippled through my application code and got to the point where it would no longer build with a versions so old of some of the dependencies. I wasn't able to locate version 2.1.0 for all components either. Is there an example or test case using jaxb that I can follow/cargo cult? -Bruce From: Bruce Edge bruce.e...@nextissuemedia.com Reply-To: users@sling.apache.org users@sling.apache.org Date: Wednesday, February 4, 2015 at 8:32 AM To: users@sling.apache.org users@sling.apache.org Subject: Re: jaxb, OSGI com.sun.xml.bind -- Cannot be resolved and overwritten by Boot Delegation My earlier claims of success were overly optimistic. Just getting everything to load into osgi was one hurdle, but getting jaxb running is a completely different story. With the configuration mentioned below, g! lb | grep -i jax 65|Active | 30|jaxb-api (2.2.11) 66|Active | 30|Old JAXB Core (2.2.11) attempting to instantiate a JAXBContext does not work, JAXBContext context = JAXBContext.newInstance(new Class[] {com.nim.content.formats.folio.schema.FolioType.class}); (syntax modification as indicated in [1]) fails with a ClassCastException: 04.02.2015 07:32:50.136 *ERROR* [pool-6-thread-1-main queue(incoming/file)] com.nim.ct.dam.ingest.jobs.ImportFileJobConsumer Exception: java.lang.NullPointerException java.lang.NullPointerException: null at javax.xml.bind.ContextFinder.handleClassCastException(ContextFinder.j ava:1 2 9) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:265) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:249) at javax.xml.bind.ContextFinder.find(ContextFinder.java:477) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:656) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:599) at com.nim.content.formats.folio.DefaultFolioReader.init(DefaultFolioR eader . java:45) Then I tried to use the jaxb-osgi package. I could not even get this to load in sling. These were the sling import warnings on the bundle on the com.sun.xml.bind.jaxb-osgi bundle (jaxb-osgi-2.2.11.jar) com.sun.org.apache.xml.internal.resolver -- Cannot be resolved but is not required and overwritten by Boot Delegation com.sun.org.apache.xml.internal.resolver.tools -- Cannot be resolved but is not required and overwritten by Boot Delegation com.sun.source.tree -- Cannot be resolved and overwritten by Boot Delegation com.sun.source.util -- Cannot be resolved and overwritten by Boot Delegation javax.xml.bind,version=2.2.12.b1401091041 -- Cannot be resolved but is not required javax.xml.bind.annotation,version=2.2.12.b1401091041 -- Cannot be resolved but is not required javax.xml.bind.annotation.adapters,version=2.2.12.b1401091041 -- Cannot be resolved but is not required javax.xml.bind.attachment,version=2.2.12.b1401091041 -- Cannot be resolved but is not required javax.xml.bind.helpers,version=2.2.12.b1401091041 -- Cannot be resolved but is not required I'm a bit at a loss what to try next. -Bruce [1] http://blog.kusandriadi.com/problem-using-jaxb- marshallingunmarshalling-wi t hin-osgi-container/ Thanks for the hints Stephan. They got me going in the right direction. My problems went away after I added these to my launchpad¹s list.xml: bundle groupIdjavax.xml.bind/groupId artifactIdjaxb-api/artifactId version2.2.11/version /bundle bundle groupIdcom.sun.xml.bind/groupId artifactIdjaxb-core/artifactId version2.2.11/version /bundle I¹m not entirely sure what was causing the problem, but there seems to be some inconsistency in module naming in this area. With the above bundles specified, the felix console bundles now include: Old JAXB Core com.sun.xml.bind.jaxb-core 2.2.11 Active jaxb-api jaxb-api 2.2.11 Active
Replacing resolver.getResource() with sling:include
Hi, I have a ResourceResolver.getResource call which I would like to replace with a sling:include / . What I currently have Resource configResource = resolver.getResource(my/component/config.js.jsp); cq:include script=%=configResource.getPath()% / What I want to have sling:include resource=%= resource % resourceType=my/component replaceSelectors=config / The problem here is that I need the extension to be set as well ( the original request's extension is set to .html ). A brief test done by creating a resource with sling:resourceType my/component at /content/test revealed that - /content/test.config.js returns the right content - /content/test.config.html does not So my questions are: 1. Is there a way I can convince sling:include to include the extension? 2. Is there isn't, is this a valid enhancement request? Thanks, Robert
Re: Configuring a service using sling:OsgiConfig
Ok. Thanks for clarifying. I could setup OsgiConfig nodes manually as well but in any case, the setting done via console would override. On Mon, Feb 2, 2015 at 7:16 PM, Bertrand Delacretaz bdelacre...@apache.org wrote: On Mon, Feb 2, 2015 at 2:39 PM, connuser1 connuser1 connus...@gmail.com wrote: On Mon, Feb 2, 2015 at 7:03 PM, Bertrand Delacretaz bdelacre...@apache.org wrote: Why do you have both the .config file and the sling:OsgiConfig nodes for the same service pid? I edited the config once using felix console. I think it created the .config file while the sling:OsgiConfig node was already created by me earlier Ok, I don't have time to look up the details right now but I suppose that's by design, as the installer aims to give priority to stuff that you setup manually. -Bertrand
RE: Implementing ModifyingResourceProvider
currently the nosql-generic part does not even compile... I plan to work it on the next day at least to have a running proof-of-concept, but cannot give a precise promise when it will be ready. stefan -Original Message- From: connuser1 connuser1 [mailto:connus...@gmail.com] Sent: Wednesday, February 04, 2015 12:46 PM To: users@sling.apache.org Subject: Re: Implementing ModifyingResourceProvider Thanks Stefan for sharing this. I was going through the nosql generic part. Though I haven't gone into much detail yet but I'll check how to use it with dynamodb. Any idea if and when it could be a part of sling? On Mon, Feb 2, 2015 at 7:24 PM, Stefan Seifert sseif...@pro-vision.de wrote: please also take not of this recent discussion on the sling-dev mailing list http://apache-sling.73963.n3.nabble.com/RT-Sling-Resource-Providers-for- NoSQL-databases-MongoDB-Couchbase-tt4046669.html an example for an existing NoSQL resource provider that solves these problems is https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/mongodb but as discussed in the mailing list we are currently looking to refactor it into a resuable part that can be used by all NoSQL resource providers, and it is very likely that this reusable part will implement all specific features of the ModifyingResourceProvider as well. related ticket is https://issues.apache.org/jira/browse/SLING-4381 stefan -Original Message- From: connuser1 connuser1 [mailto:connus...@gmail.com] Sent: Thursday, January 29, 2015 2:42 PM To: users@sling.apache.org Subject: Re: Implementing ModifyingResourceProvider More specifically, how can I keep track of the update which is handled via ModifiableValueMap ? Quoting from the ModifiableValueMap documentation [1], *Once ResourceResolver.commit() is called, the changes are finally persisted.* Basically I am not sure, how and where can the changes in ModifiableValueMap be translated to the changes to be done on the dynamodb backend. [1] - http://docs.adobe.com/docs/en/cq/current/javadoc/org/apache/sling/api/resource /ModifiableValueMap.html On Thu, Jan 29, 2015 at 6:45 PM, connuser1 connuser1 connus...@gmail.com wrote: Hi I am implementing the ModifyingResourceProvider intergace for the dynamodb resource provider [0] in order to be able to create/edit/delete resources. I needed some guidance on implementing the revert/commit/hasChanges methods. I had a look at JCRResourceProvider and it does that through the JCR Session. What is the recommended way of keeping track of the transient changes in custom resource providers like his one? Thanks [0] - https://github.com/sdmcraft/SlingDynamo
Re: Implementing ModifyingResourceProvider
Thanks Stefan for sharing this. I was going through the nosql generic part. Though I haven't gone into much detail yet but I'll check how to use it with dynamodb. Any idea if and when it could be a part of sling? On Mon, Feb 2, 2015 at 7:24 PM, Stefan Seifert sseif...@pro-vision.de wrote: please also take not of this recent discussion on the sling-dev mailing list http://apache-sling.73963.n3.nabble.com/RT-Sling-Resource-Providers-for-NoSQL-databases-MongoDB-Couchbase-tt4046669.html an example for an existing NoSQL resource provider that solves these problems is https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/mongodb but as discussed in the mailing list we are currently looking to refactor it into a resuable part that can be used by all NoSQL resource providers, and it is very likely that this reusable part will implement all specific features of the ModifyingResourceProvider as well. related ticket is https://issues.apache.org/jira/browse/SLING-4381 stefan -Original Message- From: connuser1 connuser1 [mailto:connus...@gmail.com] Sent: Thursday, January 29, 2015 2:42 PM To: users@sling.apache.org Subject: Re: Implementing ModifyingResourceProvider More specifically, how can I keep track of the update which is handled via ModifiableValueMap ? Quoting from the ModifiableValueMap documentation [1], *Once ResourceResolver.commit() is called, the changes are finally persisted.* Basically I am not sure, how and where can the changes in ModifiableValueMap be translated to the changes to be done on the dynamodb backend. [1] - http://docs.adobe.com/docs/en/cq/current/javadoc/org/apache/sling/api/resource /ModifiableValueMap.html On Thu, Jan 29, 2015 at 6:45 PM, connuser1 connuser1 connus...@gmail.com wrote: Hi I am implementing the ModifyingResourceProvider intergace for the dynamodb resource provider [0] in order to be able to create/edit/delete resources. I needed some guidance on implementing the revert/commit/hasChanges methods. I had a look at JCRResourceProvider and it does that through the JCR Session. What is the recommended way of keeping track of the transient changes in custom resource providers like his one? Thanks [0] - https://github.com/sdmcraft/SlingDynamo
Re: Replacing resolver.getResource() with sling:include
Hi Julian, On Wed, Feb 4, 2015 at 1:51 PM, Julian Sedding jsedd...@gmail.com wrote: Hi Robert You could always do the following: sling:include path=%= resource.getPath() %.config.js resourceType=my/component/ That works, thank you! Robert Regards Julian On Wed, Feb 4, 2015 at 12:47 PM, Robert Munteanu romb...@apache.org wrote: Hi, I have a ResourceResolver.getResource call which I would like to replace with a sling:include / . What I currently have Resource configResource = resolver.getResource(my/component/config.js.jsp); cq:include script=%=configResource.getPath()% / What I want to have sling:include resource=%= resource % resourceType=my/component replaceSelectors=config / The problem here is that I need the extension to be set as well ( the original request's extension is set to .html ). A brief test done by creating a resource with sling:resourceType my/component at /content/test revealed that - /content/test.config.js returns the right content - /content/test.config.html does not So my questions are: 1. Is there a way I can convince sling:include to include the extension? 2. Is there isn't, is this a valid enhancement request? Thanks, Robert
Re: Replacing resolver.getResource() with sling:include
Hi Robert You could always do the following: sling:include path=%= resource.getPath() %.config.js resourceType=my/component/ Regards Julian On Wed, Feb 4, 2015 at 12:47 PM, Robert Munteanu romb...@apache.org wrote: Hi, I have a ResourceResolver.getResource call which I would like to replace with a sling:include / . What I currently have Resource configResource = resolver.getResource(my/component/config.js.jsp); cq:include script=%=configResource.getPath()% / What I want to have sling:include resource=%= resource % resourceType=my/component replaceSelectors=config / The problem here is that I need the extension to be set as well ( the original request's extension is set to .html ). A brief test done by creating a resource with sling:resourceType my/component at /content/test revealed that - /content/test.config.js returns the right content - /content/test.config.html does not So my questions are: 1. Is there a way I can convince sling:include to include the extension? 2. Is there isn't, is this a valid enhancement request? Thanks, Robert