Re: xsi:type stripped under Tomcat?

Richard Lavoie <[email protected]>
Newsgroups gmane.text.xml.xmlbeans.user
Message-ID <[email protected]>
I've had that problem a month ago. After digging into Xml beans code, I
discovered a really weird act. What happens in XML beans is when it tries to
get a hold on it's xsb file to put the attributes into the XML, it literally
calls Thread.currentThread().getContextClassLoader() to find it's xsb files,
what I did to solve it was :

ClassLoader mainLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
try {
   your calls for xml beans and axis
...
} finally {
    Thread.currentThread().setContextClassLoader(mainLoader);
}

This put the current contextclassloader to the webappclassloader so xmlbeans
can find the xsb files in the correct classloader;

Hope it solves your problem.

On Thu, Feb 25, 2010 at 3:09 PM, Wing Yew Poon <[email protected]>wrote:

>  Matthew,
> you might try posting to the Axis2 mailing list.
> - Wing Yew
>
>  ------------------------------
> *From:* Matthew Gamble [mailto:[email protected]]
> *Sent:* Thursday, February 25, 2010 6:48 AM
> *To:* [email protected]
> *Subject:* Re: xsi:type stripped under Tomcat?
>
>  Doing some further testing on my own, I've narrowed the issue down to a
> problem when running xmlbeans and Axis2.  Anytime I try to create the XML
> Document inside my Axis2 web service the xsi:type is always stripped as
> below.
>
> I've tried googling for issues with xmlbeans and axis2, but none of the
> results I found appear to apply to my situation.  Does anyone have any
> advice on how to resolve this? I've been banging my head for a week now
> trying to figure out whats going on.
>
>
>
> On 10-02-24 10:47 AM, "Matthew M. Gamble" <[email protected]> wrote:
>
> Išm new to XMLBeans and have been trying to use it to create an XML
> document
>
> as part of a web service.  When I run my code as a standard Java
> application, the XML is correctly generated:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <c:BroadsoftDocument protocol="OCI" xmlns:c="C">
> <sessionId>000000001</sessionId>
> <command xsi:type="AuthenticationRequest"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<http://www.w3.org/2001/XMLSchema-instance%22>
> >
> <userId>admin</userId></command>
> </c:BroadsoftDocument>
>
> However, when the exact same code is run under Tomcat in a servlet I get:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <c:BroadsoftDocument protocol="OCI" xmlns:c="C">
> <sessionId>000000001</sessionId>
> <command>
> <userId>admin</userId></command>
> </c:BroadsoftDocument>
>
> This of course isnšt valid ­ the xsi:type of the łcommand˛ element is
>
> stripped when the code is run under Tomcat.
>
> Does anyone have any suggestions of what I could be doing wrong that would
> cause this type of issue only when running under Tomcat?
>
> Thanks!
>
>
>
> --------------------------------------------------------------------------
>  This electronic message contains information from Primus
> Telecommunications Canada Inc. ("PRIMUS") , which may be legally privileged
> and confidential. The information is intended to be for the use of the
> individual(s) or entity named above. If you are not the intended recipient,
> be aware that any disclosure, copying, distribution or use of the contents
> of this information is prohibited. If you have received this electronic
> message in error, please notify us by telephone or e-mail (to the number or
> address above) immediately. Any views, opinions or advice expressed in this
> electronic message are not necessarily the views, opinions or advice of
> PRIMUS. It is the responsibility of the recipient to ensure that any
> attachments are virus free and PRIMUS bears no responsibility for any loss
> or damage arising in any way from the use thereof.The term "PRIMUS" includes
> its affiliates.
> --------------------------------------------------------------------------
>  Pour la version en français de ce message, veuillez voir
> http://www.primustel.ca/fr/legal/cs.htm
> This message (and any associated files) is intended only for the
> use of the individual or entity to which it is addressed and may
> contain information that is confidential, subject to copyright or
> constitutes a trade secret. If you are not the intended recipient
> you are hereby notified that any dissemination, copying or
> distribution of this message, or files associated with this message,
> is strictly prohibited. If you have received this message in error,
> please notify us immediately by replying to the message and deleting
> it from your computer. Messages sent to and from us may be monitored.
>
> Internet communications cannot be guaranteed to be secure or error-free
> as information could be intercepted, corrupted, lost, destroyed, arrive
> late or incomplete, or contain viruses. Therefore, we do not accept
> responsibility for any errors or omissions that are present in this
> message, or any attachment, that have arisen as a result of e-mail
> transmission. If verification is required, please request a hard-copy
> version. Any views or opinions presented are solely those of the author
> and do not necessarily represent those of the company.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
> This message (and any associated files) is intended only for the
> use of the individual or entity to which it is addressed and may
> contain information that is confidential, subject to copyright or
> constitutes a trade secret. If you are not the intended recipient
> you are hereby notified that any dissemination, copying or
> distribution of this message, or files associated with this message,
> is strictly prohibited. If you have received this message in error,
> please notify us immediately by replying to the message and deleting
> it from your computer. Messages sent to and from us may be monitored.
>
> Internet communications cannot be guaranteed to be secure or error-free
> as information could be intercepted, corrupted, lost, destroyed, arrive
> late or incomplete, or contain viruses. Therefore, we do not accept
> responsibility for any errors or omissions that are present in this
> message, or any attachment, that have arisen as a result of e-mail
> transmission. If verification is required, please request a hard-copy
> version. Any views or opinions presented are solely those of the author
> and do not necessarily represent those of the company.
>



-- 
Richard Lavoie
IT consultant / consultant en informatique
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.