You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Chris McCann <xm...@greenspot.ca> on 2004/12/08 18:32:36 UTC

XMLBeans in a Servlet Context

Good day,

I am having some troubles using XML beans in a servlet environment.  I
believe the problem is associated with a classpath issue since I have
been able to get the same code to work as a standalone java application
as well as a message driven bean.

Current Scenario: I need to process complex XML documents (including
spatial data) from a JMS Queue.  I started off developing the code as a
standalone Java application and it works correctly.  Then due to a
requirements change I had to modify the code to run as a Message Driven
bean inside OC4J, again I was able to get it to work.  Now due to
another requirements change and a shortcoming in the JMS Queue I need to
run the code as a separate thread managed by a servlet.  Not a big deal
right.... create a thread and call the process method I created in the
original standalone app.  

Unfortunately I am getting a java.lang.ClassCastException while trying
to extract the data.

I've done some poking around and it appears that xml -> java type
mapping is failing to associated the xml with the correct java type.

I have the following code I added to help debug this issue:
Object o = tmpFeature.get_store();  //tmpFeature is the Implementation of the XML beans interface I would normally use 
LOG.debug("find_element_user");
Object q = ((TypeStore)o).find_element_user(FEATURE$1, 0);
printInterfaceNames(q); //Uses reflection to print all the interfaces the object implements
printSuperclasses(q); //Uses reflection to print the class hieracry of an object.


When I run this code as a standalone process I get the following:
DEBUG - XmlToObjectFactory.createElements(73) | find_element_user
DEBUG - XmlToObjectFactory.printInterfaceNames(351) | Interface: ca.bc.gov.srm.app.ilrr.registration.registryagent.schema.ILRRACQUIRERINTERESTSVWType
DEBUG - XmlToObjectFactory.printSuperclasses(340) | SuperClass:net.opengis.gml.impl.AbstractFeatureTypeImpl
DEBUG - XmlToObjectFactory.printSuperclasses(340) | SuperClass:org.apache.xmlbeans.impl.values.XmlComplexContentImpl
DEBUG - XmlToObjectFactory.printSuperclasses(340) | SuperClass:org.apache.xmlbeans.impl.values.XmlObjectBase
DEBUG - XmlToObjectFactory.printSuperclasses(340) | SuperClass:java.lang.Object

Inside Oc4J as a spawned servlet thread I get:
DEBUG - XmlToObjectFactory.createElements(77) | find_element_user
DEBUG - XmlToObjectFactory.printInterfaceNames(356) | Interface: org.apache.xmlbeans.XmlObject
DEBUG - XmlToObjectFactory.printSuperclasses(345) | SuperClass:org.apache.xmlbeans.impl.values.XmlComplexContentImpl
DEBUG - XmlToObjectFactory.printSuperclasses(345) | SuperClass:org.apache.xmlbeans.impl.values.XmlObjectBase
DEBUG - XmlToObjectFactory.printSuperclasses(345) | SuperClass:java.lang.Object

Both programs processed the same XML document exactly.

Can anybody shed some light into what is occurring here?

Thanks,

Chris


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org