users@jaxb.java.net

Re: jaxb.properties and bgm.ser files in a jar

From: Marek Malowidzki <maom_onet_at_poczta.onet.pl>
Date: Thu, 02 Jan 2003 09:27:20 +0100

> you said you used:
>
> JAXBContext jc = JAXBContext.newInstance("some.my.package",
> some.my.package.WindowTemplate.class.getClassLoader());
>
> but this shouldn't even compile. Shouldn't it be:
>
> JAXBContext jc =
> JAXBContext.newInstance("mao.snmp.screens.smlbindings.screens",
> mao.snmp.screens.smlbindings.screens.WindowTemplate.class.getClassLoader());
>
> Is WindowTemplate.class in the JAR?

Of course, it was

JAXBContext jc =
JAXBContext.newInstance("mao.snmp.screens.xmlbindings.screens",
mao.snmp.screens.xmlbindings.screens.WindowTemplate.class.getClassLoader());

(xmlbindings, not smlbindings). And of course the code compiled ok and the class
was in the jar. I changed the name of the package to an exemplary one, because I
am using a few different XML schemas and thus a few different JAXB-generated
sets of classes. Sorry for that.

Nonetheless, the workarounbd I am using with success is to place both bgm.ser
and jaxb.properties files in a plain directory (or, to be more precide, in a
directory tree that corresponds to the package name), somewhere in a classpath.
Someone suggested here that this approach with ClassLoader was used with success
to refer to these files when they are in a jar. I could not get this behavior
and would like to explain a possible cause. Has anyone tried it with success?

Best regards in 03,

Marek