Ok it works now. It was an issue of some residues of earlier XmlBeans work
(generated classes and jars ...)

I have some kind of factory class now, which is called like this 

// using TouchpointListType.class instead of the literal would throw a 
NoClassDefError here ...
....util.xml.types11.headstats.TouchpointListDocument tlt =
   (....util.xml.types11.headstats.TouchpointListDocument)
   XmlBeanFactory.parseXml(xmlString11, "headstats11", 
"TouchpointListDocument");

... and contains these methods ...

public static XmlObject parseXml(String xmlstring, String schema,
   String type, String namespace, XmlOptions options) throws XmlException {
   SchemaTypeLoader stl = loadSchema(schema);
   SchemaType st = stl.findType(new QName(namespace, type));
   XmlObject xo = stl.parse(xmlstring, st, options);
   return xo;
}

private static synchronized SchemaTypeLoader loadSchema(String schema) {
   if (schemaLoader == null) {
      schemaLoader = new HashMap();
   }
   SchemaTypeLoader stl = (SchemaTypeLoader)schemaLoader.get(schema);
   if (stl == null) {
      // I use the default classloader (from the web container) instead
      // of the context classloader to not have any problems with the
      // cached SchemaTypeLoaders in different thread contexts
      ClassLoader thisCL = XmlBeanFactory.class.getClassLoader();
      URL urlschema = 
thisCL.getResource("WEB-INF/schema/"+schema+"-schema.jar");
      ClassLoader myCL = new URLClassLoader(new URL[]{urlschema}, thisCL);
      stl = XmlBeans.typeLoaderForClassLoader(myCL);
      schemaLoader.put(schema, stl);
   }
   return stl;
}

Regards,
Andreas.

Reply via email to