Re: jaxb, OSGI com.sun.xml.bind -- Cannot be resolved and overwritten by Boot Delegation

2015-02-04 Thread Bruce Edge
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

2015-02-04 Thread Bruce Edge
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

2015-02-04 Thread Stefan Seifert
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



Re: jaxb, OSGI com.sun.xml.bind -- Cannot be resolved and overwritten by Boot Delegation

2015-01-28 Thread Bruce Edge
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 bundle dependency in the
pom.xml?

-Bruce