users@jaxb.java.net

Re: How to upgrade JAXB impl provided?

From: Eric B <ebenzacar_at_gmail.com>
Date: Thu, 5 Apr 2012 10:10:49 -0400

Hi Laroslav,

Thanks for the tip, but I guess one of the bigger questions even is how to
determine whether or not the new version of JAXB is running? Is there
anything I can to do ensure/validate that I am indeed using the newer
version of JAXB and not the older one?

I have tried putting the jars in the endorsed folder, and even specified -D
java.endorsed.dirs= $JAVA_HOME/jre/lib/endorsed but that doesn't seem to be
making a difference. I checked the JBoss startup scripts/logs and see that
the endorsed dir is properly set there as well.

Thanks,

Eric


On Wed, Apr 4, 2012 at 12:36 PM, Iaroslav Savytskyi <
iaroslav.savytskyi_at_oracle.com> wrote:

> Hi, Eric,
>
> In general the easiest way how to setup latest JAXB version:
>
> 1) put jaxb-api.jar into $JAVA_HOME/jre/lib/endorsed
> 2) put jaxb-impl.jar, jaxb-xjc.jar into the classpath
>
> But I think for JBoss you have to use it's own endorsed dir.
>
> --
> Best regards.
> Iaroslav
>
>
>
>
> On 04/04/12 17:57, ebenzacar_at_gmail.com wrote:
>
>> Hi,
>>
>> I'm running a webapp in JBoss 7.0.2 and I am running into an
>> ArrayIndexOutOfBounds exception with JAXB marshaller. I'm using
>> JDK_1.6.0_29. From a web search, this is a bug that was fixed in a
>> subsequent version of JAXB.
>>
>> So I downloaded jaxb-impl.jar 2.2.5 via Maven and included it within my
>> war. However it has not made any difference. When I startup my app, I
>> have included the following class to log the implementation being used:
>>
>> /**
>> * Print the JAXB Implementation information
>> */
>> public static void outputJaxpImplementationInfo() {
>> logger.debug(**getImplementationInfo("**DocumentBuilderFactory",
>> DocumentBuilderFactory.**newInstance().getClass()));
>> logger.debug(**getImplementationInfo("**XPathFactory",
>> XPathFactory.newInstance().**getClass()));
>> logger.debug(**getImplementationInfo("**TransformerFactory",
>> TransformerFactory.**newInstance().getClass()));
>> logger.debug(**getImplementationInfo("**SAXParserFactory",
>> SAXParserFactory.newInstance()**.getClass()));
>> }
>>
>> /**
>> * Get the JAXB implementation information for a particular class
>> * @param componentName
>> * @param componentClass
>> * @return
>> */
>> private static String getImplementationInfo(String componentName, Class
>> componentClass) {
>> CodeSource source =
>> componentClass.**getProtectionDomain().**getCodeSource();
>> return MessageFormat.format(
>> "{0} implementation: {1} loaded from: {2}",
>> componentName,
>> componentClass.getName(),
>> source == null ? "Java Runtime" : source.getLocation());
>> }
>>
>> This produces the following output:
>> 10:28:27,402 INFO [stdout] (MSC service thread 1-14) 2012-04-04
>> 10:28:27,402 DEBUG cws.cs.**lendingsimulationservice.util.**JAXBUtil -
>> DocumentBuilderFactory implementation:
>> __redirected.__**DocumentBuilderFactory loaded from:
>> file:/C:/servers/jboss-as-7.0.**2.Final/jboss-modules.jar
>> 10:28:27,403 INFO [stdout] (MSC service thread 1-14) 2012-04-04
>> 10:28:27,403 DEBUG cws.cs.**lendingsimulationservice.util.**JAXBUtil -
>> XPathFactory implementation: __redirected.__XPathFactory loaded from:
>> file:/C:/servers/jboss-as-7.0.**2.Final/jboss-modules.jar
>> 10:28:27,404 INFO [stdout] (MSC service thread 1-14) 2012-04-04
>> 10:28:27,404 DEBUG cws.cs.**lendingsimulationservice.util.**JAXBUtil -
>> TransformerFactory implementation: __redirected.__**TransformerFactory
>> loaded from: file:/C:/servers/jboss-as-7.0.**2.Final/jboss-modules.jar
>> 10:28:27,406 INFO [stdout] (MSC service thread 1-14) 2012-04-04
>> 10:28:27,406 DEBUG cws.cs.**lendingsimulationservice.util.**JAXBUtil -
>> SAXParserFactory implementation: __redirected.__**SAXParserFactory loaded
>> from: file:/C:/servers/jboss-as-7.0.**2.Final/jboss-modules.jar
>>
>>
>> I've tried the following but see no changes either:
>> 1) just dropping the jar in my war,
>> 2) putting both the api and impl jars in JAVA_HOME/jre/lib/endorsed,
>> 3) setting
>> -Djavax.xml.bind.context.**factory=com.sun.xml.bind.v2.**ContextFactory
>>
>> No matter what I try, I always seem to be using the v2.1 that is
>> bundled with the JRE.
>>
>>
>> So two questions arise:
>> 1) How do I properly bundle the new version of JAXB in my app
>> 2) How can I confirm that I am running the new version? Is the above
>> code snippet valid, or is there a bug in there as well?
>>
>> Thanks for any help/advice!
>>
>> Eric
>>
>