You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by ja...@external.t-mobile.at on 2008/06/18 20:16:12 UTC

Antwort: Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared [Virus checked]

Hi,

looks like the same problem i have. But my response is invalid also 
according to soapUI validation.

I'm not using any additional interceptors, only default cxfServlet, 
default bus config etc, without security, attachments etc. and I'm using 
jaxWS+jaxB

This is response, which is problem in my case (cxf is client in this case)

<soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <locationSearchReply 
xmlns="http://www.deltavista.at/schema/locationsearch">
         <foundLocation>
            <street>Stephansplatz</street>
            <houseNumber>1</houseNumber>
            <city>Wien</city>
            <zip xsi:type="xsd:string">1010</zip>
            <country xsi:type="xsd:string">AUT</country>
            <locationMatch>4</locationMatch>
            <similarity>92</similarity>
            <confidence>98</confidence>
         </foundLocation>
      </locationSearchReply>
   </soapenv:Body>
</soapenv:Envelope>

i have a problem with xsd:string inside reply. 

pieces of xsd:
                                        <element name="zip" 
type="locationsearch:Zip" minOccurs="1"/>
                        <simpleType name="Zip">
                                <restriction base="string">
                                        <minLength value="4"/>
                                        <maxLength value="7"/>
                                </restriction>
                        </simpleType>

when i turn off validation, everything works

best regards
jano




Daniel Kulp <dk...@apache.org> 
06/18/2008 20:05
Bitte antworten an
users@cxf.apache.org


An
users@cxf.apache.org
Kopie

Thema
Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a 
QName: the prefix 'ns0' is not declared  [Virus checked]







Very strange.   The message is definitely valid.

Could questions:
1) Do you have any SAAJ type handlers/interceptors on the chain (jaxws 
SOAPHandler, ws-security things, etc...)?

2) I noticed you have a xerces jar...  can you try removing that and 
seeing if the JDK built-in parser will work?  Also, check if you have 
a xalan jar installed and remove that as well.

3) Can you turn off validation.   It looks like it's the validator 
having an issue, not the unmarshaller.   If it unmarshalls OK that 
way, we at least know the parser is giving it the correct data.   If 
that still fails, we'll need to dig in more.

Dan



On Jun 17, 2008, at 12:33 PM, Urciolo, Kevin wrote:

> I am running in to an issue when a Java 5 client using JWSDP is 
> sending
> a request to my CXF (2.1.1 SNAPSHOT) service.  I get an exception,
> Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a
> QName: the prefix 'ns0' is not declared, as shown below.  The type 
> is an
> extension from a base type.  I am assuming this is why "xsi:type" is
> generated by the client since it is not used in other places.
>
> Is there a reason why CXF is having trouble with this?
>
> Type From Schema:
>
>                       <xs:complexType name="Xxx">
>                                <xs:complexContent>
>                                        <xs:extension base="tns:Base">
>                                                <xs:sequence>
>                                                        <xs:element
> minOccurs="1"
> 
> name="a"
> nillable="false" type="xs:boolean" />
>                                                        <xs:element
> minOccurs="1"
> 
> name="b"
> nillable="false" type="xs:boolean" />
>                                                </xs:sequence>
>                                        </xs:extension>
>                                </xs:complexContent>
>                      </xs:complexType>
>
> ------------------------------------------------------------------------
> ------------------------------------------------------------------------
> -----
>
> XML Generated:
>
> <?xml version="1.0"?>
> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:ns0="http://mdc.com">
>  <env:Body>
>    <ns0:createXxxRequest>
>      <ns0:xxx xsi:type="ns0:Xxx">
>        <ns0:name>xxx</ns0:name>
>      </ns0:xxx>
>    </ns0:createXxxRequest>
>  </env:Body>
> </env:Envelope>
>
> ------------------------------------------------------------------------
> ------------------------------------------------------------------------
> -----
>
> Exception In Log:
>
> INFO: Interceptor has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Unmarshalling Error: 
> UndeclaredPrefix:
> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.
>        at
> org 
> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
> a:643)
>        at
> org 
> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
> a:555)
>        at
> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:64)
>        at
> org 
> .apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLite
> ralInInterceptor.java:183)
>        at
> org 
> .apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
> hain.java:221)
>        at
> org 
> .apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiati
> onObserver.java:78)
>        at
> org 
> .apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestin
> ation.java:92)
>        at
> org 
> .apache.cxf.transport.servlet.ServletController.invokeDestination(Ser
> vletController.java:279)
>        at
> org 
> .apache.cxf.transport.servlet.ServletController.invoke(ServletControl
> ler.java:161)
>        at
> org 
> .apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFSe
> rvlet.java:174)
>        at
> org 
> .apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFSe
> rvlet.java:152)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
>        at
> org 
> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> tionFilterChain.java:252)
>        at
> org 
> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> erChain.java:173)
>        at
> org 
> .jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilte
> r.java:96)
>        at
> org 
> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> tionFilterChain.java:202)
>        at
> org 
> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> erChain.java:173)
>        at
> org 
> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
> e.java:213)
>        at
> org 
> .apache.catalina.core.StandardContextValve.invoke(StandardContextValv
> e.java:178)
>        at
> org 
> .jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAs
> sociationValve.java:175)
>        at
> org 
> .jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.j
> ava:74)
>        at
> org 
> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
> :126)
>        at
> org 
> .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
> :105)
>        at
> org 
> .jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnecti
> onValve.java:156)
>        at
> org 
> .apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
> java:107)
>        at
> org 
> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1
> 48)
>        at
> org 
> .apache.coyote.http11.Http11Processor.process(Http11Processor.java:86
> 9)
>        at
> org.apache.coyote.http11.Http11BaseProtocol 
> $Http11ConnectionHandler.proc
> essConnection(Http11BaseProtocol.java:664)
>        at
> org 
> .apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint
> .java:527)
>        at
> org 
> .apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorker
> Thread.java:112)
>        at java.lang.Thread.run(Thread.java:619)
> Caused by: javax.xml.bind.UnmarshalException
> - with linked exception:
> [org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot resolve
> 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.]
>        at
> com 
> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamEx
> ception(UnmarshallerImpl.java:396)
>        at
> com 
> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
> arshallerImpl.java:335)
>        at
> com 
> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unma
> rshallerImpl.java:312)
>        at
> org 
> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
> a:628)
>        ... 31 more
> Caused by: org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot
> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.
>        at
> org 
> .apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unkno
> wn Source)
>        at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
> Source)
>        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> Source)
>        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> Source)
>        at
> org.apache.xerces.impl.xs.XMLSchemaValidator 
> $XSIErrorReporter.reportErro
> r(Unknown Source)
>        at
> org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown
> Source)
>        at
> org 
> .apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unknown
> Source)
>        at
> org 
> .apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
> Source)
>        at
> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
> Source)
>        at
> org 
> .apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unkn
> own Source)
>        at
> com 
> .sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startEle
> ment(ValidatingUnmarshaller.java:73)
>        at
> com 
> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStart
> Element(StAXStreamConnector.java:238)
>        at
> com 
> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAX
> StreamConnector.java:172)
>        at
> com 
> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
> arshallerImpl.java:333)
>        ... 33 more

---
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog








Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared [Virus checked]

Posted by Benson Margulies <bi...@gmail.com>.
I don't have a modularity theory about where you would specify 'schema
validate with Wstx instead of turning it on for JAXB', but I'm game to
try it based on someone else's suggestion.

On Wed, Jul 15, 2009 at 1:53 PM, Daniel Kulp<dk...@apache.org> wrote:
>
> Your error definitely is different than the one logged in JIRA as that test
>
>
> On Mon July 13 2009 12:13:45 pm Marc Giger wrote:
>> Hi Dan,
>>
>> We encountered exactly the same problem last week (Cxf 2.1.5).
>> The culprit seems to be W3CDomStreamReader which doesn't
>> return the namespace for an Attribute which is declared as xs:QName
>> (2.6.1:
>> http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions).
>
> Well, it's not a problem with the W3CDomStreamReader, it's definitely a
> problem with JAXB's validation routines.    The testcase that was provided in
> CXF's JIRA doesn't involve the W3CDomStreamReader at all, just a straight StAX
> reader, and the problem persists.
>
> I've logged a bug with the JAXB folks:
> https://jaxb.dev.java.net/issues/show_bug.cgi?id=665
>
> There really isn't much we can do.   The NamespaceContext on the
> XMLStreamReader doesn't provide us a way to "copy" all the namespaces into the
> current element to get it to work.   Thus, we'd REALLY have to hack things up
> to work around it.  Probably immediately (after StaxInInterceptor) wrapper the
> XMLStreamReader with something that would maintain a usable NamespaceContext.
> Not really fun to do, but doable.
>
> The other alternative, which will be possible with CXF 2.3, will be to NOT use
> the JAXB schema validation and use the validation built into Woodstox.   I
> know Benson has worked on getting that working for Aegis, but it could work
> for JAXB as well.   There just hasn't been a compelling reason for it yet.
>
> Dan
>
>
>
>
>
>>
>> AFAICS there are two possible solutions:
>>
>> /**
>>      * Find name spaces declaration in atrributes and move them to
>> separate
>>      * collection.
>>      */
>>     @Override
>>     protected final void newFrame(ElementFrame<Node, Node> frame) {
>>         Node element = getCurrentNode();
>>         frame.uris = new ArrayList<String>();
>>         frame.prefixes = new ArrayList<String>();
>>         frame.attributes = new ArrayList<Object>();
>>
>>         if (context == null) {
>>             context = new W3CNamespaceContext();
>>         }
>>         if (element instanceof Element) {
>>             context.setElement((Element)element);
>>         }
>>
>>         NamedNodeMap nodes = element.getAttributes();
>>
>>         String ePrefix = element.getPrefix();
>>         if (ePrefix == null) {
>>             ePrefix = "";
>>         }
>>
>>         if (nodes != null) {
>>             for (int i = 0; i < nodes.getLength(); i++) {
>>                 Node node = nodes.item(i);
>>                 String prefix = node.getPrefix();
>>                 String localName = node.getLocalName();
>>                 String value = node.getNodeValue();
>>                 String name = node.getNodeName();
>>
>>                 if (prefix == null) {
>>                     prefix = "";
>>                 }
>>
>>                 if (name != null && "xmlns".equals(name)) {
>>                     frame.uris.add(value);
>>                     frame.prefixes.add("");
>>                 } else if (prefix.length() > 0 &&
>>                 "xmlns".equals(prefix)) { frame.uris.add(value);
>>                     frame.prefixes.add(localName);
>>                 } else if (name.startsWith("xmlns:")) {
>>                     prefix = name.substring(6);
>>                     frame.uris.add(value);
>>                     frame.prefixes.add(prefix);
>>                 } else {
>>                     frame.attributes.add(node);
>>                 }
>>             }
>>         }
>>     }
>>
>> In the loop, test the _value_ of an attribute for the existence of an
>> colon (":") and lookup the prefix (ugly)
>>
>> or:
>>
>> public int getNamespaceCount() {
>>         return getCurrentFrame().prefixes.size();
>>     }
>>
>>     public String getNamespacePrefix(int i) {
>>         return getCurrentFrame().prefixes.get(i);
>>     }
>>
>>     public String getNamespaceURI(int i) {
>>         return getCurrentFrame().uris.get(i);
>>     }
>>
>> change these methods to return the namespaces from the parent frames
>> too (needs some more thinking because of duplicate prefixes with
>> different urls, etc)...
>>
>> What do you think?
>>
>> Question: I didn't understand for what the ElementFrames are good for.
>> Can you explain me this?
>>
>> Thanks & Greetings
>>
>> Marc
>>
>>
>> On Mon, 13 Jul 2009 11:29:44 -0400
>>
>> Daniel Kulp <dk...@apache.org> wrote:
>> > On Mon July 13 2009 10:16:13 am jp4 wrote:
>> > > Dan,
>> > >
>> > > I upgraded to CXF 2.2.2 and tried once again with Java 6.  I am
>> > > still seeing the same error.  The type is properly declared, and I
>> > > can validate the same XML with a servlet that uses the same XSDs.
>> > > Should I open a bug for this? Any other ideas?
>> >
>> > Yes, please do open a bug, but we'll probably need a testcase that
>> > shows the error as I'm not sure how to reproduce it without a test
>> > case.
>> >
>> > Thanks!
>> > Dan
>> >
>> > > Thanks,
>> > >
>> > > John
>> > >
>> > > dkulp wrote:
>> > > > On Thu July 9 2009 10:34:38 am jp4 wrote:
>> > > >> I am seeing a similar behavior where the xsi:type causes the
>> > > >> UndeclaredPrefix error.  Initially I was running CXF 2.2 with
>> > > >> JDK 1.5 on
>> > > >
>> > > > Well, definitely try with CXF 2.2.2.   That may help.
>> > > >
>> > > > If that doesn't help, use something like wireshark or similar to
>> > > > capture the
>> > > > raw message off the wire and see if ns3 is actually properly
>> > > > declared on the
>> > > > wire.   If not, that would probably be a bug.
>> > > >
>> > > > Dan
>> > > >
>> > > >> Jboss 4.2.3.GA.  I have since upgraded to Java 6.  I send a
>> > > >> sample request
>> > > >> through SOAPUI and I still see the same error below...  If I
>> > > >> attempt to validate the same file from within the container
>> > > >> using a servlet and the code below, it validates just fine.  Any
>> > > >> idea what could be causing the discrepancy?
>> > > >>
>> > > >>         Source source = new
>> > > >> StreamSource(getClass().getResourceAsStream("/request.xml"));
>> > > >>         // If you comment the following line, it works
>> > > >>         source = toDOMSource(source);
>> > > >>         validator.validate(source);
>> > > >>
>> > > >>
>> > > >> <07/09/09
>> > > >> 10:23:37:779|http-8443-2|INFO|apache.cxf.phase.PhaseInterceptorChain
>> > > >>|Int erc eptor has thrown exception, unwinding now|
>> > > >> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
>> > > >> UndeclaredPrefix: Cannot resolve 'ns3:FundingSourceType' as a
>> > > >> QName: the prefix 'ns3' is not
>> > > >> declared.
>> > > >>        at
>> > > >> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder
>> > > >>.jav a:6 22) at
>> > > >> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder
>> > > >>.jav a:5 27) at
>> > > >> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:108)
>> > > >> at
>> > > >> org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(Doc
>> > > >>Lite ral InInterceptor.java:183) at
>> > > >> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercep
>> > > >>torC hai n.java:236) at
>> > > >> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInit
>> > > >>iati onO bserver.java:89) at
>> > > >> org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDe
>> > > >>stin ati on.java:99) at
>> > > >> org.apache.cxf.transport.servlet.ServletController.invokeDestination
>> > > >>(Ser vle tController.java:337) at
>> > > >> org.apache.cxf.transport.servlet.ServletController.invoke(ServletCon
>> > > >>trol ler .java:182) at
>> > > >> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractC
>> > > >>XFSe rvl et.java:163) at
>> > > >> org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractC
>> > > >>XFSe rvl et.java:141) at
>> > >
>> > > javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>> > >
>> > > >>        at
>> > > >> javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at
>> > > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
>> > > >>lica tio nFilterChain.java:290) at
>> > > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
>> > > >>Filt erC hain.java:206) at
>> > > >> com.billmelater.enterpriseservices.servlet.util.RequestTimerServletF
>> > > >>ilte r.d oFilter(RequestTimerServletFilter.java:55) at
>> > > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
>> > > >>lica tio nFilterChain.java:235) at
>> > > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
>> > > >>Filt erC hain.java:206) at
>> > > >> org.springframework.security.util.FilterChainProxy$VirtualFilterChai
>> > > >>n.do Fil ter(FilterChainProxy.java:378) at
>> > > >> org.springframework.security.intercept.web.FilterSecurityInterceptor
>> > > >>.inv oke (FilterSecurityInterceptor.java:109)
>> > > >>
>> > > >> dkulp wrote:
>> > > >> > Did some snooping...   The RI seems to have the same problem:
>> > > >> > http://forums.java.net/jive//message.jspa?messageID=268876
>> > > >> >
>> > > >> > And they mention its a bug in the JDK:
>> > > >> > https://jaxp.dev.java.net/issues/show_bug.cgi?id=46
>> > > >> >
>> > > >> > The workaround seems to be to use the latest 1.6 JDK or get
>> > > >> > the latest sun jaxp parser
>> > > >> > (http://download.java.net/maven/1/com.sun.xml.parsers/jars/
>> > > >> > )  and throw it in your endorsed dir.
>> > > >> >
>> > > >> > Dan
>> > > >> >
>> > > >> > On Jun 18, 2008, at 2:16 PM,
>> > > >> > jan.minaroviech@external.t-mobile.at
>> > > >>
>> > > >> wrote:
>> > > >> >> Hi,
>> > > >> >>
>> > > >> >> looks like the same problem i have. But my response is
>> > > >> >> invalid also according to soapUI validation.
>> > > >> >>
>> > > >> >> I'm not using any additional interceptors, only default
>> > > >> >> cxfServlet, default bus config etc, without security,
>> > > >> >> attachments etc. and I'm using
>> > > >> >> jaxWS+jaxB
>> > > >> >>
>> > > >> >> This is response, which is problem in my case (cxf is client
>> > > >> >> in this case)
>> > > >> >>
>> > > >> >> <soapenv:Envelope
>> > > >> >> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>> > > >> >> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> > > >> >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>> > > >> >>   <soapenv:Body>
>> > > >> >>      <locationSearchReply
>> > > >> >> xmlns="http://www.deltavista.at/schema/locationsearch">
>> > > >> >>         <foundLocation>
>> > > >> >>            <street>Stephansplatz</street>
>> > > >> >>            <houseNumber>1</houseNumber>
>> > > >> >>            <city>Wien</city>
>> > > >> >>            <zip xsi:type="xsd:string">1010</zip>
>> > > >> >>            <country xsi:type="xsd:string">AUT</country>
>> > > >> >>            <locationMatch>4</locationMatch>
>> > > >> >>            <similarity>92</similarity>
>> > > >> >>            <confidence>98</confidence>
>> > > >> >>         </foundLocation>
>> > > >> >>      </locationSearchReply>
>> > > >> >>   </soapenv:Body>
>> > > >> >> </soapenv:Envelope>
>> > > >> >>
>> > > >> >> i have a problem with xsd:string inside reply.
>> > > >> >>
>> > > >> >> pieces of xsd:
>> > > >> >>                                        <element name="zip"
>> > > >> >> type="locationsearch:Zip" minOccurs="1"/>
>> > > >> >>                        <simpleType name="Zip">
>> > > >> >>                                <restriction base="string">
>> > > >> >>                                        <minLength value="4"/>
>> > > >> >>                                        <maxLength value="7"/>
>> > > >> >>                                </restriction>
>> > > >> >>                        </simpleType>
>> > > >> >>
>> > > >> >> when i turn off validation, everything works
>> > > >> >>
>> > > >> >> best regards
>> > > >> >> jano
>> > > >> >>
>> > > >> >>
>> > > >> >>
>> > > >> >>
>> > > >> >> Daniel Kulp <dk...@apache.org>
>> > > >> >> 06/18/2008 20:05
>> > > >> >> Bitte antworten an
>> > > >> >> users@cxf.apache.org
>> > > >> >>
>> > > >> >>
>> > > >> >> An
>> > > >> >> users@cxf.apache.org
>> > > >> >> Kopie
>> > > >> >>
>> > > >> >> Thema
>> > > >> >> Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve
>> > > >> >> 'ns0:Xxx' as a
>> > > >> >> QName: the prefix 'ns0' is not declared  [Virus checked]
>> > > >> >>
>> > > >> >>
>> > > >> >>
>> > > >> >>
>> > > >> >>
>> > > >> >>
>> > > >> >>
>> > > >> >> Very strange.   The message is definitely valid.
>> > > >> >>
>> > > >> >> Could questions:
>> > > >> >> 1) Do you have any SAAJ type handlers/interceptors on the
>> > > >> >> chain (jaxws SOAPHandler, ws-security things, etc...)?
>> > > >> >>
>> > > >> >> 2) I noticed you have a xerces jar...  can you try removing
>> > > >> >> that and seeing if the JDK built-in parser will work?  Also,
>> > > >> >> check if you have a xalan jar installed and remove that as
>> > > >> >> well.
>> > > >> >>
>> > > >> >> 3) Can you turn off validation.   It looks like it's the
>> > > >> >> validator having an issue, not the unmarshaller.   If it
>> > > >> >> unmarshalls OK that way, we at least know the parser is
>> > > >> >> giving it the correct data.   If that still fails, we'll need
>> > > >> >> to dig in more.
>> > > >> >>
>> > > >> >> Dan
>> > > >> >>
>> > > >> >> On Jun 17, 2008, at 12:33 PM, Urciolo, Kevin wrote:
>> > > >> >>> I am running in to an issue when a Java 5 client using JWSDP
>> > > >> >>> is sending
>> > > >> >>> a request to my CXF (2.1.1 SNAPSHOT) service.  I get an
>> > > >> >>> exception, Unmarshalling Error: UndeclaredPrefix: Cannot
>> > > >> >>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
>> > > >> >>> declared, as shown below.  The type is an
>> > > >> >>> extension from a base type.  I am assuming this is why
>> > > >> >>> "xsi:type" is generated by the client since it is not used
>> > > >> >>> in other places.
>> > > >> >>>
>> > > >> >>> Is there a reason why CXF is having trouble with this?
>> > > >> >>>
>> > > >> >>> Type From Schema:
>> > > >> >>>
>> > > >> >>>                      <xs:complexType name="Xxx">
>> > > >> >>>                               <xs:complexContent>
>> > > >> >>>                                       <xs:extension
>> > > >> >>> base="tns:Base"> <xs:sequence>
>> > > >> >>>
>> > > >> >>> <xs:element minOccurs="1"
>> > > >> >>>
>> > > >> >>> name="a"
>> > > >> >>> nillable="false" type="xs:boolean" />
>> > > >> >>>
>> > > >> >>> <xs:element minOccurs="1"
>> > > >> >>>
>> > > >> >>> name="b"
>> > > >> >>> nillable="false" type="xs:boolean" />
>> > > >> >>>                                               </xs:sequence>
>> > > >> >>>                                       </xs:extension>
>> > > >> >>>                               </xs:complexContent>
>> > > >> >>>                     </xs:complexType>
>> > > >>
>> > > >> --------------------------------------------------------------------
>> > > >>---
>> > > >>
>> > > >> >>>-
>> > > >>
>> > > >> --------------------------------------------------------------------
>> > > >>---
>> > > >>
>> > > >> >>>- -----
>> > > >> >>>
>> > > >> >>> XML Generated:
>> > > >> >>>
>> > > >> >>> <?xml version="1.0"?>
>> > > >> >>> <env:Envelope
>> > > >> >>> xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
>> > > >> >>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> > > >> >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> > > >> >>> xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
>> > > >> >>> xmlns:ns0="http://mdc.com"> <env:Body>
>> > > >> >>>   <ns0:createXxxRequest>
>> > > >> >>>     <ns0:xxx xsi:type="ns0:Xxx">
>> > > >> >>>       <ns0:name>xxx</ns0:name>
>> > > >> >>>     </ns0:xxx>
>> > > >> >>>   </ns0:createXxxRequest>
>> > > >> >>> </env:Body>
>> > > >> >>> </env:Envelope>
>> > > >>
>> > > >> --------------------------------------------------------------------
>> > > >>---
>> > > >>
>> > > >> >>>-
>> > > >>
>> > > >> --------------------------------------------------------------------
>> > > >>---
>> > > >>
>> > > >> >>>- -----
>> > > >> >>>
>> > > >> >>> Exception In Log:
>> > > >> >>>
>> > > >> >>> INFO: Interceptor has thrown exception, unwinding now
>> > > >> >>> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
>> > > >> >>> UndeclaredPrefix:
>> > > >> >>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
>> > > >> >>> declared.
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecode
>> > > >> >>>r.ja v a:643)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecode
>> > > >> >>>r.ja v a:555)
>> > > >> >>>       at
>> > > >> >>> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:6
>> > > >> >>>4) at
>> > > >> >>> org
>> > > >> >>> .apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(Do
>> > > >> >>>cLit e ralInInterceptor.java:183)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterce
>> > > >> >>>ptor C hain.java:221)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIni
>> > > >> >>>tiat i onObserver.java:78)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.cxf.transport.servlet.ServletDestination.invoke(ServletD
>> > > >> >>>esti n ation.java:92)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.cxf.transport.servlet.ServletController.invokeDestinatio
>> > > >> >>>n(Se r vletController.java:279)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.cxf.transport.servlet.ServletController.invoke(ServletCo
>> > > >> >>>ntro l ler.java:161)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.cxf.transport.servlet.AbstractCXFServlet.invoke(Abstract
>> > > >> >>>CXFS e rvlet.java:174)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.cxf.transport.servlet.AbstractCXFServlet.doPost(Abstract
>> > > >> >>>CXFS e rvlet.java:152)
>> > > >> >>>       at
>> > > >> >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>> > > >> >>> at
>> > > >> >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
>> > > >> >>> at
>> > > >> >>> org
>> > > >> >>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Ap
>> > > >> >>>plic a tionFilterChain.java:252)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.catalina.core.ApplicationFilterChain.doFilter(Applicatio
>> > > >> >>>nFil t erChain.java:173)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeader
>> > > >> >>>Filt e r.java:96)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Ap
>> > > >> >>>plic a tionFilterChain.java:202)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.catalina.core.ApplicationFilterChain.doFilter(Applicatio
>> > > >> >>>nFil t erChain.java:173)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrappe
>> > > >> >>>rVal v e.java:213)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.catalina.core.StandardContextValve.invoke(StandardContex
>> > > >> >>>tVal v e.java:178)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .jboss.web.tomcat.security.SecurityAssociationValve.invoke(Secur
>> > > >> >>>ityA s sociationValve.java:175)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextVa
>> > > >> >>>lve. j ava:74)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve
>> > > >> >>>.jav a
>> > > >> >>>
>> > > >> >>> :126)
>> > > >> >>>
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve
>> > > >> >>>.jav a
>> > > >> >>>
>> > > >> >>> :105)
>> > > >> >>>
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedCon
>> > > >> >>>nect i onValve.java:156)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.catalina.core.StandardEngineValve.invoke(StandardEngineV
>> > > >> >>>alve . java:107)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.j
>> > > >> >>>ava: 1 48)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.coyote.http11.Http11Processor.process(Http11Processor.ja
>> > > >> >>>va:8 6 9)
>> > > >> >>>       at
>> > > >> >>> org.apache.coyote.http11.Http11BaseProtocol
>> > > >> >>> $Http11ConnectionHandler.proc
>> > > >> >>> essConnection(Http11BaseProtocol.java:664)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEnd
>> > > >> >>>poin t .java:527)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveW
>> > > >> >>>orke r Thread.java:112)
>> > > >> >>>       at java.lang.Thread.run(Thread.java:619)
>> > > >> >>> Caused by: javax.xml.bind.UnmarshalException
>> > > >> >>> - with linked exception:
>> > > >> >>> [org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot
>> > > >> >>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
>> > > >> >>> declared.] at
>> > > >> >>> com
>> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStr
>> > > >> >>>eamE x ception(UnmarshallerImpl.java:396)
>> > > >> >>>       at
>> > > >> >>> com
>> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal
>> > > >> >>>0(Un m arshallerImpl.java:335)
>> > > >> >>>       at
>> > > >> >>> com
>> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal
>> > > >> >>>(Unm a rshallerImpl.java:312)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecode
>> > > >> >>>r.ja v a:628)
>> > > >> >>>       ... 31 more
>> > > >> >>> Caused by: org.xml.sax.SAXParseException: UndeclaredPrefix:
>> > > >> >>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
>> > > >> >>> declared. at
>> > > >> >>> org
>> > > >> >>> .apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(
>> > > >> >>>Unkn o wn Source)
>> > > >> >>>       at
>> > > >> >>> org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
>> > > >> >>> Source) at
>> > > >> >>> org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>> > > >> >>> Source) at
>> > > >> >>> org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>> > > >> >>> Source) at
>> > > >> >>> org.apache.xerces.impl.xs.XMLSchemaValidator
>> > > >> >>> $XSIErrorReporter.reportErro
>> > > >> >>> r(Unknown Source)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unkn
>> > > >> >>>own Source)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unk
>> > > >> >>>nown Source)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unk
>> > > >> >>>nown Source)
>> > > >> >>>       at
>> > > >> >>> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknow
>> > > >> >>>n Source)
>> > > >> >>>       at
>> > > >> >>> org
>> > > >> >>> .apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement
>> > > >> >>>(Unk n own Source)
>> > > >> >>>       at
>> > > >> >>> com
>> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.sta
>> > > >> >>>rtEl e ment(ValidatingUnmarshaller.java:73)
>> > > >> >>>       at
>> > > >> >>> com
>> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handle
>> > > >> >>>Star t Element(StAXStreamConnector.java:238)
>> > > >> >>>       at
>> > > >> >>> com
>> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge
>> > > >> >>>(StA X StreamConnector.java:172)
>> > > >> >>>       at
>> > > >> >>> com
>> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal
>> > > >> >>>0(Un m arshallerImpl.java:333)
>> > > >> >>>       ... 33 more
>> > > >> >>
>> > > >> >> ---
>> > > >> >> Daniel Kulp
>> > > >> >> dkulp@apache.org
>> > > >> >> http://www.dankulp.com/blog
>> > > >> >
>> > > >> > ---
>> > > >> > Daniel Kulp
>> > > >> > dkulp@apache.org
>> > > >> > http://www.dankulp.com/blog
>> > > >
>> > > > --
>> > > > Daniel Kulp
>> > > > dkulp@apache.org
>> > > > http://www.dankulp.com/blog
>> >
>> > --
>> > Daniel Kulp
>> > dkulp@apache.org
>> > http://www.dankulp.com/blog
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared [Virus checked]

Posted by Daniel Kulp <dk...@apache.org>.
Your error definitely is different than the one logged in JIRA as that test 


On Mon July 13 2009 12:13:45 pm Marc Giger wrote:
> Hi Dan,
>
> We encountered exactly the same problem last week (Cxf 2.1.5).
> The culprit seems to be W3CDomStreamReader which doesn't
> return the namespace for an Attribute which is declared as xs:QName
> (2.6.1:
> http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions).

Well, it's not a problem with the W3CDomStreamReader, it's definitely a 
problem with JAXB's validation routines.    The testcase that was provided in 
CXF's JIRA doesn't involve the W3CDomStreamReader at all, just a straight StAX 
reader, and the problem persists.

I've logged a bug with the JAXB folks:
https://jaxb.dev.java.net/issues/show_bug.cgi?id=665

There really isn't much we can do.   The NamespaceContext on the 
XMLStreamReader doesn't provide us a way to "copy" all the namespaces into the 
current element to get it to work.   Thus, we'd REALLY have to hack things up 
to work around it.  Probably immediately (after StaxInInterceptor) wrapper the 
XMLStreamReader with something that would maintain a usable NamespaceContext.   
Not really fun to do, but doable.

The other alternative, which will be possible with CXF 2.3, will be to NOT use 
the JAXB schema validation and use the validation built into Woodstox.   I 
know Benson has worked on getting that working for Aegis, but it could work 
for JAXB as well.   There just hasn't been a compelling reason for it yet.  

Dan





>
> AFAICS there are two possible solutions:
>
> /**
>      * Find name spaces declaration in atrributes and move them to
> separate
>      * collection.
>      */
>     @Override
>     protected final void newFrame(ElementFrame<Node, Node> frame) {
>         Node element = getCurrentNode();
>         frame.uris = new ArrayList<String>();
>         frame.prefixes = new ArrayList<String>();
>         frame.attributes = new ArrayList<Object>();
>
>         if (context == null) {
>             context = new W3CNamespaceContext();
>         }
>         if (element instanceof Element) {
>             context.setElement((Element)element);
>         }
>
>         NamedNodeMap nodes = element.getAttributes();
>
>         String ePrefix = element.getPrefix();
>         if (ePrefix == null) {
>             ePrefix = "";
>         }
>
>         if (nodes != null) {
>             for (int i = 0; i < nodes.getLength(); i++) {
>                 Node node = nodes.item(i);
>                 String prefix = node.getPrefix();
>                 String localName = node.getLocalName();
>                 String value = node.getNodeValue();
>                 String name = node.getNodeName();
>
>                 if (prefix == null) {
>                     prefix = "";
>                 }
>
>                 if (name != null && "xmlns".equals(name)) {
>                     frame.uris.add(value);
>                     frame.prefixes.add("");
>                 } else if (prefix.length() > 0 &&
>                 "xmlns".equals(prefix)) { frame.uris.add(value);
>                     frame.prefixes.add(localName);
>                 } else if (name.startsWith("xmlns:")) {
>                     prefix = name.substring(6);
>                     frame.uris.add(value);
>                     frame.prefixes.add(prefix);
>                 } else {
>                     frame.attributes.add(node);
>                 }
>             }
>         }
>     }
>
> In the loop, test the _value_ of an attribute for the existence of an
> colon (":") and lookup the prefix (ugly)
>
> or:
>
> public int getNamespaceCount() {
>         return getCurrentFrame().prefixes.size();
>     }
>
>     public String getNamespacePrefix(int i) {
>         return getCurrentFrame().prefixes.get(i);
>     }
>
>     public String getNamespaceURI(int i) {
>         return getCurrentFrame().uris.get(i);
>     }
>
> change these methods to return the namespaces from the parent frames
> too (needs some more thinking because of duplicate prefixes with
> different urls, etc)...
>
> What do you think?
>
> Question: I didn't understand for what the ElementFrames are good for.
> Can you explain me this?
>
> Thanks & Greetings
>
> Marc
>
>
> On Mon, 13 Jul 2009 11:29:44 -0400
>
> Daniel Kulp <dk...@apache.org> wrote:
> > On Mon July 13 2009 10:16:13 am jp4 wrote:
> > > Dan,
> > >
> > > I upgraded to CXF 2.2.2 and tried once again with Java 6.  I am
> > > still seeing the same error.  The type is properly declared, and I
> > > can validate the same XML with a servlet that uses the same XSDs.
> > > Should I open a bug for this? Any other ideas?
> >
> > Yes, please do open a bug, but we'll probably need a testcase that
> > shows the error as I'm not sure how to reproduce it without a test
> > case.
> >
> > Thanks!
> > Dan
> >
> > > Thanks,
> > >
> > > John
> > >
> > > dkulp wrote:
> > > > On Thu July 9 2009 10:34:38 am jp4 wrote:
> > > >> I am seeing a similar behavior where the xsi:type causes the
> > > >> UndeclaredPrefix error.  Initially I was running CXF 2.2 with
> > > >> JDK 1.5 on
> > > >
> > > > Well, definitely try with CXF 2.2.2.   That may help.
> > > >
> > > > If that doesn't help, use something like wireshark or similar to
> > > > capture the
> > > > raw message off the wire and see if ns3 is actually properly
> > > > declared on the
> > > > wire.   If not, that would probably be a bug.
> > > >
> > > > Dan
> > > >
> > > >> Jboss 4.2.3.GA.  I have since upgraded to Java 6.  I send a
> > > >> sample request
> > > >> through SOAPUI and I still see the same error below...  If I
> > > >> attempt to validate the same file from within the container
> > > >> using a servlet and the code below, it validates just fine.  Any
> > > >> idea what could be causing the discrepancy?
> > > >>
> > > >>         Source source = new
> > > >> StreamSource(getClass().getResourceAsStream("/request.xml"));
> > > >>         // If you comment the following line, it works
> > > >>         source = toDOMSource(source);
> > > >>         validator.validate(source);
> > > >>
> > > >>
> > > >> <07/09/09
> > > >> 10:23:37:779|http-8443-2|INFO|apache.cxf.phase.PhaseInterceptorChain
> > > >>|Int erc eptor has thrown exception, unwinding now|
> > > >> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
> > > >> UndeclaredPrefix: Cannot resolve 'ns3:FundingSourceType' as a
> > > >> QName: the prefix 'ns3' is not
> > > >> declared.
> > > >> 	at
> > > >> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder
> > > >>.jav a:6 22) at
> > > >> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder
> > > >>.jav a:5 27) at
> > > >> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:108)
> > > >> at
> > > >> org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(Doc
> > > >>Lite ral InInterceptor.java:183) at
> > > >> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercep
> > > >>torC hai n.java:236) at
> > > >> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInit
> > > >>iati onO bserver.java:89) at
> > > >> org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDe
> > > >>stin ati on.java:99) at
> > > >> org.apache.cxf.transport.servlet.ServletController.invokeDestination
> > > >>(Ser vle tController.java:337) at
> > > >> org.apache.cxf.transport.servlet.ServletController.invoke(ServletCon
> > > >>trol ler .java:182) at
> > > >> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractC
> > > >>XFSe rvl et.java:163) at
> > > >> org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractC
> > > >>XFSe rvl et.java:141) at
> > >
> > > javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
> > >
> > > >> 	at
> > > >> javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at
> > > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
> > > >>lica tio nFilterChain.java:290) at
> > > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
> > > >>Filt erC hain.java:206) at
> > > >> com.billmelater.enterpriseservices.servlet.util.RequestTimerServletF
> > > >>ilte r.d oFilter(RequestTimerServletFilter.java:55) at
> > > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
> > > >>lica tio nFilterChain.java:235) at
> > > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
> > > >>Filt erC hain.java:206) at
> > > >> org.springframework.security.util.FilterChainProxy$VirtualFilterChai
> > > >>n.do Fil ter(FilterChainProxy.java:378) at
> > > >> org.springframework.security.intercept.web.FilterSecurityInterceptor
> > > >>.inv oke (FilterSecurityInterceptor.java:109)
> > > >>
> > > >> dkulp wrote:
> > > >> > Did some snooping...   The RI seems to have the same problem:
> > > >> > http://forums.java.net/jive//message.jspa?messageID=268876
> > > >> >
> > > >> > And they mention its a bug in the JDK:
> > > >> > https://jaxp.dev.java.net/issues/show_bug.cgi?id=46
> > > >> >
> > > >> > The workaround seems to be to use the latest 1.6 JDK or get
> > > >> > the latest sun jaxp parser
> > > >> > (http://download.java.net/maven/1/com.sun.xml.parsers/jars/
> > > >> > )  and throw it in your endorsed dir.
> > > >> >
> > > >> > Dan
> > > >> >
> > > >> > On Jun 18, 2008, at 2:16 PM,
> > > >> > jan.minaroviech@external.t-mobile.at
> > > >>
> > > >> wrote:
> > > >> >> Hi,
> > > >> >>
> > > >> >> looks like the same problem i have. But my response is
> > > >> >> invalid also according to soapUI validation.
> > > >> >>
> > > >> >> I'm not using any additional interceptors, only default
> > > >> >> cxfServlet, default bus config etc, without security,
> > > >> >> attachments etc. and I'm using
> > > >> >> jaxWS+jaxB
> > > >> >>
> > > >> >> This is response, which is problem in my case (cxf is client
> > > >> >> in this case)
> > > >> >>
> > > >> >> <soapenv:Envelope
> > > >> >> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> > > >> >> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > > >> >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> > > >> >>   <soapenv:Body>
> > > >> >>      <locationSearchReply
> > > >> >> xmlns="http://www.deltavista.at/schema/locationsearch">
> > > >> >>         <foundLocation>
> > > >> >>            <street>Stephansplatz</street>
> > > >> >>            <houseNumber>1</houseNumber>
> > > >> >>            <city>Wien</city>
> > > >> >>            <zip xsi:type="xsd:string">1010</zip>
> > > >> >>            <country xsi:type="xsd:string">AUT</country>
> > > >> >>            <locationMatch>4</locationMatch>
> > > >> >>            <similarity>92</similarity>
> > > >> >>            <confidence>98</confidence>
> > > >> >>         </foundLocation>
> > > >> >>      </locationSearchReply>
> > > >> >>   </soapenv:Body>
> > > >> >> </soapenv:Envelope>
> > > >> >>
> > > >> >> i have a problem with xsd:string inside reply.
> > > >> >>
> > > >> >> pieces of xsd:
> > > >> >>                                        <element name="zip"
> > > >> >> type="locationsearch:Zip" minOccurs="1"/>
> > > >> >>                        <simpleType name="Zip">
> > > >> >>                                <restriction base="string">
> > > >> >>                                        <minLength value="4"/>
> > > >> >>                                        <maxLength value="7"/>
> > > >> >>                                </restriction>
> > > >> >>                        </simpleType>
> > > >> >>
> > > >> >> when i turn off validation, everything works
> > > >> >>
> > > >> >> best regards
> > > >> >> jano
> > > >> >>
> > > >> >>
> > > >> >>
> > > >> >>
> > > >> >> Daniel Kulp <dk...@apache.org>
> > > >> >> 06/18/2008 20:05
> > > >> >> Bitte antworten an
> > > >> >> users@cxf.apache.org
> > > >> >>
> > > >> >>
> > > >> >> An
> > > >> >> users@cxf.apache.org
> > > >> >> Kopie
> > > >> >>
> > > >> >> Thema
> > > >> >> Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve
> > > >> >> 'ns0:Xxx' as a
> > > >> >> QName: the prefix 'ns0' is not declared  [Virus checked]
> > > >> >>
> > > >> >>
> > > >> >>
> > > >> >>
> > > >> >>
> > > >> >>
> > > >> >>
> > > >> >> Very strange.   The message is definitely valid.
> > > >> >>
> > > >> >> Could questions:
> > > >> >> 1) Do you have any SAAJ type handlers/interceptors on the
> > > >> >> chain (jaxws SOAPHandler, ws-security things, etc...)?
> > > >> >>
> > > >> >> 2) I noticed you have a xerces jar...  can you try removing
> > > >> >> that and seeing if the JDK built-in parser will work?  Also,
> > > >> >> check if you have a xalan jar installed and remove that as
> > > >> >> well.
> > > >> >>
> > > >> >> 3) Can you turn off validation.   It looks like it's the
> > > >> >> validator having an issue, not the unmarshaller.   If it
> > > >> >> unmarshalls OK that way, we at least know the parser is
> > > >> >> giving it the correct data.   If that still fails, we'll need
> > > >> >> to dig in more.
> > > >> >>
> > > >> >> Dan
> > > >> >>
> > > >> >> On Jun 17, 2008, at 12:33 PM, Urciolo, Kevin wrote:
> > > >> >>> I am running in to an issue when a Java 5 client using JWSDP
> > > >> >>> is sending
> > > >> >>> a request to my CXF (2.1.1 SNAPSHOT) service.  I get an
> > > >> >>> exception, Unmarshalling Error: UndeclaredPrefix: Cannot
> > > >> >>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
> > > >> >>> declared, as shown below.  The type is an
> > > >> >>> extension from a base type.  I am assuming this is why
> > > >> >>> "xsi:type" is generated by the client since it is not used
> > > >> >>> in other places.
> > > >> >>>
> > > >> >>> Is there a reason why CXF is having trouble with this?
> > > >> >>>
> > > >> >>> Type From Schema:
> > > >> >>>
> > > >> >>>                      <xs:complexType name="Xxx">
> > > >> >>>                               <xs:complexContent>
> > > >> >>>                                       <xs:extension
> > > >> >>> base="tns:Base"> <xs:sequence>
> > > >> >>>                                                      
> > > >> >>> <xs:element minOccurs="1"
> > > >> >>>
> > > >> >>> name="a"
> > > >> >>> nillable="false" type="xs:boolean" />
> > > >> >>>                                                      
> > > >> >>> <xs:element minOccurs="1"
> > > >> >>>
> > > >> >>> name="b"
> > > >> >>> nillable="false" type="xs:boolean" />
> > > >> >>>                                               </xs:sequence>
> > > >> >>>                                       </xs:extension>
> > > >> >>>                               </xs:complexContent>
> > > >> >>>                     </xs:complexType>
> > > >>
> > > >> --------------------------------------------------------------------
> > > >>---
> > > >>
> > > >> >>>-
> > > >>
> > > >> --------------------------------------------------------------------
> > > >>---
> > > >>
> > > >> >>>- -----
> > > >> >>>
> > > >> >>> XML Generated:
> > > >> >>>
> > > >> >>> <?xml version="1.0"?>
> > > >> >>> <env:Envelope
> > > >> >>> xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
> > > >> >>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > > >> >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > >> >>> xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
> > > >> >>> xmlns:ns0="http://mdc.com"> <env:Body>
> > > >> >>>   <ns0:createXxxRequest>
> > > >> >>>     <ns0:xxx xsi:type="ns0:Xxx">
> > > >> >>>       <ns0:name>xxx</ns0:name>
> > > >> >>>     </ns0:xxx>
> > > >> >>>   </ns0:createXxxRequest>
> > > >> >>> </env:Body>
> > > >> >>> </env:Envelope>
> > > >>
> > > >> --------------------------------------------------------------------
> > > >>---
> > > >>
> > > >> >>>-
> > > >>
> > > >> --------------------------------------------------------------------
> > > >>---
> > > >>
> > > >> >>>- -----
> > > >> >>>
> > > >> >>> Exception In Log:
> > > >> >>>
> > > >> >>> INFO: Interceptor has thrown exception, unwinding now
> > > >> >>> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
> > > >> >>> UndeclaredPrefix:
> > > >> >>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
> > > >> >>> declared.
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecode
> > > >> >>>r.ja v a:643)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecode
> > > >> >>>r.ja v a:555)
> > > >> >>>       at
> > > >> >>> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:6
> > > >> >>>4) at
> > > >> >>> org
> > > >> >>> .apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(Do
> > > >> >>>cLit e ralInInterceptor.java:183)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterce
> > > >> >>>ptor C hain.java:221)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIni
> > > >> >>>tiat i onObserver.java:78)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.cxf.transport.servlet.ServletDestination.invoke(ServletD
> > > >> >>>esti n ation.java:92)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.cxf.transport.servlet.ServletController.invokeDestinatio
> > > >> >>>n(Se r vletController.java:279)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.cxf.transport.servlet.ServletController.invoke(ServletCo
> > > >> >>>ntro l ler.java:161)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.cxf.transport.servlet.AbstractCXFServlet.invoke(Abstract
> > > >> >>>CXFS e rvlet.java:174)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.cxf.transport.servlet.AbstractCXFServlet.doPost(Abstract
> > > >> >>>CXFS e rvlet.java:152)
> > > >> >>>       at
> > > >> >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> > > >> >>> at
> > > >> >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
> > > >> >>> at
> > > >> >>> org
> > > >> >>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Ap
> > > >> >>>plic a tionFilterChain.java:252)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.catalina.core.ApplicationFilterChain.doFilter(Applicatio
> > > >> >>>nFil t erChain.java:173)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeader
> > > >> >>>Filt e r.java:96)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Ap
> > > >> >>>plic a tionFilterChain.java:202)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.catalina.core.ApplicationFilterChain.doFilter(Applicatio
> > > >> >>>nFil t erChain.java:173)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrappe
> > > >> >>>rVal v e.java:213)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.catalina.core.StandardContextValve.invoke(StandardContex
> > > >> >>>tVal v e.java:178)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .jboss.web.tomcat.security.SecurityAssociationValve.invoke(Secur
> > > >> >>>ityA s sociationValve.java:175)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextVa
> > > >> >>>lve. j ava:74)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve
> > > >> >>>.jav a
> > > >> >>>
> > > >> >>> :126)
> > > >> >>>
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve
> > > >> >>>.jav a
> > > >> >>>
> > > >> >>> :105)
> > > >> >>>
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedCon
> > > >> >>>nect i onValve.java:156)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.catalina.core.StandardEngineValve.invoke(StandardEngineV
> > > >> >>>alve . java:107)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.j
> > > >> >>>ava: 1 48)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.coyote.http11.Http11Processor.process(Http11Processor.ja
> > > >> >>>va:8 6 9)
> > > >> >>>       at
> > > >> >>> org.apache.coyote.http11.Http11BaseProtocol
> > > >> >>> $Http11ConnectionHandler.proc
> > > >> >>> essConnection(Http11BaseProtocol.java:664)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEnd
> > > >> >>>poin t .java:527)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveW
> > > >> >>>orke r Thread.java:112)
> > > >> >>>       at java.lang.Thread.run(Thread.java:619)
> > > >> >>> Caused by: javax.xml.bind.UnmarshalException
> > > >> >>> - with linked exception:
> > > >> >>> [org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot
> > > >> >>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
> > > >> >>> declared.] at
> > > >> >>> com
> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStr
> > > >> >>>eamE x ception(UnmarshallerImpl.java:396)
> > > >> >>>       at
> > > >> >>> com
> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal
> > > >> >>>0(Un m arshallerImpl.java:335)
> > > >> >>>       at
> > > >> >>> com
> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal
> > > >> >>>(Unm a rshallerImpl.java:312)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecode
> > > >> >>>r.ja v a:628)
> > > >> >>>       ... 31 more
> > > >> >>> Caused by: org.xml.sax.SAXParseException: UndeclaredPrefix:
> > > >> >>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
> > > >> >>> declared. at
> > > >> >>> org
> > > >> >>> .apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(
> > > >> >>>Unkn o wn Source)
> > > >> >>>       at
> > > >> >>> org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
> > > >> >>> Source) at
> > > >> >>> org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> > > >> >>> Source) at
> > > >> >>> org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> > > >> >>> Source) at
> > > >> >>> org.apache.xerces.impl.xs.XMLSchemaValidator
> > > >> >>> $XSIErrorReporter.reportErro
> > > >> >>> r(Unknown Source)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unkn
> > > >> >>>own Source)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unk
> > > >> >>>nown Source)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unk
> > > >> >>>nown Source)
> > > >> >>>       at
> > > >> >>> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknow
> > > >> >>>n Source)
> > > >> >>>       at
> > > >> >>> org
> > > >> >>> .apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement
> > > >> >>>(Unk n own Source)
> > > >> >>>       at
> > > >> >>> com
> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.sta
> > > >> >>>rtEl e ment(ValidatingUnmarshaller.java:73)
> > > >> >>>       at
> > > >> >>> com
> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handle
> > > >> >>>Star t Element(StAXStreamConnector.java:238)
> > > >> >>>       at
> > > >> >>> com
> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge
> > > >> >>>(StA X StreamConnector.java:172)
> > > >> >>>       at
> > > >> >>> com
> > > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal
> > > >> >>>0(Un m arshallerImpl.java:333)
> > > >> >>>       ... 33 more
> > > >> >>
> > > >> >> ---
> > > >> >> Daniel Kulp
> > > >> >> dkulp@apache.org
> > > >> >> http://www.dankulp.com/blog
> > > >> >
> > > >> > ---
> > > >> > Daniel Kulp
> > > >> > dkulp@apache.org
> > > >> > http://www.dankulp.com/blog
> > > >
> > > > --
> > > > Daniel Kulp
> > > > dkulp@apache.org
> > > > http://www.dankulp.com/blog
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared [Virus checked]

Posted by Marc Giger <gi...@gmx.ch>.
Hi Dan,

We encountered exactly the same problem last week (Cxf 2.1.5).
The culprit seems to be W3CDomStreamReader which doesn't
return the namespace for an Attribute which is declared as xs:QName
(2.6.1:
http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions).

AFAICS there are two possible solutions:

/**
     * Find name spaces declaration in atrributes and move them to
separate
     * collection.
     */
    @Override
    protected final void newFrame(ElementFrame<Node, Node> frame) {
        Node element = getCurrentNode();
        frame.uris = new ArrayList<String>();
        frame.prefixes = new ArrayList<String>();
        frame.attributes = new ArrayList<Object>();

        if (context == null) {
            context = new W3CNamespaceContext();
        }
        if (element instanceof Element) {
            context.setElement((Element)element);
        }

        NamedNodeMap nodes = element.getAttributes();

        String ePrefix = element.getPrefix();
        if (ePrefix == null) {
            ePrefix = "";
        }

        if (nodes != null) {
            for (int i = 0; i < nodes.getLength(); i++) {
                Node node = nodes.item(i);
                String prefix = node.getPrefix();
                String localName = node.getLocalName();
                String value = node.getNodeValue();
                String name = node.getNodeName();

                if (prefix == null) {
                    prefix = "";
                }

                if (name != null && "xmlns".equals(name)) {
                    frame.uris.add(value);
                    frame.prefixes.add("");
                } else if (prefix.length() > 0 &&
                "xmlns".equals(prefix)) { frame.uris.add(value);
                    frame.prefixes.add(localName);
                } else if (name.startsWith("xmlns:")) {
                    prefix = name.substring(6);
                    frame.uris.add(value);
                    frame.prefixes.add(prefix);
                } else {
                    frame.attributes.add(node);
                }
            }
        }
    }

In the loop, test the _value_ of an attribute for the existence of an
colon (":") and lookup the prefix (ugly) 

or:

public int getNamespaceCount() {
        return getCurrentFrame().prefixes.size();
    }

    public String getNamespacePrefix(int i) {
        return getCurrentFrame().prefixes.get(i);
    }

    public String getNamespaceURI(int i) {
        return getCurrentFrame().uris.get(i);
    }

change these methods to return the namespaces from the parent frames
too (needs some more thinking because of duplicate prefixes with
different urls, etc)...

What do you think?

Question: I didn't understand for what the ElementFrames are good for.
Can you explain me this?

Thanks & Greetings

Marc


On Mon, 13 Jul 2009 11:29:44 -0400
Daniel Kulp <dk...@apache.org> wrote:

> On Mon July 13 2009 10:16:13 am jp4 wrote:
> > Dan,
> >
> > I upgraded to CXF 2.2.2 and tried once again with Java 6.  I am
> > still seeing the same error.  The type is properly declared, and I
> > can validate the same XML with a servlet that uses the same XSDs.
> > Should I open a bug for this? Any other ideas?
> 
> Yes, please do open a bug, but we'll probably need a testcase that
> shows the error as I'm not sure how to reproduce it without a test
> case.
> 
> Thanks!
> Dan
> 
> >
> > Thanks,
> >
> > John
> >
> > dkulp wrote:
> > > On Thu July 9 2009 10:34:38 am jp4 wrote:
> > >> I am seeing a similar behavior where the xsi:type causes the
> > >> UndeclaredPrefix error.  Initially I was running CXF 2.2 with
> > >> JDK 1.5 on
> > >
> > > Well, definitely try with CXF 2.2.2.   That may help.
> > >
> > > If that doesn't help, use something like wireshark or similar to
> > > capture the
> > > raw message off the wire and see if ns3 is actually properly
> > > declared on the
> > > wire.   If not, that would probably be a bug.
> > >
> > > Dan
> > >
> > >> Jboss 4.2.3.GA.  I have since upgraded to Java 6.  I send a
> > >> sample request
> > >> through SOAPUI and I still see the same error below...  If I
> > >> attempt to validate the same file from within the container
> > >> using a servlet and the code below, it validates just fine.  Any
> > >> idea what could be causing the discrepancy?
> > >>
> > >>         Source source = new
> > >> StreamSource(getClass().getResourceAsStream("/request.xml"));
> > >>         // If you comment the following line, it works
> > >>         source = toDOMSource(source);
> > >>         validator.validate(source);
> > >>
> > >>
> > >> <07/09/09
> > >> 10:23:37:779|http-8443-2|INFO|apache.cxf.phase.PhaseInterceptorChain|Int
> > >>erc eptor has thrown exception, unwinding now|
> > >> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
> > >> UndeclaredPrefix: Cannot resolve 'ns3:FundingSourceType' as a
> > >> QName: the prefix 'ns3' is not
> > >> declared.
> > >> 	at
> > >> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
> > >>a:6 22) at
> > >> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
> > >>a:5 27) at
> > >> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:108)
> > >> at
> > >> org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLite
> > >>ral InInterceptor.java:183) at
> > >> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
> > >>hai n.java:236) at
> > >> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiati
> > >>onO bserver.java:89) at
> > >> org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestin
> > >>ati on.java:99) at
> > >> org.apache.cxf.transport.servlet.ServletController.invokeDestination(Ser
> > >>vle tController.java:337) at
> > >> org.apache.cxf.transport.servlet.ServletController.invoke(ServletControl
> > >>ler .java:182) at
> > >> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFSe
> > >>rvl et.java:163) at
> > >> org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFSe
> > >>rvl et.java:141) at
> >
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
> >
> > >> 	at
> > >> javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at
> > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> > >>tio nFilterChain.java:290) at
> > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> > >>erC hain.java:206) at
> > >> com.billmelater.enterpriseservices.servlet.util.RequestTimerServletFilte
> > >>r.d oFilter(RequestTimerServletFilter.java:55) at
> > >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> > >>tio nFilterChain.java:235) at
> > >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> > >>erC hain.java:206) at
> > >> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.do
> > >>Fil ter(FilterChainProxy.java:378) at
> > >> org.springframework.security.intercept.web.FilterSecurityInterceptor.inv
> > >>oke (FilterSecurityInterceptor.java:109)
> > >>
> > >> dkulp wrote:
> > >> > Did some snooping...   The RI seems to have the same problem:
> > >> > http://forums.java.net/jive//message.jspa?messageID=268876
> > >> >
> > >> > And they mention its a bug in the JDK:
> > >> > https://jaxp.dev.java.net/issues/show_bug.cgi?id=46
> > >> >
> > >> > The workaround seems to be to use the latest 1.6 JDK or get
> > >> > the latest sun jaxp parser
> > >> > (http://download.java.net/maven/1/com.sun.xml.parsers/jars/
> > >> > )  and throw it in your endorsed dir.
> > >> >
> > >> > Dan
> > >> >
> > >> > On Jun 18, 2008, at 2:16 PM,
> > >> > jan.minaroviech@external.t-mobile.at
> > >>
> > >> wrote:
> > >> >> Hi,
> > >> >>
> > >> >> looks like the same problem i have. But my response is
> > >> >> invalid also according to soapUI validation.
> > >> >>
> > >> >> I'm not using any additional interceptors, only default
> > >> >> cxfServlet, default bus config etc, without security,
> > >> >> attachments etc. and I'm using
> > >> >> jaxWS+jaxB
> > >> >>
> > >> >> This is response, which is problem in my case (cxf is client
> > >> >> in this case)
> > >> >>
> > >> >> <soapenv:Envelope
> > >> >> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> > >> >> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > >> >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> > >> >>   <soapenv:Body>
> > >> >>      <locationSearchReply
> > >> >> xmlns="http://www.deltavista.at/schema/locationsearch">
> > >> >>         <foundLocation>
> > >> >>            <street>Stephansplatz</street>
> > >> >>            <houseNumber>1</houseNumber>
> > >> >>            <city>Wien</city>
> > >> >>            <zip xsi:type="xsd:string">1010</zip>
> > >> >>            <country xsi:type="xsd:string">AUT</country>
> > >> >>            <locationMatch>4</locationMatch>
> > >> >>            <similarity>92</similarity>
> > >> >>            <confidence>98</confidence>
> > >> >>         </foundLocation>
> > >> >>      </locationSearchReply>
> > >> >>   </soapenv:Body>
> > >> >> </soapenv:Envelope>
> > >> >>
> > >> >> i have a problem with xsd:string inside reply.
> > >> >>
> > >> >> pieces of xsd:
> > >> >>                                        <element name="zip"
> > >> >> type="locationsearch:Zip" minOccurs="1"/>
> > >> >>                        <simpleType name="Zip">
> > >> >>                                <restriction base="string">
> > >> >>                                        <minLength value="4"/>
> > >> >>                                        <maxLength value="7"/>
> > >> >>                                </restriction>
> > >> >>                        </simpleType>
> > >> >>
> > >> >> when i turn off validation, everything works
> > >> >>
> > >> >> best regards
> > >> >> jano
> > >> >>
> > >> >>
> > >> >>
> > >> >>
> > >> >> Daniel Kulp <dk...@apache.org>
> > >> >> 06/18/2008 20:05
> > >> >> Bitte antworten an
> > >> >> users@cxf.apache.org
> > >> >>
> > >> >>
> > >> >> An
> > >> >> users@cxf.apache.org
> > >> >> Kopie
> > >> >>
> > >> >> Thema
> > >> >> Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve
> > >> >> 'ns0:Xxx' as a
> > >> >> QName: the prefix 'ns0' is not declared  [Virus checked]
> > >> >>
> > >> >>
> > >> >>
> > >> >>
> > >> >>
> > >> >>
> > >> >>
> > >> >> Very strange.   The message is definitely valid.
> > >> >>
> > >> >> Could questions:
> > >> >> 1) Do you have any SAAJ type handlers/interceptors on the
> > >> >> chain (jaxws SOAPHandler, ws-security things, etc...)?
> > >> >>
> > >> >> 2) I noticed you have a xerces jar...  can you try removing
> > >> >> that and seeing if the JDK built-in parser will work?  Also,
> > >> >> check if you have a xalan jar installed and remove that as
> > >> >> well.
> > >> >>
> > >> >> 3) Can you turn off validation.   It looks like it's the
> > >> >> validator having an issue, not the unmarshaller.   If it
> > >> >> unmarshalls OK that way, we at least know the parser is
> > >> >> giving it the correct data.   If that still fails, we'll need
> > >> >> to dig in more.
> > >> >>
> > >> >> Dan
> > >> >>
> > >> >> On Jun 17, 2008, at 12:33 PM, Urciolo, Kevin wrote:
> > >> >>> I am running in to an issue when a Java 5 client using JWSDP
> > >> >>> is sending
> > >> >>> a request to my CXF (2.1.1 SNAPSHOT) service.  I get an
> > >> >>> exception, Unmarshalling Error: UndeclaredPrefix: Cannot
> > >> >>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
> > >> >>> declared, as shown below.  The type is an
> > >> >>> extension from a base type.  I am assuming this is why
> > >> >>> "xsi:type" is generated by the client since it is not used
> > >> >>> in other places.
> > >> >>>
> > >> >>> Is there a reason why CXF is having trouble with this?
> > >> >>>
> > >> >>> Type From Schema:
> > >> >>>
> > >> >>>                      <xs:complexType name="Xxx">
> > >> >>>                               <xs:complexContent>
> > >> >>>                                       <xs:extension
> > >> >>> base="tns:Base"> <xs:sequence>
> > >> >>>                                                       <xs:element
> > >> >>> minOccurs="1"
> > >> >>>
> > >> >>> name="a"
> > >> >>> nillable="false" type="xs:boolean" />
> > >> >>>                                                       <xs:element
> > >> >>> minOccurs="1"
> > >> >>>
> > >> >>> name="b"
> > >> >>> nillable="false" type="xs:boolean" />
> > >> >>>                                               </xs:sequence>
> > >> >>>                                       </xs:extension>
> > >> >>>                               </xs:complexContent>
> > >> >>>                     </xs:complexType>
> > >>
> > >> -----------------------------------------------------------------------
> > >>
> > >> >>>-
> > >>
> > >> -----------------------------------------------------------------------
> > >>
> > >> >>>- -----
> > >> >>>
> > >> >>> XML Generated:
> > >> >>>
> > >> >>> <?xml version="1.0"?>
> > >> >>> <env:Envelope
> > >> >>> xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
> > >> >>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > >> >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > >> >>> xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
> > >> >>> xmlns:ns0="http://mdc.com"> <env:Body>
> > >> >>>   <ns0:createXxxRequest>
> > >> >>>     <ns0:xxx xsi:type="ns0:Xxx">
> > >> >>>       <ns0:name>xxx</ns0:name>
> > >> >>>     </ns0:xxx>
> > >> >>>   </ns0:createXxxRequest>
> > >> >>> </env:Body>
> > >> >>> </env:Envelope>
> > >>
> > >> -----------------------------------------------------------------------
> > >>
> > >> >>>-
> > >>
> > >> -----------------------------------------------------------------------
> > >>
> > >> >>>- -----
> > >> >>>
> > >> >>> Exception In Log:
> > >> >>>
> > >> >>> INFO: Interceptor has thrown exception, unwinding now
> > >> >>> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
> > >> >>> UndeclaredPrefix:
> > >> >>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
> > >> >>> declared.
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.ja
> > >> >>>v a:643)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.ja
> > >> >>>v a:555)
> > >> >>>       at
> > >> >>> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:64)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLit
> > >> >>>e ralInInterceptor.java:183)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptor
> > >> >>>C hain.java:221)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiat
> > >> >>>i onObserver.java:78)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.cxf.transport.servlet.ServletDestination.invoke(ServletDesti
> > >> >>>n ation.java:92)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.cxf.transport.servlet.ServletController.invokeDestination(Se
> > >> >>>r vletController.java:279)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.cxf.transport.servlet.ServletController.invoke(ServletContro
> > >> >>>l ler.java:161)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFS
> > >> >>>e rvlet.java:174)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFS
> > >> >>>e rvlet.java:152)
> > >> >>>       at
> > >> >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> > >> >>> at
> > >> >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
> > >> >>> at
> > >> >>> org .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic
> > >> >>>a tionFilterChain.java:252)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil
> > >> >>>t erChain.java:173)
> > >> >>>       at
> > >> >>> org
> > >> >>> .jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilt
> > >> >>>e r.java:96)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic
> > >> >>>a tionFilterChain.java:202)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil
> > >> >>>t erChain.java:173)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal
> > >> >>>v e.java:213)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.catalina.core.StandardContextValve.invoke(StandardContextVal
> > >> >>>v e.java:178)
> > >> >>>       at
> > >> >>> org
> > >> >>> .jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityA
> > >> >>>s sociationValve.java:175)
> > >> >>>       at
> > >> >>> org
> > >> >>> .jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.
> > >> >>>j ava:74)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav
> > >> >>>a
> > >> >>>
> > >> >>> :126)
> > >> >>>
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav
> > >> >>>a
> > >> >>>
> > >> >>> :105)
> > >> >>>
> > >> >>>       at
> > >> >>> org
> > >> >>> .jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnect
> > >> >>>i onValve.java:156)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve
> > >> >>>. java:107)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
> > >> >>>1 48)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.coyote.http11.Http11Processor.process(Http11Processor.java:8
> > >> >>>6 9)
> > >> >>>       at
> > >> >>> org.apache.coyote.http11.Http11BaseProtocol
> > >> >>> $Http11ConnectionHandler.proc
> > >> >>> essConnection(Http11BaseProtocol.java:664)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoin
> > >> >>>t .java:527)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorke
> > >> >>>r Thread.java:112)
> > >> >>>       at java.lang.Thread.run(Thread.java:619)
> > >> >>> Caused by: javax.xml.bind.UnmarshalException
> > >> >>> - with linked exception:
> > >> >>> [org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot
> > >> >>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
> > >> >>> declared.] at
> > >> >>> com
> > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamE
> > >> >>>x ception(UnmarshallerImpl.java:396)
> > >> >>>       at
> > >> >>> com
> > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Un
> > >> >>>m arshallerImpl.java:335)
> > >> >>>       at
> > >> >>> com
> > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unm
> > >> >>>a rshallerImpl.java:312)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.ja
> > >> >>>v a:628)
> > >> >>>       ... 31 more
> > >> >>> Caused by: org.xml.sax.SAXParseException: UndeclaredPrefix:
> > >> >>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
> > >> >>> declared. at
> > >> >>> org
> > >> >>> .apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unkn
> > >> >>>o wn Source)
> > >> >>>       at
> > >> >>> org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
> > >> >>> Source) at
> > >> >>> org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> > >> >>> Source) at
> > >> >>> org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> > >> >>> Source) at
> > >> >>> org.apache.xerces.impl.xs.XMLSchemaValidator
> > >> >>> $XSIErrorReporter.reportErro
> > >> >>> r(Unknown Source)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown
> > >> >>> Source)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unknown
> > >> >>> Source)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
> > >> >>> Source)
> > >> >>>       at
> > >> >>> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
> > >> >>> Source)
> > >> >>>       at
> > >> >>> org
> > >> >>> .apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unk
> > >> >>>n own Source)
> > >> >>>       at
> > >> >>> com
> > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startEl
> > >> >>>e ment(ValidatingUnmarshaller.java:73)
> > >> >>>       at
> > >> >>> com
> > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStar
> > >> >>>t Element(StAXStreamConnector.java:238)
> > >> >>>       at
> > >> >>> com
> > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StA
> > >> >>>X StreamConnector.java:172)
> > >> >>>       at
> > >> >>> com
> > >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Un
> > >> >>>m arshallerImpl.java:333)
> > >> >>>       ... 33 more
> > >> >>
> > >> >> ---
> > >> >> Daniel Kulp
> > >> >> dkulp@apache.org
> > >> >> http://www.dankulp.com/blog
> > >> >
> > >> > ---
> > >> > Daniel Kulp
> > >> > dkulp@apache.org
> > >> > http://www.dankulp.com/blog
> > >
> > > --
> > > Daniel Kulp
> > > dkulp@apache.org
> > > http://www.dankulp.com/blog
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog


-- 
Lesson 1: Cryptographic protocols should not be developed by a
committee. -- Niels Ferguson and Bruce Schneier --

Re: Antwort: Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared [Virus checked]

Posted by jp4 <jo...@hnpsolutions.com>.
Dan,

I opened https://issues.apache.org/jira/browse/CXF-2340 and attached a test
case.  Thanks again for your help with this matter!

Thanks,

John

dkulp wrote:
> 
> On Mon July 13 2009 10:16:13 am jp4 wrote:
>> Dan,
>>
>> I upgraded to CXF 2.2.2 and tried once again with Java 6.  I am still
>> seeing the same error.  The type is properly declared, and I can validate
>> the same XML with a servlet that uses the same XSDs.  Should I open a bug
>> for this? Any other ideas?
> 
> Yes, please do open a bug, but we'll probably need a testcase that shows
> the 
> error as I'm not sure how to reproduce it without a test case.
> 
> Thanks!
> Dan
> 
>>
>> Thanks,
>>
>> John
>>
>> dkulp wrote:
>> > On Thu July 9 2009 10:34:38 am jp4 wrote:
>> >> I am seeing a similar behavior where the xsi:type causes the
>> >> UndeclaredPrefix error.  Initially I was running CXF 2.2 with JDK 1.5
>> on
>> >
>> > Well, definitely try with CXF 2.2.2.   That may help.
>> >
>> > If that doesn't help, use something like wireshark or similar to
>> capture
>> > the
>> > raw message off the wire and see if ns3 is actually properly declared
>> on
>> > the
>> > wire.   If not, that would probably be a bug.
>> >
>> > Dan
>> >
>> >> Jboss 4.2.3.GA.  I have since upgraded to Java 6.  I send a sample
>> >> request
>> >> through SOAPUI and I still see the same error below...  If I attempt
>> to
>> >> validate the same file from within the container using a servlet and
>> the
>> >> code below, it validates just fine.  Any idea what could be causing
>> the
>> >> discrepancy?
>> >>
>> >>         Source source = new
>> >> StreamSource(getClass().getResourceAsStream("/request.xml"));
>> >>         // If you comment the following line, it works
>> >>         source = toDOMSource(source);
>> >>         validator.validate(source);
>> >>
>> >>
>> >> <07/09/09
>> >>
>> 10:23:37:779|http-8443-2|INFO|apache.cxf.phase.PhaseInterceptorChain|Int
>> >>erc eptor has thrown exception, unwinding now|
>> >> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
>> UndeclaredPrefix:
>> >> Cannot resolve 'ns3:FundingSourceType' as a QName: the prefix 'ns3' is
>> >> not
>> >> declared.
>> >> 	at
>> >>
>> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>> >>a:6 22) at
>> >>
>> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>> >>a:5 27) at
>> >> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:108) at
>> >>
>> org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLite
>> >>ral InInterceptor.java:183) at
>> >>
>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
>> >>hai n.java:236) at
>> >>
>> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiati
>> >>onO bserver.java:89) at
>> >>
>> org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestin
>> >>ati on.java:99) at
>> >>
>> org.apache.cxf.transport.servlet.ServletController.invokeDestination(Ser
>> >>vle tController.java:337) at
>> >>
>> org.apache.cxf.transport.servlet.ServletController.invoke(ServletControl
>> >>ler .java:182) at
>> >>
>> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFSe
>> >>rvl et.java:163) at
>> >>
>> org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFSe
>> >>rvl et.java:141) at
>>
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>>
>> >> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>> >> 	at
>> >>
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
>> >>tio nFilterChain.java:290) at
>> >>
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
>> >>erC hain.java:206) at
>> >>
>> com.billmelater.enterpriseservices.servlet.util.RequestTimerServletFilte
>> >>r.d oFilter(RequestTimerServletFilter.java:55) at
>> >>
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
>> >>tio nFilterChain.java:235) at
>> >>
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
>> >>erC hain.java:206) at
>> >>
>> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.do
>> >>Fil ter(FilterChainProxy.java:378) at
>> >>
>> org.springframework.security.intercept.web.FilterSecurityInterceptor.inv
>> >>oke (FilterSecurityInterceptor.java:109)
>> >>
>> >> dkulp wrote:
>> >> > Did some snooping...   The RI seems to have the same problem:
>> >> > http://forums.java.net/jive//message.jspa?messageID=268876
>> >> >
>> >> > And they mention its a bug in the JDK:
>> >> > https://jaxp.dev.java.net/issues/show_bug.cgi?id=46
>> >> >
>> >> > The workaround seems to be to use the latest 1.6 JDK or get the
>> latest
>> >> > sun jaxp parser
>> >> > (http://download.java.net/maven/1/com.sun.xml.parsers/jars/
>> >> > )  and throw it in your endorsed dir.
>> >> >
>> >> > Dan
>> >> >
>> >> > On Jun 18, 2008, at 2:16 PM, jan.minaroviech@external.t-mobile.at
>> >>
>> >> wrote:
>> >> >> Hi,
>> >> >>
>> >> >> looks like the same problem i have. But my response is invalid also
>> >> >> according to soapUI validation.
>> >> >>
>> >> >> I'm not using any additional interceptors, only default cxfServlet,
>> >> >> default bus config etc, without security, attachments etc. and I'm
>> >> >> using
>> >> >> jaxWS+jaxB
>> >> >>
>> >> >> This is response, which is problem in my case (cxf is client in
>> this
>> >> >> case)
>> >> >>
>> >> >> <soapenv:Envelope
>> >> >> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>> >> >> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> >> >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>> >> >>   <soapenv:Body>
>> >> >>      <locationSearchReply
>> >> >> xmlns="http://www.deltavista.at/schema/locationsearch">
>> >> >>         <foundLocation>
>> >> >>            <street>Stephansplatz</street>
>> >> >>            <houseNumber>1</houseNumber>
>> >> >>            <city>Wien</city>
>> >> >>            <zip xsi:type="xsd:string">1010</zip>
>> >> >>            <country xsi:type="xsd:string">AUT</country>
>> >> >>            <locationMatch>4</locationMatch>
>> >> >>            <similarity>92</similarity>
>> >> >>            <confidence>98</confidence>
>> >> >>         </foundLocation>
>> >> >>      </locationSearchReply>
>> >> >>   </soapenv:Body>
>> >> >> </soapenv:Envelope>
>> >> >>
>> >> >> i have a problem with xsd:string inside reply.
>> >> >>
>> >> >> pieces of xsd:
>> >> >>                                        <element name="zip"
>> >> >> type="locationsearch:Zip" minOccurs="1"/>
>> >> >>                        <simpleType name="Zip">
>> >> >>                                <restriction base="string">
>> >> >>                                        <minLength value="4"/>
>> >> >>                                        <maxLength value="7"/>
>> >> >>                                </restriction>
>> >> >>                        </simpleType>
>> >> >>
>> >> >> when i turn off validation, everything works
>> >> >>
>> >> >> best regards
>> >> >> jano
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> Daniel Kulp <dk...@apache.org>
>> >> >> 06/18/2008 20:05
>> >> >> Bitte antworten an
>> >> >> users@cxf.apache.org
>> >> >>
>> >> >>
>> >> >> An
>> >> >> users@cxf.apache.org
>> >> >> Kopie
>> >> >>
>> >> >> Thema
>> >> >> Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx'
>> >> >> as a
>> >> >> QName: the prefix 'ns0' is not declared  [Virus checked]
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> Very strange.   The message is definitely valid.
>> >> >>
>> >> >> Could questions:
>> >> >> 1) Do you have any SAAJ type handlers/interceptors on the chain
>> >> >> (jaxws SOAPHandler, ws-security things, etc...)?
>> >> >>
>> >> >> 2) I noticed you have a xerces jar...  can you try removing that
>> and
>> >> >> seeing if the JDK built-in parser will work?  Also, check if you
>> have
>> >> >> a xalan jar installed and remove that as well.
>> >> >>
>> >> >> 3) Can you turn off validation.   It looks like it's the validator
>> >> >> having an issue, not the unmarshaller.   If it unmarshalls OK that
>> >> >> way, we at least know the parser is giving it the correct data.  
>> If
>> >> >> that still fails, we'll need to dig in more.
>> >> >>
>> >> >> Dan
>> >> >>
>> >> >> On Jun 17, 2008, at 12:33 PM, Urciolo, Kevin wrote:
>> >> >>> I am running in to an issue when a Java 5 client using JWSDP is
>> >> >>> sending
>> >> >>> a request to my CXF (2.1.1 SNAPSHOT) service.  I get an exception,
>> >> >>> Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as
>> a
>> >> >>> QName: the prefix 'ns0' is not declared, as shown below.  The type
>> >> >>> is an
>> >> >>> extension from a base type.  I am assuming this is why "xsi:type"
>> is
>> >> >>> generated by the client since it is not used in other places.
>> >> >>>
>> >> >>> Is there a reason why CXF is having trouble with this?
>> >> >>>
>> >> >>> Type From Schema:
>> >> >>>
>> >> >>>                      <xs:complexType name="Xxx">
>> >> >>>                               <xs:complexContent>
>> >> >>>                                       <xs:extension
>> base="tns:Base">
>> >> >>>                                               <xs:sequence>
>> >> >>>                                                       <xs:element
>> >> >>> minOccurs="1"
>> >> >>>
>> >> >>> name="a"
>> >> >>> nillable="false" type="xs:boolean" />
>> >> >>>                                                       <xs:element
>> >> >>> minOccurs="1"
>> >> >>>
>> >> >>> name="b"
>> >> >>> nillable="false" type="xs:boolean" />
>> >> >>>                                               </xs:sequence>
>> >> >>>                                       </xs:extension>
>> >> >>>                               </xs:complexContent>
>> >> >>>                     </xs:complexType>
>> >>
>> >>
>> -----------------------------------------------------------------------
>> >>
>> >> >>>-
>> >>
>> >>
>> -----------------------------------------------------------------------
>> >>
>> >> >>>- -----
>> >> >>>
>> >> >>> XML Generated:
>> >> >>>
>> >> >>> <?xml version="1.0"?>
>> >> >>> <env:Envelope
>> xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
>> >> >>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> >> >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> >> >>> xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
>> >> >>> xmlns:ns0="http://mdc.com">
>> >> >>> <env:Body>
>> >> >>>   <ns0:createXxxRequest>
>> >> >>>     <ns0:xxx xsi:type="ns0:Xxx">
>> >> >>>       <ns0:name>xxx</ns0:name>
>> >> >>>     </ns0:xxx>
>> >> >>>   </ns0:createXxxRequest>
>> >> >>> </env:Body>
>> >> >>> </env:Envelope>
>> >>
>> >>
>> -----------------------------------------------------------------------
>> >>
>> >> >>>-
>> >>
>> >>
>> -----------------------------------------------------------------------
>> >>
>> >> >>>- -----
>> >> >>>
>> >> >>> Exception In Log:
>> >> >>>
>> >> >>> INFO: Interceptor has thrown exception, unwinding now
>> >> >>> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
>> >> >>> UndeclaredPrefix:
>> >> >>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
>> >> >>> declared.
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.ja
>> >> >>>v a:643)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.ja
>> >> >>>v a:555)
>> >> >>>       at
>> >> >>> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:64)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLit
>> >> >>>e ralInInterceptor.java:183)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptor
>> >> >>>C hain.java:221)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiat
>> >> >>>i onObserver.java:78)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.cxf.transport.servlet.ServletDestination.invoke(ServletDesti
>> >> >>>n ation.java:92)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.cxf.transport.servlet.ServletController.invokeDestination(Se
>> >> >>>r vletController.java:279)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.cxf.transport.servlet.ServletController.invoke(ServletContro
>> >> >>>l ler.java:161)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFS
>> >> >>>e rvlet.java:174)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFS
>> >> >>>e rvlet.java:152)
>> >> >>>       at
>> >> >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at
>> >> >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at
>> >> >>> org
>> >> >>>
>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic
>> >> >>>a tionFilterChain.java:252)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil
>> >> >>>t erChain.java:173)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilt
>> >> >>>e r.java:96)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic
>> >> >>>a tionFilterChain.java:202)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil
>> >> >>>t erChain.java:173)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal
>> >> >>>v e.java:213)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.catalina.core.StandardContextValve.invoke(StandardContextVal
>> >> >>>v e.java:178)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityA
>> >> >>>s sociationValve.java:175)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.
>> >> >>>j ava:74)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav
>> >> >>>a
>> >> >>>
>> >> >>> :126)
>> >> >>>
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav
>> >> >>>a
>> >> >>>
>> >> >>> :105)
>> >> >>>
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnect
>> >> >>>i onValve.java:156)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve
>> >> >>>. java:107)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
>> >> >>>1 48)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.coyote.http11.Http11Processor.process(Http11Processor.java:8
>> >> >>>6 9)
>> >> >>>       at
>> >> >>> org.apache.coyote.http11.Http11BaseProtocol
>> >> >>> $Http11ConnectionHandler.proc
>> >> >>> essConnection(Http11BaseProtocol.java:664)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoin
>> >> >>>t .java:527)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorke
>> >> >>>r Thread.java:112)
>> >> >>>       at java.lang.Thread.run(Thread.java:619)
>> >> >>> Caused by: javax.xml.bind.UnmarshalException
>> >> >>> - with linked exception:
>> >> >>> [org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot resolve
>> >> >>> 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.]
>> >> >>>       at
>> >> >>> com
>> >> >>>
>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamE
>> >> >>>x ception(UnmarshallerImpl.java:396)
>> >> >>>       at
>> >> >>> com
>> >> >>>
>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Un
>> >> >>>m arshallerImpl.java:335)
>> >> >>>       at
>> >> >>> com
>> >> >>>
>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unm
>> >> >>>a rshallerImpl.java:312)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.ja
>> >> >>>v a:628)
>> >> >>>       ... 31 more
>> >> >>> Caused by: org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot
>> >> >>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unkn
>> >> >>>o wn Source)
>> >> >>>       at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
>> >> >>> Source)
>> >> >>>       at
>> org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>> >> >>> Source)
>> >> >>>       at
>> org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>> >> >>> Source)
>> >> >>>       at
>> >> >>> org.apache.xerces.impl.xs.XMLSchemaValidator
>> >> >>> $XSIErrorReporter.reportErro
>> >> >>> r(Unknown Source)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown
>> >> >>> Source)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unknown
>> >> >>> Source)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
>> >> >>> Source)
>> >> >>>       at
>> >> >>> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
>> >> >>> Source)
>> >> >>>       at
>> >> >>> org
>> >> >>>
>> .apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unk
>> >> >>>n own Source)
>> >> >>>       at
>> >> >>> com
>> >> >>>
>> .sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startEl
>> >> >>>e ment(ValidatingUnmarshaller.java:73)
>> >> >>>       at
>> >> >>> com
>> >> >>>
>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStar
>> >> >>>t Element(StAXStreamConnector.java:238)
>> >> >>>       at
>> >> >>> com
>> >> >>>
>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StA
>> >> >>>X StreamConnector.java:172)
>> >> >>>       at
>> >> >>> com
>> >> >>>
>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Un
>> >> >>>m arshallerImpl.java:333)
>> >> >>>       ... 33 more
>> >> >>
>> >> >> ---
>> >> >> Daniel Kulp
>> >> >> dkulp@apache.org
>> >> >> http://www.dankulp.com/blog
>> >> >
>> >> > ---
>> >> > Daniel Kulp
>> >> > dkulp@apache.org
>> >> > http://www.dankulp.com/blog
>> >
>> > --
>> > Daniel Kulp
>> > dkulp@apache.org
>> > http://www.dankulp.com/blog
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/Unmarshalling-Error%3A-UndeclaredPrefix%3A-Cannot-resolve-%27ns0%3AXxx%27-as-a-QName%3A-the-prefix-%27ns0%27-is-not-declared-tp17918441p24486562.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Antwort: Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared [Virus checked]

Posted by Daniel Kulp <dk...@apache.org>.
On Mon July 13 2009 10:16:13 am jp4 wrote:
> Dan,
>
> I upgraded to CXF 2.2.2 and tried once again with Java 6.  I am still
> seeing the same error.  The type is properly declared, and I can validate
> the same XML with a servlet that uses the same XSDs.  Should I open a bug
> for this? Any other ideas?

Yes, please do open a bug, but we'll probably need a testcase that shows the 
error as I'm not sure how to reproduce it without a test case.

Thanks!
Dan

>
> Thanks,
>
> John
>
> dkulp wrote:
> > On Thu July 9 2009 10:34:38 am jp4 wrote:
> >> I am seeing a similar behavior where the xsi:type causes the
> >> UndeclaredPrefix error.  Initially I was running CXF 2.2 with JDK 1.5 on
> >
> > Well, definitely try with CXF 2.2.2.   That may help.
> >
> > If that doesn't help, use something like wireshark or similar to capture
> > the
> > raw message off the wire and see if ns3 is actually properly declared on
> > the
> > wire.   If not, that would probably be a bug.
> >
> > Dan
> >
> >> Jboss 4.2.3.GA.  I have since upgraded to Java 6.  I send a sample
> >> request
> >> through SOAPUI and I still see the same error below...  If I attempt to
> >> validate the same file from within the container using a servlet and the
> >> code below, it validates just fine.  Any idea what could be causing the
> >> discrepancy?
> >>
> >>         Source source = new
> >> StreamSource(getClass().getResourceAsStream("/request.xml"));
> >>         // If you comment the following line, it works
> >>         source = toDOMSource(source);
> >>         validator.validate(source);
> >>
> >>
> >> <07/09/09
> >> 10:23:37:779|http-8443-2|INFO|apache.cxf.phase.PhaseInterceptorChain|Int
> >>erc eptor has thrown exception, unwinding now|
> >> org.apache.cxf.interceptor.Fault: Unmarshalling Error: UndeclaredPrefix:
> >> Cannot resolve 'ns3:FundingSourceType' as a QName: the prefix 'ns3' is
> >> not
> >> declared.
> >> 	at
> >> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
> >>a:6 22) at
> >> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
> >>a:5 27) at
> >> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:108) at
> >> org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLite
> >>ral InInterceptor.java:183) at
> >> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
> >>hai n.java:236) at
> >> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiati
> >>onO bserver.java:89) at
> >> org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestin
> >>ati on.java:99) at
> >> org.apache.cxf.transport.servlet.ServletController.invokeDestination(Ser
> >>vle tController.java:337) at
> >> org.apache.cxf.transport.servlet.ServletController.invoke(ServletControl
> >>ler .java:182) at
> >> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFSe
> >>rvl et.java:163) at
> >> org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFSe
> >>rvl et.java:141) at
>
> javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>
> >> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >> 	at
> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> >>tio nFilterChain.java:290) at
> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> >>erC hain.java:206) at
> >> com.billmelater.enterpriseservices.servlet.util.RequestTimerServletFilte
> >>r.d oFilter(RequestTimerServletFilter.java:55) at
> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> >>tio nFilterChain.java:235) at
> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> >>erC hain.java:206) at
> >> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.do
> >>Fil ter(FilterChainProxy.java:378) at
> >> org.springframework.security.intercept.web.FilterSecurityInterceptor.inv
> >>oke (FilterSecurityInterceptor.java:109)
> >>
> >> dkulp wrote:
> >> > Did some snooping...   The RI seems to have the same problem:
> >> > http://forums.java.net/jive//message.jspa?messageID=268876
> >> >
> >> > And they mention its a bug in the JDK:
> >> > https://jaxp.dev.java.net/issues/show_bug.cgi?id=46
> >> >
> >> > The workaround seems to be to use the latest 1.6 JDK or get the latest
> >> > sun jaxp parser
> >> > (http://download.java.net/maven/1/com.sun.xml.parsers/jars/
> >> > )  and throw it in your endorsed dir.
> >> >
> >> > Dan
> >> >
> >> > On Jun 18, 2008, at 2:16 PM, jan.minaroviech@external.t-mobile.at
> >>
> >> wrote:
> >> >> Hi,
> >> >>
> >> >> looks like the same problem i have. But my response is invalid also
> >> >> according to soapUI validation.
> >> >>
> >> >> I'm not using any additional interceptors, only default cxfServlet,
> >> >> default bus config etc, without security, attachments etc. and I'm
> >> >> using
> >> >> jaxWS+jaxB
> >> >>
> >> >> This is response, which is problem in my case (cxf is client in this
> >> >> case)
> >> >>
> >> >> <soapenv:Envelope
> >> >> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> >> >> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> >> >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> >> >>   <soapenv:Body>
> >> >>      <locationSearchReply
> >> >> xmlns="http://www.deltavista.at/schema/locationsearch">
> >> >>         <foundLocation>
> >> >>            <street>Stephansplatz</street>
> >> >>            <houseNumber>1</houseNumber>
> >> >>            <city>Wien</city>
> >> >>            <zip xsi:type="xsd:string">1010</zip>
> >> >>            <country xsi:type="xsd:string">AUT</country>
> >> >>            <locationMatch>4</locationMatch>
> >> >>            <similarity>92</similarity>
> >> >>            <confidence>98</confidence>
> >> >>         </foundLocation>
> >> >>      </locationSearchReply>
> >> >>   </soapenv:Body>
> >> >> </soapenv:Envelope>
> >> >>
> >> >> i have a problem with xsd:string inside reply.
> >> >>
> >> >> pieces of xsd:
> >> >>                                        <element name="zip"
> >> >> type="locationsearch:Zip" minOccurs="1"/>
> >> >>                        <simpleType name="Zip">
> >> >>                                <restriction base="string">
> >> >>                                        <minLength value="4"/>
> >> >>                                        <maxLength value="7"/>
> >> >>                                </restriction>
> >> >>                        </simpleType>
> >> >>
> >> >> when i turn off validation, everything works
> >> >>
> >> >> best regards
> >> >> jano
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> Daniel Kulp <dk...@apache.org>
> >> >> 06/18/2008 20:05
> >> >> Bitte antworten an
> >> >> users@cxf.apache.org
> >> >>
> >> >>
> >> >> An
> >> >> users@cxf.apache.org
> >> >> Kopie
> >> >>
> >> >> Thema
> >> >> Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx'
> >> >> as a
> >> >> QName: the prefix 'ns0' is not declared  [Virus checked]
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> Very strange.   The message is definitely valid.
> >> >>
> >> >> Could questions:
> >> >> 1) Do you have any SAAJ type handlers/interceptors on the chain
> >> >> (jaxws SOAPHandler, ws-security things, etc...)?
> >> >>
> >> >> 2) I noticed you have a xerces jar...  can you try removing that and
> >> >> seeing if the JDK built-in parser will work?  Also, check if you have
> >> >> a xalan jar installed and remove that as well.
> >> >>
> >> >> 3) Can you turn off validation.   It looks like it's the validator
> >> >> having an issue, not the unmarshaller.   If it unmarshalls OK that
> >> >> way, we at least know the parser is giving it the correct data.   If
> >> >> that still fails, we'll need to dig in more.
> >> >>
> >> >> Dan
> >> >>
> >> >> On Jun 17, 2008, at 12:33 PM, Urciolo, Kevin wrote:
> >> >>> I am running in to an issue when a Java 5 client using JWSDP is
> >> >>> sending
> >> >>> a request to my CXF (2.1.1 SNAPSHOT) service.  I get an exception,
> >> >>> Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a
> >> >>> QName: the prefix 'ns0' is not declared, as shown below.  The type
> >> >>> is an
> >> >>> extension from a base type.  I am assuming this is why "xsi:type" is
> >> >>> generated by the client since it is not used in other places.
> >> >>>
> >> >>> Is there a reason why CXF is having trouble with this?
> >> >>>
> >> >>> Type From Schema:
> >> >>>
> >> >>>                      <xs:complexType name="Xxx">
> >> >>>                               <xs:complexContent>
> >> >>>                                       <xs:extension base="tns:Base">
> >> >>>                                               <xs:sequence>
> >> >>>                                                       <xs:element
> >> >>> minOccurs="1"
> >> >>>
> >> >>> name="a"
> >> >>> nillable="false" type="xs:boolean" />
> >> >>>                                                       <xs:element
> >> >>> minOccurs="1"
> >> >>>
> >> >>> name="b"
> >> >>> nillable="false" type="xs:boolean" />
> >> >>>                                               </xs:sequence>
> >> >>>                                       </xs:extension>
> >> >>>                               </xs:complexContent>
> >> >>>                     </xs:complexType>
> >>
> >> -----------------------------------------------------------------------
> >>
> >> >>>-
> >>
> >> -----------------------------------------------------------------------
> >>
> >> >>>- -----
> >> >>>
> >> >>> XML Generated:
> >> >>>
> >> >>> <?xml version="1.0"?>
> >> >>> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
> >> >>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> >> >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >> >>> xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
> >> >>> xmlns:ns0="http://mdc.com">
> >> >>> <env:Body>
> >> >>>   <ns0:createXxxRequest>
> >> >>>     <ns0:xxx xsi:type="ns0:Xxx">
> >> >>>       <ns0:name>xxx</ns0:name>
> >> >>>     </ns0:xxx>
> >> >>>   </ns0:createXxxRequest>
> >> >>> </env:Body>
> >> >>> </env:Envelope>
> >>
> >> -----------------------------------------------------------------------
> >>
> >> >>>-
> >>
> >> -----------------------------------------------------------------------
> >>
> >> >>>- -----
> >> >>>
> >> >>> Exception In Log:
> >> >>>
> >> >>> INFO: Interceptor has thrown exception, unwinding now
> >> >>> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
> >> >>> UndeclaredPrefix:
> >> >>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
> >> >>> declared.
> >> >>>       at
> >> >>> org
> >> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.ja
> >> >>>v a:643)
> >> >>>       at
> >> >>> org
> >> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.ja
> >> >>>v a:555)
> >> >>>       at
> >> >>> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:64)
> >> >>>       at
> >> >>> org
> >> >>> .apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLit
> >> >>>e ralInInterceptor.java:183)
> >> >>>       at
> >> >>> org
> >> >>> .apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptor
> >> >>>C hain.java:221)
> >> >>>       at
> >> >>> org
> >> >>> .apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiat
> >> >>>i onObserver.java:78)
> >> >>>       at
> >> >>> org
> >> >>> .apache.cxf.transport.servlet.ServletDestination.invoke(ServletDesti
> >> >>>n ation.java:92)
> >> >>>       at
> >> >>> org
> >> >>> .apache.cxf.transport.servlet.ServletController.invokeDestination(Se
> >> >>>r vletController.java:279)
> >> >>>       at
> >> >>> org
> >> >>> .apache.cxf.transport.servlet.ServletController.invoke(ServletContro
> >> >>>l ler.java:161)
> >> >>>       at
> >> >>> org
> >> >>> .apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFS
> >> >>>e rvlet.java:174)
> >> >>>       at
> >> >>> org
> >> >>> .apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFS
> >> >>>e rvlet.java:152)
> >> >>>       at
> >> >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at
> >> >>> javax.servlet.http.HttpServlet.service(HttpServlet.java:810) at
> >> >>> org
> >> >>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic
> >> >>>a tionFilterChain.java:252)
> >> >>>       at
> >> >>> org
> >> >>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil
> >> >>>t erChain.java:173)
> >> >>>       at
> >> >>> org
> >> >>> .jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilt
> >> >>>e r.java:96)
> >> >>>       at
> >> >>> org
> >> >>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applic
> >> >>>a tionFilterChain.java:202)
> >> >>>       at
> >> >>> org
> >> >>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFil
> >> >>>t erChain.java:173)
> >> >>>       at
> >> >>> org
> >> >>> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVal
> >> >>>v e.java:213)
> >> >>>       at
> >> >>> org
> >> >>> .apache.catalina.core.StandardContextValve.invoke(StandardContextVal
> >> >>>v e.java:178)
> >> >>>       at
> >> >>> org
> >> >>> .jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityA
> >> >>>s sociationValve.java:175)
> >> >>>       at
> >> >>> org
> >> >>> .jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.
> >> >>>j ava:74)
> >> >>>       at
> >> >>> org
> >> >>> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jav
> >> >>>a
> >> >>>
> >> >>> :126)
> >> >>>
> >> >>>       at
> >> >>> org
> >> >>> .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jav
> >> >>>a
> >> >>>
> >> >>> :105)
> >> >>>
> >> >>>       at
> >> >>> org
> >> >>> .jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnect
> >> >>>i onValve.java:156)
> >> >>>       at
> >> >>> org
> >> >>> .apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve
> >> >>>. java:107)
> >> >>>       at
> >> >>> org
> >> >>> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
> >> >>>1 48)
> >> >>>       at
> >> >>> org
> >> >>> .apache.coyote.http11.Http11Processor.process(Http11Processor.java:8
> >> >>>6 9)
> >> >>>       at
> >> >>> org.apache.coyote.http11.Http11BaseProtocol
> >> >>> $Http11ConnectionHandler.proc
> >> >>> essConnection(Http11BaseProtocol.java:664)
> >> >>>       at
> >> >>> org
> >> >>> .apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoin
> >> >>>t .java:527)
> >> >>>       at
> >> >>> org
> >> >>> .apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorke
> >> >>>r Thread.java:112)
> >> >>>       at java.lang.Thread.run(Thread.java:619)
> >> >>> Caused by: javax.xml.bind.UnmarshalException
> >> >>> - with linked exception:
> >> >>> [org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot resolve
> >> >>> 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.]
> >> >>>       at
> >> >>> com
> >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamE
> >> >>>x ception(UnmarshallerImpl.java:396)
> >> >>>       at
> >> >>> com
> >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Un
> >> >>>m arshallerImpl.java:335)
> >> >>>       at
> >> >>> com
> >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unm
> >> >>>a rshallerImpl.java:312)
> >> >>>       at
> >> >>> org
> >> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.ja
> >> >>>v a:628)
> >> >>>       ... 31 more
> >> >>> Caused by: org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot
> >> >>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.
> >> >>>       at
> >> >>> org
> >> >>> .apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unkn
> >> >>>o wn Source)
> >> >>>       at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
> >> >>> Source)
> >> >>>       at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> >> >>> Source)
> >> >>>       at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> >> >>> Source)
> >> >>>       at
> >> >>> org.apache.xerces.impl.xs.XMLSchemaValidator
> >> >>> $XSIErrorReporter.reportErro
> >> >>> r(Unknown Source)
> >> >>>       at
> >> >>> org
> >> >>> .apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown
> >> >>> Source)
> >> >>>       at
> >> >>> org
> >> >>> .apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unknown
> >> >>> Source)
> >> >>>       at
> >> >>> org
> >> >>> .apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
> >> >>> Source)
> >> >>>       at
> >> >>> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
> >> >>> Source)
> >> >>>       at
> >> >>> org
> >> >>> .apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unk
> >> >>>n own Source)
> >> >>>       at
> >> >>> com
> >> >>> .sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startEl
> >> >>>e ment(ValidatingUnmarshaller.java:73)
> >> >>>       at
> >> >>> com
> >> >>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStar
> >> >>>t Element(StAXStreamConnector.java:238)
> >> >>>       at
> >> >>> com
> >> >>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StA
> >> >>>X StreamConnector.java:172)
> >> >>>       at
> >> >>> com
> >> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Un
> >> >>>m arshallerImpl.java:333)
> >> >>>       ... 33 more
> >> >>
> >> >> ---
> >> >> Daniel Kulp
> >> >> dkulp@apache.org
> >> >> http://www.dankulp.com/blog
> >> >
> >> > ---
> >> > Daniel Kulp
> >> > dkulp@apache.org
> >> > http://www.dankulp.com/blog
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Antwort: Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared [Virus checked]

Posted by jp4 <jo...@hnpsolutions.com>.
Dan,

I upgraded to CXF 2.2.2 and tried once again with Java 6.  I am still seeing
the same error.  The type is properly declared, and I can validate the same
XML with a servlet that uses the same XSDs.  Should I open a bug for this? 
Any other ideas?

Thanks,

John

dkulp wrote:
> 
> On Thu July 9 2009 10:34:38 am jp4 wrote:
>> I am seeing a similar behavior where the xsi:type causes the
>> UndeclaredPrefix error.  Initially I was running CXF 2.2 with JDK 1.5 on
> 
> Well, definitely try with CXF 2.2.2.   That may help.
> 
> If that doesn't help, use something like wireshark or similar to capture
> the 
> raw message off the wire and see if ns3 is actually properly declared on
> the 
> wire.   If not, that would probably be a bug.
> 
> Dan
> 
> 
>> Jboss 4.2.3.GA.  I have since upgraded to Java 6.  I send a sample
>> request
>> through SOAPUI and I still see the same error below...  If I attempt to
>> validate the same file from within the container using a servlet and the
>> code below, it validates just fine.  Any idea what could be causing the
>> discrepancy?
>>
>>         Source source = new
>> StreamSource(getClass().getResourceAsStream("/request.xml"));
>>         // If you comment the following line, it works
>>         source = toDOMSource(source);
>>         validator.validate(source);
>>
>>
>> <07/09/09
>> 10:23:37:779|http-8443-2|INFO|apache.cxf.phase.PhaseInterceptorChain|Interc
>>eptor has thrown exception, unwinding now|
>> org.apache.cxf.interceptor.Fault: Unmarshalling Error: UndeclaredPrefix:
>> Cannot resolve 'ns3:FundingSourceType' as a QName: the prefix 'ns3' is
>> not
>> declared.
>> 	at
>> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:6
>>22) at
>> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:5
>>27) at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:108)
>> at
>> org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteral
>>InInterceptor.java:183) at
>> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>>n.java:236) at
>> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationO
>>bserver.java:89) at
>> org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestinati
>>on.java:99) at
>> org.apache.cxf.transport.servlet.ServletController.invokeDestination(Servle
>>tController.java:337) at
>> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController
>>.java:182) at
>> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServl
>>et.java:163) at
>> org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServl
>>et.java:141) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>> 	at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
>>nFilterChain.java:290) at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
>>hain.java:206) at
>> com.billmelater.enterpriseservices.servlet.util.RequestTimerServletFilter.d
>>oFilter(RequestTimerServletFilter.java:55) at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
>>nFilterChain.java:235) at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
>>hain.java:206) at
>> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFil
>>ter(FilterChainProxy.java:378) at
>> org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke
>>(FilterSecurityInterceptor.java:109)
>>
>> dkulp wrote:
>> > Did some snooping...   The RI seems to have the same problem:
>> > http://forums.java.net/jive//message.jspa?messageID=268876
>> >
>> > And they mention its a bug in the JDK:
>> > https://jaxp.dev.java.net/issues/show_bug.cgi?id=46
>> >
>> > The workaround seems to be to use the latest 1.6 JDK or get the latest
>> > sun jaxp parser
>> > (http://download.java.net/maven/1/com.sun.xml.parsers/jars/
>> > )  and throw it in your endorsed dir.
>> >
>> > Dan
>> >
>> > On Jun 18, 2008, at 2:16 PM, jan.minaroviech@external.t-mobile.at
>> wrote:
>> >> Hi,
>> >>
>> >> looks like the same problem i have. But my response is invalid also
>> >> according to soapUI validation.
>> >>
>> >> I'm not using any additional interceptors, only default cxfServlet,
>> >> default bus config etc, without security, attachments etc. and I'm
>> >> using
>> >> jaxWS+jaxB
>> >>
>> >> This is response, which is problem in my case (cxf is client in this
>> >> case)
>> >>
>> >> <soapenv:Envelope
>> >> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>> >> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>> >>   <soapenv:Body>
>> >>      <locationSearchReply
>> >> xmlns="http://www.deltavista.at/schema/locationsearch">
>> >>         <foundLocation>
>> >>            <street>Stephansplatz</street>
>> >>            <houseNumber>1</houseNumber>
>> >>            <city>Wien</city>
>> >>            <zip xsi:type="xsd:string">1010</zip>
>> >>            <country xsi:type="xsd:string">AUT</country>
>> >>            <locationMatch>4</locationMatch>
>> >>            <similarity>92</similarity>
>> >>            <confidence>98</confidence>
>> >>         </foundLocation>
>> >>      </locationSearchReply>
>> >>   </soapenv:Body>
>> >> </soapenv:Envelope>
>> >>
>> >> i have a problem with xsd:string inside reply.
>> >>
>> >> pieces of xsd:
>> >>                                        <element name="zip"
>> >> type="locationsearch:Zip" minOccurs="1"/>
>> >>                        <simpleType name="Zip">
>> >>                                <restriction base="string">
>> >>                                        <minLength value="4"/>
>> >>                                        <maxLength value="7"/>
>> >>                                </restriction>
>> >>                        </simpleType>
>> >>
>> >> when i turn off validation, everything works
>> >>
>> >> best regards
>> >> jano
>> >>
>> >>
>> >>
>> >>
>> >> Daniel Kulp <dk...@apache.org>
>> >> 06/18/2008 20:05
>> >> Bitte antworten an
>> >> users@cxf.apache.org
>> >>
>> >>
>> >> An
>> >> users@cxf.apache.org
>> >> Kopie
>> >>
>> >> Thema
>> >> Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx'
>> >> as a
>> >> QName: the prefix 'ns0' is not declared  [Virus checked]
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> Very strange.   The message is definitely valid.
>> >>
>> >> Could questions:
>> >> 1) Do you have any SAAJ type handlers/interceptors on the chain (jaxws
>> >> SOAPHandler, ws-security things, etc...)?
>> >>
>> >> 2) I noticed you have a xerces jar...  can you try removing that and
>> >> seeing if the JDK built-in parser will work?  Also, check if you have
>> >> a xalan jar installed and remove that as well.
>> >>
>> >> 3) Can you turn off validation.   It looks like it's the validator
>> >> having an issue, not the unmarshaller.   If it unmarshalls OK that
>> >> way, we at least know the parser is giving it the correct data.   If
>> >> that still fails, we'll need to dig in more.
>> >>
>> >> Dan
>> >>
>> >> On Jun 17, 2008, at 12:33 PM, Urciolo, Kevin wrote:
>> >>> I am running in to an issue when a Java 5 client using JWSDP is
>> >>> sending
>> >>> a request to my CXF (2.1.1 SNAPSHOT) service.  I get an exception,
>> >>> Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a
>> >>> QName: the prefix 'ns0' is not declared, as shown below.  The type
>> >>> is an
>> >>> extension from a base type.  I am assuming this is why "xsi:type" is
>> >>> generated by the client since it is not used in other places.
>> >>>
>> >>> Is there a reason why CXF is having trouble with this?
>> >>>
>> >>> Type From Schema:
>> >>>
>> >>>                      <xs:complexType name="Xxx">
>> >>>                               <xs:complexContent>
>> >>>                                       <xs:extension base="tns:Base">
>> >>>                                               <xs:sequence>
>> >>>                                                       <xs:element
>> >>> minOccurs="1"
>> >>>
>> >>> name="a"
>> >>> nillable="false" type="xs:boolean" />
>> >>>                                                       <xs:element
>> >>> minOccurs="1"
>> >>>
>> >>> name="b"
>> >>> nillable="false" type="xs:boolean" />
>> >>>                                               </xs:sequence>
>> >>>                                       </xs:extension>
>> >>>                               </xs:complexContent>
>> >>>                     </xs:complexType>
>> >>>
>> >>>
>> -----------------------------------------------------------------------
>> >>>-
>> >>>
>> -----------------------------------------------------------------------
>> >>>- -----
>> >>>
>> >>> XML Generated:
>> >>>
>> >>> <?xml version="1.0"?>
>> >>> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
>> >>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> >>> xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
>> >>> xmlns:ns0="http://mdc.com">
>> >>> <env:Body>
>> >>>   <ns0:createXxxRequest>
>> >>>     <ns0:xxx xsi:type="ns0:Xxx">
>> >>>       <ns0:name>xxx</ns0:name>
>> >>>     </ns0:xxx>
>> >>>   </ns0:createXxxRequest>
>> >>> </env:Body>
>> >>> </env:Envelope>
>> >>>
>> >>>
>> -----------------------------------------------------------------------
>> >>>-
>> >>>
>> -----------------------------------------------------------------------
>> >>>- -----
>> >>>
>> >>> Exception In Log:
>> >>>
>> >>> INFO: Interceptor has thrown exception, unwinding now
>> >>> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
>> >>> UndeclaredPrefix:
>> >>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
>> >>> declared.
>> >>>       at
>> >>> org
>> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>> >>> a:643)
>> >>>       at
>> >>> org
>> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>> >>> a:555)
>> >>>       at
>> >>> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:64)
>> >>>       at
>> >>> org
>> >>> .apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLite
>> >>> ralInInterceptor.java:183)
>> >>>       at
>> >>> org
>> >>> .apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
>> >>> hain.java:221)
>> >>>       at
>> >>> org
>> >>> .apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiati
>> >>> onObserver.java:78)
>> >>>       at
>> >>> org
>> >>> .apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestin
>> >>> ation.java:92)
>> >>>       at
>> >>> org
>> >>> .apache.cxf.transport.servlet.ServletController.invokeDestination(Ser
>> >>> vletController.java:279)
>> >>>       at
>> >>> org
>> >>> .apache.cxf.transport.servlet.ServletController.invoke(ServletControl
>> >>> ler.java:161)
>> >>>       at
>> >>> org
>> >>> .apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFSe
>> >>> rvlet.java:174)
>> >>>       at
>> >>> org
>> >>> .apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFSe
>> >>> rvlet.java:152)
>> >>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>> >>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
>> >>>       at
>> >>> org
>> >>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
>> >>> tionFilterChain.java:252)
>> >>>       at
>> >>> org
>> >>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
>> >>> erChain.java:173)
>> >>>       at
>> >>> org
>> >>> .jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilte
>> >>> r.java:96)
>> >>>       at
>> >>> org
>> >>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
>> >>> tionFilterChain.java:202)
>> >>>       at
>> >>> org
>> >>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
>> >>> erChain.java:173)
>> >>>       at
>> >>> org
>> >>> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
>> >>> e.java:213)
>> >>>       at
>> >>> org
>> >>> .apache.catalina.core.StandardContextValve.invoke(StandardContextValv
>> >>> e.java:178)
>> >>>       at
>> >>> org
>> >>> .jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAs
>> >>> sociationValve.java:175)
>> >>>       at
>> >>> org
>> >>> .jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.j
>> >>> ava:74)
>> >>>       at
>> >>> org
>> >>> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
>> >>>
>> >>> :126)
>> >>>
>> >>>       at
>> >>> org
>> >>> .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
>> >>>
>> >>> :105)
>> >>>
>> >>>       at
>> >>> org
>> >>> .jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnecti
>> >>> onValve.java:156)
>> >>>       at
>> >>> org
>> >>> .apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
>> >>> java:107)
>> >>>       at
>> >>> org
>> >>> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1
>> >>> 48)
>> >>>       at
>> >>> org
>> >>> .apache.coyote.http11.Http11Processor.process(Http11Processor.java:86
>> >>> 9)
>> >>>       at
>> >>> org.apache.coyote.http11.Http11BaseProtocol
>> >>> $Http11ConnectionHandler.proc
>> >>> essConnection(Http11BaseProtocol.java:664)
>> >>>       at
>> >>> org
>> >>> .apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint
>> >>> .java:527)
>> >>>       at
>> >>> org
>> >>> .apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorker
>> >>> Thread.java:112)
>> >>>       at java.lang.Thread.run(Thread.java:619)
>> >>> Caused by: javax.xml.bind.UnmarshalException
>> >>> - with linked exception:
>> >>> [org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot resolve
>> >>> 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.]
>> >>>       at
>> >>> com
>> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamEx
>> >>> ception(UnmarshallerImpl.java:396)
>> >>>       at
>> >>> com
>> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
>> >>> arshallerImpl.java:335)
>> >>>       at
>> >>> com
>> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unma
>> >>> rshallerImpl.java:312)
>> >>>       at
>> >>> org
>> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>> >>> a:628)
>> >>>       ... 31 more
>> >>> Caused by: org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot
>> >>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.
>> >>>       at
>> >>> org
>> >>> .apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unkno
>> >>> wn Source)
>> >>>       at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
>> >>> Source)
>> >>>       at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>> >>> Source)
>> >>>       at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>> >>> Source)
>> >>>       at
>> >>> org.apache.xerces.impl.xs.XMLSchemaValidator
>> >>> $XSIErrorReporter.reportErro
>> >>> r(Unknown Source)
>> >>>       at
>> >>> org
>> >>> .apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown
>> >>> Source)
>> >>>       at
>> >>> org
>> >>> .apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unknown
>> >>> Source)
>> >>>       at
>> >>> org
>> >>> .apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
>> >>> Source)
>> >>>       at
>> >>> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
>> >>> Source)
>> >>>       at
>> >>> org
>> >>> .apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unkn
>> >>> own Source)
>> >>>       at
>> >>> com
>> >>> .sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startEle
>> >>> ment(ValidatingUnmarshaller.java:73)
>> >>>       at
>> >>> com
>> >>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStart
>> >>> Element(StAXStreamConnector.java:238)
>> >>>       at
>> >>> com
>> >>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAX
>> >>> StreamConnector.java:172)
>> >>>       at
>> >>> com
>> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
>> >>> arshallerImpl.java:333)
>> >>>       ... 33 more
>> >>
>> >> ---
>> >> Daniel Kulp
>> >> dkulp@apache.org
>> >> http://www.dankulp.com/blog
>> >
>> > ---
>> > Daniel Kulp
>> > dkulp@apache.org
>> > http://www.dankulp.com/blog
> 
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/Unmarshalling-Error%3A-UndeclaredPrefix%3A-Cannot-resolve-%27ns0%3AXxx%27-as-a-QName%3A-the-prefix-%27ns0%27-is-not-declared-tp17918441p24462568.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Antwort: Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared [Virus checked]

Posted by Daniel Kulp <dk...@apache.org>.
On Thu July 9 2009 10:34:38 am jp4 wrote:
> I am seeing a similar behavior where the xsi:type causes the
> UndeclaredPrefix error.  Initially I was running CXF 2.2 with JDK 1.5 on

Well, definitely try with CXF 2.2.2.   That may help.

If that doesn't help, use something like wireshark or similar to capture the 
raw message off the wire and see if ns3 is actually properly declared on the 
wire.   If not, that would probably be a bug.

Dan


> Jboss 4.2.3.GA.  I have since upgraded to Java 6.  I send a sample request
> through SOAPUI and I still see the same error below...  If I attempt to
> validate the same file from within the container using a servlet and the
> code below, it validates just fine.  Any idea what could be causing the
> discrepancy?
>
>         Source source = new
> StreamSource(getClass().getResourceAsStream("/request.xml"));
>         // If you comment the following line, it works
>         source = toDOMSource(source);
>         validator.validate(source);
>
>
> <07/09/09
> 10:23:37:779|http-8443-2|INFO|apache.cxf.phase.PhaseInterceptorChain|Interc
>eptor has thrown exception, unwinding now|
> org.apache.cxf.interceptor.Fault: Unmarshalling Error: UndeclaredPrefix:
> Cannot resolve 'ns3:FundingSourceType' as a QName: the prefix 'ns3' is not
> declared.
> 	at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:6
>22) at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:5
>27) at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:108)
> at
> org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteral
>InInterceptor.java:183) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>n.java:236) at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationO
>bserver.java:89) at
> org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestinati
>on.java:99) at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(Servle
>tController.java:337) at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController
>.java:182) at
> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServl
>et.java:163) at
> org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServl
>et.java:141) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
>nFilterChain.java:290) at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
>hain.java:206) at
> com.billmelater.enterpriseservices.servlet.util.RequestTimerServletFilter.d
>oFilter(RequestTimerServletFilter.java:55) at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
>nFilterChain.java:235) at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
>hain.java:206) at
> org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFil
>ter(FilterChainProxy.java:378) at
> org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke
>(FilterSecurityInterceptor.java:109)
>
> dkulp wrote:
> > Did some snooping...   The RI seems to have the same problem:
> > http://forums.java.net/jive//message.jspa?messageID=268876
> >
> > And they mention its a bug in the JDK:
> > https://jaxp.dev.java.net/issues/show_bug.cgi?id=46
> >
> > The workaround seems to be to use the latest 1.6 JDK or get the latest
> > sun jaxp parser
> > (http://download.java.net/maven/1/com.sun.xml.parsers/jars/
> > )  and throw it in your endorsed dir.
> >
> > Dan
> >
> > On Jun 18, 2008, at 2:16 PM, jan.minaroviech@external.t-mobile.at wrote:
> >> Hi,
> >>
> >> looks like the same problem i have. But my response is invalid also
> >> according to soapUI validation.
> >>
> >> I'm not using any additional interceptors, only default cxfServlet,
> >> default bus config etc, without security, attachments etc. and I'm
> >> using
> >> jaxWS+jaxB
> >>
> >> This is response, which is problem in my case (cxf is client in this
> >> case)
> >>
> >> <soapenv:Envelope
> >> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> >> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> >> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> >>   <soapenv:Body>
> >>      <locationSearchReply
> >> xmlns="http://www.deltavista.at/schema/locationsearch">
> >>         <foundLocation>
> >>            <street>Stephansplatz</street>
> >>            <houseNumber>1</houseNumber>
> >>            <city>Wien</city>
> >>            <zip xsi:type="xsd:string">1010</zip>
> >>            <country xsi:type="xsd:string">AUT</country>
> >>            <locationMatch>4</locationMatch>
> >>            <similarity>92</similarity>
> >>            <confidence>98</confidence>
> >>         </foundLocation>
> >>      </locationSearchReply>
> >>   </soapenv:Body>
> >> </soapenv:Envelope>
> >>
> >> i have a problem with xsd:string inside reply.
> >>
> >> pieces of xsd:
> >>                                        <element name="zip"
> >> type="locationsearch:Zip" minOccurs="1"/>
> >>                        <simpleType name="Zip">
> >>                                <restriction base="string">
> >>                                        <minLength value="4"/>
> >>                                        <maxLength value="7"/>
> >>                                </restriction>
> >>                        </simpleType>
> >>
> >> when i turn off validation, everything works
> >>
> >> best regards
> >> jano
> >>
> >>
> >>
> >>
> >> Daniel Kulp <dk...@apache.org>
> >> 06/18/2008 20:05
> >> Bitte antworten an
> >> users@cxf.apache.org
> >>
> >>
> >> An
> >> users@cxf.apache.org
> >> Kopie
> >>
> >> Thema
> >> Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx'
> >> as a
> >> QName: the prefix 'ns0' is not declared  [Virus checked]
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> Very strange.   The message is definitely valid.
> >>
> >> Could questions:
> >> 1) Do you have any SAAJ type handlers/interceptors on the chain (jaxws
> >> SOAPHandler, ws-security things, etc...)?
> >>
> >> 2) I noticed you have a xerces jar...  can you try removing that and
> >> seeing if the JDK built-in parser will work?  Also, check if you have
> >> a xalan jar installed and remove that as well.
> >>
> >> 3) Can you turn off validation.   It looks like it's the validator
> >> having an issue, not the unmarshaller.   If it unmarshalls OK that
> >> way, we at least know the parser is giving it the correct data.   If
> >> that still fails, we'll need to dig in more.
> >>
> >> Dan
> >>
> >> On Jun 17, 2008, at 12:33 PM, Urciolo, Kevin wrote:
> >>> I am running in to an issue when a Java 5 client using JWSDP is
> >>> sending
> >>> a request to my CXF (2.1.1 SNAPSHOT) service.  I get an exception,
> >>> Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a
> >>> QName: the prefix 'ns0' is not declared, as shown below.  The type
> >>> is an
> >>> extension from a base type.  I am assuming this is why "xsi:type" is
> >>> generated by the client since it is not used in other places.
> >>>
> >>> Is there a reason why CXF is having trouble with this?
> >>>
> >>> Type From Schema:
> >>>
> >>>                      <xs:complexType name="Xxx">
> >>>                               <xs:complexContent>
> >>>                                       <xs:extension base="tns:Base">
> >>>                                               <xs:sequence>
> >>>                                                       <xs:element
> >>> minOccurs="1"
> >>>
> >>> name="a"
> >>> nillable="false" type="xs:boolean" />
> >>>                                                       <xs:element
> >>> minOccurs="1"
> >>>
> >>> name="b"
> >>> nillable="false" type="xs:boolean" />
> >>>                                               </xs:sequence>
> >>>                                       </xs:extension>
> >>>                               </xs:complexContent>
> >>>                     </xs:complexType>
> >>>
> >>> -----------------------------------------------------------------------
> >>>-
> >>> -----------------------------------------------------------------------
> >>>- -----
> >>>
> >>> XML Generated:
> >>>
> >>> <?xml version="1.0"?>
> >>> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
> >>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> >>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >>> xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
> >>> xmlns:ns0="http://mdc.com">
> >>> <env:Body>
> >>>   <ns0:createXxxRequest>
> >>>     <ns0:xxx xsi:type="ns0:Xxx">
> >>>       <ns0:name>xxx</ns0:name>
> >>>     </ns0:xxx>
> >>>   </ns0:createXxxRequest>
> >>> </env:Body>
> >>> </env:Envelope>
> >>>
> >>> -----------------------------------------------------------------------
> >>>-
> >>> -----------------------------------------------------------------------
> >>>- -----
> >>>
> >>> Exception In Log:
> >>>
> >>> INFO: Interceptor has thrown exception, unwinding now
> >>> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
> >>> UndeclaredPrefix:
> >>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not
> >>> declared.
> >>>       at
> >>> org
> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
> >>> a:643)
> >>>       at
> >>> org
> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
> >>> a:555)
> >>>       at
> >>> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:64)
> >>>       at
> >>> org
> >>> .apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLite
> >>> ralInInterceptor.java:183)
> >>>       at
> >>> org
> >>> .apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
> >>> hain.java:221)
> >>>       at
> >>> org
> >>> .apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiati
> >>> onObserver.java:78)
> >>>       at
> >>> org
> >>> .apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestin
> >>> ation.java:92)
> >>>       at
> >>> org
> >>> .apache.cxf.transport.servlet.ServletController.invokeDestination(Ser
> >>> vletController.java:279)
> >>>       at
> >>> org
> >>> .apache.cxf.transport.servlet.ServletController.invoke(ServletControl
> >>> ler.java:161)
> >>>       at
> >>> org
> >>> .apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFSe
> >>> rvlet.java:174)
> >>>       at
> >>> org
> >>> .apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFSe
> >>> rvlet.java:152)
> >>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> >>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
> >>>       at
> >>> org
> >>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> >>> tionFilterChain.java:252)
> >>>       at
> >>> org
> >>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> >>> erChain.java:173)
> >>>       at
> >>> org
> >>> .jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilte
> >>> r.java:96)
> >>>       at
> >>> org
> >>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> >>> tionFilterChain.java:202)
> >>>       at
> >>> org
> >>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> >>> erChain.java:173)
> >>>       at
> >>> org
> >>> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
> >>> e.java:213)
> >>>       at
> >>> org
> >>> .apache.catalina.core.StandardContextValve.invoke(StandardContextValv
> >>> e.java:178)
> >>>       at
> >>> org
> >>> .jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAs
> >>> sociationValve.java:175)
> >>>       at
> >>> org
> >>> .jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.j
> >>> ava:74)
> >>>       at
> >>> org
> >>> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
> >>>
> >>> :126)
> >>>
> >>>       at
> >>> org
> >>> .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
> >>>
> >>> :105)
> >>>
> >>>       at
> >>> org
> >>> .jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnecti
> >>> onValve.java:156)
> >>>       at
> >>> org
> >>> .apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
> >>> java:107)
> >>>       at
> >>> org
> >>> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1
> >>> 48)
> >>>       at
> >>> org
> >>> .apache.coyote.http11.Http11Processor.process(Http11Processor.java:86
> >>> 9)
> >>>       at
> >>> org.apache.coyote.http11.Http11BaseProtocol
> >>> $Http11ConnectionHandler.proc
> >>> essConnection(Http11BaseProtocol.java:664)
> >>>       at
> >>> org
> >>> .apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint
> >>> .java:527)
> >>>       at
> >>> org
> >>> .apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorker
> >>> Thread.java:112)
> >>>       at java.lang.Thread.run(Thread.java:619)
> >>> Caused by: javax.xml.bind.UnmarshalException
> >>> - with linked exception:
> >>> [org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot resolve
> >>> 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.]
> >>>       at
> >>> com
> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamEx
> >>> ception(UnmarshallerImpl.java:396)
> >>>       at
> >>> com
> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
> >>> arshallerImpl.java:335)
> >>>       at
> >>> com
> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unma
> >>> rshallerImpl.java:312)
> >>>       at
> >>> org
> >>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
> >>> a:628)
> >>>       ... 31 more
> >>> Caused by: org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot
> >>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.
> >>>       at
> >>> org
> >>> .apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unkno
> >>> wn Source)
> >>>       at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
> >>> Source)
> >>>       at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> >>> Source)
> >>>       at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
> >>> Source)
> >>>       at
> >>> org.apache.xerces.impl.xs.XMLSchemaValidator
> >>> $XSIErrorReporter.reportErro
> >>> r(Unknown Source)
> >>>       at
> >>> org
> >>> .apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown
> >>> Source)
> >>>       at
> >>> org
> >>> .apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unknown
> >>> Source)
> >>>       at
> >>> org
> >>> .apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
> >>> Source)
> >>>       at
> >>> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
> >>> Source)
> >>>       at
> >>> org
> >>> .apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unkn
> >>> own Source)
> >>>       at
> >>> com
> >>> .sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startEle
> >>> ment(ValidatingUnmarshaller.java:73)
> >>>       at
> >>> com
> >>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStart
> >>> Element(StAXStreamConnector.java:238)
> >>>       at
> >>> com
> >>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAX
> >>> StreamConnector.java:172)
> >>>       at
> >>> com
> >>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
> >>> arshallerImpl.java:333)
> >>>       ... 33 more
> >>
> >> ---
> >> Daniel Kulp
> >> dkulp@apache.org
> >> http://www.dankulp.com/blog
> >
> > ---
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Antwort: Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared [Virus checked]

Posted by jp4 <jo...@hnpsolutions.com>.
I just tried with Jboss 5.1.0.GA as well and I still see the same issue.  Any
thoughts or recommendations would be greatly appreciated.
 

jp4 wrote:
> 
> I am seeing a similar behavior where the xsi:type causes the
> UndeclaredPrefix error.  Initially I was running CXF 2.2 with JDK 1.5 on
> Jboss 4.2.3.GA.  I have since upgraded to Java 6.  I send a sample request
> through SOAPUI and I still see the same error below...  If I attempt to
> validate the same file from within the container using a servlet and the
> code below, it validates just fine.  Any idea what could be causing the
> discrepancy?  Also, it's important to note that if I turn off validation
> (as suggested in a previous post) it works fine.
> 
>         Source source = new
> StreamSource(getClass().getResourceAsStream("/request.xml"));
>         source = toDOMSource(source);
>         validator.validate(source);
> 
>  - with linked exception:
> [org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot resolve
> 'ns3:PayPalFundingSourceType' as a QName: the prefix 'ns3' is not
> declared.]
> 	at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:425)
> 	at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)
> 	at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
> 	at
> org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:607)
> 	... 57 more
> Caused by: org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot resolve
> 'ns3:PayPalFundingSourceType' as a QName: the prefix 'ns3' is not
> declared.
> 	at
> org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
> Source)
> 	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
> 	at
> org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown
> Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown
> Source)
> 	at
> org.apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unknown
> Source)
> 	at
> org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
> Source)
> 	at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
> Source)
> 	at
> org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unknown
> Source)
> 	at
> com.sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startElement(ValidatingUnmarshaller.java:89)
> 	at
> com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:275)
> 	at
> com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:209)
> 	at
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
> 
> 
> dkulp wrote:
>> 
>> 
>> Did some snooping...   The RI seems to have the same problem:
>> http://forums.java.net/jive//message.jspa?messageID=268876
>> 
>> And they mention its a bug in the JDK:
>> https://jaxp.dev.java.net/issues/show_bug.cgi?id=46
>> 
>> The workaround seems to be to use the latest 1.6 JDK or get the latest  
>> sun jaxp parser
>> (http://download.java.net/maven/1/com.sun.xml.parsers/jars/ 
>> )  and throw it in your endorsed dir.
>> 
>> Dan
>> 
>> 
>> 
>> On Jun 18, 2008, at 2:16 PM, jan.minaroviech@external.t-mobile.at wrote:
>> 
>>> Hi,
>>>
>>> looks like the same problem i have. But my response is invalid also
>>> according to soapUI validation.
>>>
>>> I'm not using any additional interceptors, only default cxfServlet,
>>> default bus config etc, without security, attachments etc. and I'm  
>>> using
>>> jaxWS+jaxB
>>>
>>> This is response, which is problem in my case (cxf is client in this  
>>> case)
>>>
>>> <soapenv:Envelope
>>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>>   <soapenv:Body>
>>>      <locationSearchReply
>>> xmlns="http://www.deltavista.at/schema/locationsearch">
>>>         <foundLocation>
>>>            <street>Stephansplatz</street>
>>>            <houseNumber>1</houseNumber>
>>>            <city>Wien</city>
>>>            <zip xsi:type="xsd:string">1010</zip>
>>>            <country xsi:type="xsd:string">AUT</country>
>>>            <locationMatch>4</locationMatch>
>>>            <similarity>92</similarity>
>>>            <confidence>98</confidence>
>>>         </foundLocation>
>>>      </locationSearchReply>
>>>   </soapenv:Body>
>>> </soapenv:Envelope>
>>>
>>> i have a problem with xsd:string inside reply.
>>>
>>> pieces of xsd:
>>>                                        <element name="zip"
>>> type="locationsearch:Zip" minOccurs="1"/>
>>>                        <simpleType name="Zip">
>>>                                <restriction base="string">
>>>                                        <minLength value="4"/>
>>>                                        <maxLength value="7"/>
>>>                                </restriction>
>>>                        </simpleType>
>>>
>>> when i turn off validation, everything works
>>>
>>> best regards
>>> jano
>>>
>>>
>>>
>>>
>>> Daniel Kulp <dk...@apache.org>
>>> 06/18/2008 20:05
>>> Bitte antworten an
>>> users@cxf.apache.org
>>>
>>>
>>> An
>>> users@cxf.apache.org
>>> Kopie
>>>
>>> Thema
>>> Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx'  
>>> as a
>>> QName: the prefix 'ns0' is not declared  [Virus checked]
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Very strange.   The message is definitely valid.
>>>
>>> Could questions:
>>> 1) Do you have any SAAJ type handlers/interceptors on the chain (jaxws
>>> SOAPHandler, ws-security things, etc...)?
>>>
>>> 2) I noticed you have a xerces jar...  can you try removing that and
>>> seeing if the JDK built-in parser will work?  Also, check if you have
>>> a xalan jar installed and remove that as well.
>>>
>>> 3) Can you turn off validation.   It looks like it's the validator
>>> having an issue, not the unmarshaller.   If it unmarshalls OK that
>>> way, we at least know the parser is giving it the correct data.   If
>>> that still fails, we'll need to dig in more.
>>>
>>> Dan
>>>
>>>
>>>
>>> On Jun 17, 2008, at 12:33 PM, Urciolo, Kevin wrote:
>>>
>>>> I am running in to an issue when a Java 5 client using JWSDP is
>>>> sending
>>>> a request to my CXF (2.1.1 SNAPSHOT) service.  I get an exception,
>>>> Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a
>>>> QName: the prefix 'ns0' is not declared, as shown below.  The type
>>>> is an
>>>> extension from a base type.  I am assuming this is why "xsi:type" is
>>>> generated by the client since it is not used in other places.
>>>>
>>>> Is there a reason why CXF is having trouble with this?
>>>>
>>>> Type From Schema:
>>>>
>>>>                      <xs:complexType name="Xxx">
>>>>                               <xs:complexContent>
>>>>                                       <xs:extension base="tns:Base">
>>>>                                               <xs:sequence>
>>>>                                                       <xs:element
>>>> minOccurs="1"
>>>>
>>>> name="a"
>>>> nillable="false" type="xs:boolean" />
>>>>                                                       <xs:element
>>>> minOccurs="1"
>>>>
>>>> name="b"
>>>> nillable="false" type="xs:boolean" />
>>>>                                               </xs:sequence>
>>>>                                       </xs:extension>
>>>>                               </xs:complexContent>
>>>>                     </xs:complexType>
>>>>
>>>> ------------------------------------------------------------------------
>>>> ------------------------------------------------------------------------
>>>> -----
>>>>
>>>> XML Generated:
>>>>
>>>> <?xml version="1.0"?>
>>>> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
>>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>> xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
>>>> xmlns:ns0="http://mdc.com">
>>>> <env:Body>
>>>>   <ns0:createXxxRequest>
>>>>     <ns0:xxx xsi:type="ns0:Xxx">
>>>>       <ns0:name>xxx</ns0:name>
>>>>     </ns0:xxx>
>>>>   </ns0:createXxxRequest>
>>>> </env:Body>
>>>> </env:Envelope>
>>>>
>>>> ------------------------------------------------------------------------
>>>> ------------------------------------------------------------------------
>>>> -----
>>>>
>>>> Exception In Log:
>>>>
>>>> INFO: Interceptor has thrown exception, unwinding now
>>>> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
>>>> UndeclaredPrefix:
>>>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not  
>>>> declared.
>>>>       at
>>>> org
>>>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>>>> a:643)
>>>>       at
>>>> org
>>>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>>>> a:555)
>>>>       at
>>>> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:64)
>>>>       at
>>>> org
>>>> .apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLite
>>>> ralInInterceptor.java:183)
>>>>       at
>>>> org
>>>> .apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
>>>> hain.java:221)
>>>>       at
>>>> org
>>>> .apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiati
>>>> onObserver.java:78)
>>>>       at
>>>> org
>>>> .apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestin
>>>> ation.java:92)
>>>>       at
>>>> org
>>>> .apache.cxf.transport.servlet.ServletController.invokeDestination(Ser
>>>> vletController.java:279)
>>>>       at
>>>> org
>>>> .apache.cxf.transport.servlet.ServletController.invoke(ServletControl
>>>> ler.java:161)
>>>>       at
>>>> org
>>>> .apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFSe
>>>> rvlet.java:174)
>>>>       at
>>>> org
>>>> .apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFSe
>>>> rvlet.java:152)
>>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
>>>>       at
>>>> org
>>>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
>>>> tionFilterChain.java:252)
>>>>       at
>>>> org
>>>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
>>>> erChain.java:173)
>>>>       at
>>>> org
>>>> .jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilte
>>>> r.java:96)
>>>>       at
>>>> org
>>>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
>>>> tionFilterChain.java:202)
>>>>       at
>>>> org
>>>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
>>>> erChain.java:173)
>>>>       at
>>>> org
>>>> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
>>>> e.java:213)
>>>>       at
>>>> org
>>>> .apache.catalina.core.StandardContextValve.invoke(StandardContextValv
>>>> e.java:178)
>>>>       at
>>>> org
>>>> .jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAs
>>>> sociationValve.java:175)
>>>>       at
>>>> org
>>>> .jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.j
>>>> ava:74)
>>>>       at
>>>> org
>>>> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
>>>> :126)
>>>>       at
>>>> org
>>>> .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
>>>> :105)
>>>>       at
>>>> org
>>>> .jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnecti
>>>> onValve.java:156)
>>>>       at
>>>> org
>>>> .apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
>>>> java:107)
>>>>       at
>>>> org
>>>> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1
>>>> 48)
>>>>       at
>>>> org
>>>> .apache.coyote.http11.Http11Processor.process(Http11Processor.java:86
>>>> 9)
>>>>       at
>>>> org.apache.coyote.http11.Http11BaseProtocol
>>>> $Http11ConnectionHandler.proc
>>>> essConnection(Http11BaseProtocol.java:664)
>>>>       at
>>>> org
>>>> .apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint
>>>> .java:527)
>>>>       at
>>>> org
>>>> .apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorker
>>>> Thread.java:112)
>>>>       at java.lang.Thread.run(Thread.java:619)
>>>> Caused by: javax.xml.bind.UnmarshalException
>>>> - with linked exception:
>>>> [org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot resolve
>>>> 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.]
>>>>       at
>>>> com
>>>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamEx
>>>> ception(UnmarshallerImpl.java:396)
>>>>       at
>>>> com
>>>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
>>>> arshallerImpl.java:335)
>>>>       at
>>>> com
>>>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unma
>>>> rshallerImpl.java:312)
>>>>       at
>>>> org
>>>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>>>> a:628)
>>>>       ... 31 more
>>>> Caused by: org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot
>>>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.
>>>>       at
>>>> org
>>>> .apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unkno
>>>> wn Source)
>>>>       at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
>>>> Source)
>>>>       at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>>>> Source)
>>>>       at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>>>> Source)
>>>>       at
>>>> org.apache.xerces.impl.xs.XMLSchemaValidator
>>>> $XSIErrorReporter.reportErro
>>>> r(Unknown Source)
>>>>       at
>>>> org 
>>>> .apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown
>>>> Source)
>>>>       at
>>>> org
>>>> .apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unknown
>>>> Source)
>>>>       at
>>>> org
>>>> .apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
>>>> Source)
>>>>       at
>>>> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
>>>> Source)
>>>>       at
>>>> org
>>>> .apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unkn
>>>> own Source)
>>>>       at
>>>> com
>>>> .sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startEle
>>>> ment(ValidatingUnmarshaller.java:73)
>>>>       at
>>>> com
>>>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStart
>>>> Element(StAXStreamConnector.java:238)
>>>>       at
>>>> com
>>>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAX
>>>> StreamConnector.java:172)
>>>>       at
>>>> com
>>>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
>>>> arshallerImpl.java:333)
>>>>       ... 33 more
>>>
>>> ---
>>> Daniel Kulp
>>> dkulp@apache.org
>>> http://www.dankulp.com/blog
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>> 
>> ---
>> Daniel Kulp
>> dkulp@apache.org
>> http://www.dankulp.com/blog
>> 
>> 
>> 
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Unmarshalling-Error%3A-UndeclaredPrefix%3A-Cannot-resolve-%27ns0%3AXxx%27-as-a-QName%3A-the-prefix-%27ns0%27-is-not-declared-tp17918441p24414577.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Antwort: Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared [Virus checked]

Posted by jp4 <jo...@hnpsolutions.com>.
I am seeing a similar behavior where the xsi:type causes the UndeclaredPrefix
error.  Initially I was running CXF 2.2 with JDK 1.5 on Jboss 4.2.3.GA.  I
have since upgraded to Java 6.  I send a sample request through SOAPUI and I
still see the same error below...  If I attempt to validate the same file
from within the container using a servlet and the code below, it validates
just fine.  Any idea what could be causing the discrepancy?

        Source source = new
StreamSource(getClass().getResourceAsStream("/request.xml"));
        // If you comment the following line, it works
        source = toDOMSource(source);
        validator.validate(source);


<07/09/09
10:23:37:779|http-8443-2|INFO|apache.cxf.phase.PhaseInterceptorChain|Interceptor
has thrown exception, unwinding now|
org.apache.cxf.interceptor.Fault: Unmarshalling Error: UndeclaredPrefix:
Cannot resolve 'ns3:FundingSourceType' as a QName: the prefix 'ns3' is not
declared. 
	at
org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:622)
	at
org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:527)
	at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:108)
	at
org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:183)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
	at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:89)
	at
org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:99)
	at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:337)
	at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:182)
	at
org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:163)
	at
org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:141)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at
com.billmelater.enterpriseservices.servlet.util.RequestTimerServletFilter.doFilter(RequestTimerServletFilter.java:55)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
	at
org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)


dkulp wrote:
> 
> 
> Did some snooping...   The RI seems to have the same problem:
> http://forums.java.net/jive//message.jspa?messageID=268876
> 
> And they mention its a bug in the JDK:
> https://jaxp.dev.java.net/issues/show_bug.cgi?id=46
> 
> The workaround seems to be to use the latest 1.6 JDK or get the latest  
> sun jaxp parser
> (http://download.java.net/maven/1/com.sun.xml.parsers/jars/ 
> )  and throw it in your endorsed dir.
> 
> Dan
> 
> 
> 
> On Jun 18, 2008, at 2:16 PM, jan.minaroviech@external.t-mobile.at wrote:
> 
>> Hi,
>>
>> looks like the same problem i have. But my response is invalid also
>> according to soapUI validation.
>>
>> I'm not using any additional interceptors, only default cxfServlet,
>> default bus config etc, without security, attachments etc. and I'm  
>> using
>> jaxWS+jaxB
>>
>> This is response, which is problem in my case (cxf is client in this  
>> case)
>>
>> <soapenv:Envelope
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>   <soapenv:Body>
>>      <locationSearchReply
>> xmlns="http://www.deltavista.at/schema/locationsearch">
>>         <foundLocation>
>>            <street>Stephansplatz</street>
>>            <houseNumber>1</houseNumber>
>>            <city>Wien</city>
>>            <zip xsi:type="xsd:string">1010</zip>
>>            <country xsi:type="xsd:string">AUT</country>
>>            <locationMatch>4</locationMatch>
>>            <similarity>92</similarity>
>>            <confidence>98</confidence>
>>         </foundLocation>
>>      </locationSearchReply>
>>   </soapenv:Body>
>> </soapenv:Envelope>
>>
>> i have a problem with xsd:string inside reply.
>>
>> pieces of xsd:
>>                                        <element name="zip"
>> type="locationsearch:Zip" minOccurs="1"/>
>>                        <simpleType name="Zip">
>>                                <restriction base="string">
>>                                        <minLength value="4"/>
>>                                        <maxLength value="7"/>
>>                                </restriction>
>>                        </simpleType>
>>
>> when i turn off validation, everything works
>>
>> best regards
>> jano
>>
>>
>>
>>
>> Daniel Kulp <dk...@apache.org>
>> 06/18/2008 20:05
>> Bitte antworten an
>> users@cxf.apache.org
>>
>>
>> An
>> users@cxf.apache.org
>> Kopie
>>
>> Thema
>> Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx'  
>> as a
>> QName: the prefix 'ns0' is not declared  [Virus checked]
>>
>>
>>
>>
>>
>>
>>
>> Very strange.   The message is definitely valid.
>>
>> Could questions:
>> 1) Do you have any SAAJ type handlers/interceptors on the chain (jaxws
>> SOAPHandler, ws-security things, etc...)?
>>
>> 2) I noticed you have a xerces jar...  can you try removing that and
>> seeing if the JDK built-in parser will work?  Also, check if you have
>> a xalan jar installed and remove that as well.
>>
>> 3) Can you turn off validation.   It looks like it's the validator
>> having an issue, not the unmarshaller.   If it unmarshalls OK that
>> way, we at least know the parser is giving it the correct data.   If
>> that still fails, we'll need to dig in more.
>>
>> Dan
>>
>>
>>
>> On Jun 17, 2008, at 12:33 PM, Urciolo, Kevin wrote:
>>
>>> I am running in to an issue when a Java 5 client using JWSDP is
>>> sending
>>> a request to my CXF (2.1.1 SNAPSHOT) service.  I get an exception,
>>> Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a
>>> QName: the prefix 'ns0' is not declared, as shown below.  The type
>>> is an
>>> extension from a base type.  I am assuming this is why "xsi:type" is
>>> generated by the client since it is not used in other places.
>>>
>>> Is there a reason why CXF is having trouble with this?
>>>
>>> Type From Schema:
>>>
>>>                      <xs:complexType name="Xxx">
>>>                               <xs:complexContent>
>>>                                       <xs:extension base="tns:Base">
>>>                                               <xs:sequence>
>>>                                                       <xs:element
>>> minOccurs="1"
>>>
>>> name="a"
>>> nillable="false" type="xs:boolean" />
>>>                                                       <xs:element
>>> minOccurs="1"
>>>
>>> name="b"
>>> nillable="false" type="xs:boolean" />
>>>                                               </xs:sequence>
>>>                                       </xs:extension>
>>>                               </xs:complexContent>
>>>                     </xs:complexType>
>>>
>>> ------------------------------------------------------------------------
>>> ------------------------------------------------------------------------
>>> -----
>>>
>>> XML Generated:
>>>
>>> <?xml version="1.0"?>
>>> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
>>> xmlns:ns0="http://mdc.com">
>>> <env:Body>
>>>   <ns0:createXxxRequest>
>>>     <ns0:xxx xsi:type="ns0:Xxx">
>>>       <ns0:name>xxx</ns0:name>
>>>     </ns0:xxx>
>>>   </ns0:createXxxRequest>
>>> </env:Body>
>>> </env:Envelope>
>>>
>>> ------------------------------------------------------------------------
>>> ------------------------------------------------------------------------
>>> -----
>>>
>>> Exception In Log:
>>>
>>> INFO: Interceptor has thrown exception, unwinding now
>>> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
>>> UndeclaredPrefix:
>>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not  
>>> declared.
>>>       at
>>> org
>>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>>> a:643)
>>>       at
>>> org
>>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>>> a:555)
>>>       at
>>> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:64)
>>>       at
>>> org
>>> .apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLite
>>> ralInInterceptor.java:183)
>>>       at
>>> org
>>> .apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
>>> hain.java:221)
>>>       at
>>> org
>>> .apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiati
>>> onObserver.java:78)
>>>       at
>>> org
>>> .apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestin
>>> ation.java:92)
>>>       at
>>> org
>>> .apache.cxf.transport.servlet.ServletController.invokeDestination(Ser
>>> vletController.java:279)
>>>       at
>>> org
>>> .apache.cxf.transport.servlet.ServletController.invoke(ServletControl
>>> ler.java:161)
>>>       at
>>> org
>>> .apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFSe
>>> rvlet.java:174)
>>>       at
>>> org
>>> .apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFSe
>>> rvlet.java:152)
>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
>>>       at
>>> org
>>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
>>> tionFilterChain.java:252)
>>>       at
>>> org
>>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
>>> erChain.java:173)
>>>       at
>>> org
>>> .jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilte
>>> r.java:96)
>>>       at
>>> org
>>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
>>> tionFilterChain.java:202)
>>>       at
>>> org
>>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
>>> erChain.java:173)
>>>       at
>>> org
>>> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
>>> e.java:213)
>>>       at
>>> org
>>> .apache.catalina.core.StandardContextValve.invoke(StandardContextValv
>>> e.java:178)
>>>       at
>>> org
>>> .jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAs
>>> sociationValve.java:175)
>>>       at
>>> org
>>> .jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.j
>>> ava:74)
>>>       at
>>> org
>>> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
>>> :126)
>>>       at
>>> org
>>> .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
>>> :105)
>>>       at
>>> org
>>> .jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnecti
>>> onValve.java:156)
>>>       at
>>> org
>>> .apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
>>> java:107)
>>>       at
>>> org
>>> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1
>>> 48)
>>>       at
>>> org
>>> .apache.coyote.http11.Http11Processor.process(Http11Processor.java:86
>>> 9)
>>>       at
>>> org.apache.coyote.http11.Http11BaseProtocol
>>> $Http11ConnectionHandler.proc
>>> essConnection(Http11BaseProtocol.java:664)
>>>       at
>>> org
>>> .apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint
>>> .java:527)
>>>       at
>>> org
>>> .apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorker
>>> Thread.java:112)
>>>       at java.lang.Thread.run(Thread.java:619)
>>> Caused by: javax.xml.bind.UnmarshalException
>>> - with linked exception:
>>> [org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot resolve
>>> 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.]
>>>       at
>>> com
>>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamEx
>>> ception(UnmarshallerImpl.java:396)
>>>       at
>>> com
>>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
>>> arshallerImpl.java:335)
>>>       at
>>> com
>>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unma
>>> rshallerImpl.java:312)
>>>       at
>>> org
>>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>>> a:628)
>>>       ... 31 more
>>> Caused by: org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot
>>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.
>>>       at
>>> org
>>> .apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unkno
>>> wn Source)
>>>       at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
>>> Source)
>>>       at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>>> Source)
>>>       at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>>> Source)
>>>       at
>>> org.apache.xerces.impl.xs.XMLSchemaValidator
>>> $XSIErrorReporter.reportErro
>>> r(Unknown Source)
>>>       at
>>> org 
>>> .apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown
>>> Source)
>>>       at
>>> org
>>> .apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unknown
>>> Source)
>>>       at
>>> org
>>> .apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
>>> Source)
>>>       at
>>> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
>>> Source)
>>>       at
>>> org
>>> .apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unkn
>>> own Source)
>>>       at
>>> com
>>> .sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startEle
>>> ment(ValidatingUnmarshaller.java:73)
>>>       at
>>> com
>>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStart
>>> Element(StAXStreamConnector.java:238)
>>>       at
>>> com
>>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAX
>>> StreamConnector.java:172)
>>>       at
>>> com
>>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
>>> arshallerImpl.java:333)
>>>       ... 33 more
>>
>> ---
>> Daniel Kulp
>> dkulp@apache.org
>> http://www.dankulp.com/blog
>>
>>
>>
>>
>>
>>
>>
> 
> ---
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Unmarshalling-Error%3A-UndeclaredPrefix%3A-Cannot-resolve-%27ns0%3AXxx%27-as-a-QName%3A-the-prefix-%27ns0%27-is-not-declared-tp17918441p24410641.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Antwort: Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared [Virus checked]

Posted by Daniel Kulp <dk...@apache.org>.
Did some snooping...   The RI seems to have the same problem:
http://forums.java.net/jive//message.jspa?messageID=268876

And they mention its a bug in the JDK:
https://jaxp.dev.java.net/issues/show_bug.cgi?id=46

The workaround seems to be to use the latest 1.6 JDK or get the latest  
sun jaxp parser (http://download.java.net/maven/1/com.sun.xml.parsers/jars/ 
)  and throw it in your endorsed dir.

Dan



On Jun 18, 2008, at 2:16 PM, jan.minaroviech@external.t-mobile.at wrote:

> Hi,
>
> looks like the same problem i have. But my response is invalid also
> according to soapUI validation.
>
> I'm not using any additional interceptors, only default cxfServlet,
> default bus config etc, without security, attachments etc. and I'm  
> using
> jaxWS+jaxB
>
> This is response, which is problem in my case (cxf is client in this  
> case)
>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>   <soapenv:Body>
>      <locationSearchReply
> xmlns="http://www.deltavista.at/schema/locationsearch">
>         <foundLocation>
>            <street>Stephansplatz</street>
>            <houseNumber>1</houseNumber>
>            <city>Wien</city>
>            <zip xsi:type="xsd:string">1010</zip>
>            <country xsi:type="xsd:string">AUT</country>
>            <locationMatch>4</locationMatch>
>            <similarity>92</similarity>
>            <confidence>98</confidence>
>         </foundLocation>
>      </locationSearchReply>
>   </soapenv:Body>
> </soapenv:Envelope>
>
> i have a problem with xsd:string inside reply.
>
> pieces of xsd:
>                                        <element name="zip"
> type="locationsearch:Zip" minOccurs="1"/>
>                        <simpleType name="Zip">
>                                <restriction base="string">
>                                        <minLength value="4"/>
>                                        <maxLength value="7"/>
>                                </restriction>
>                        </simpleType>
>
> when i turn off validation, everything works
>
> best regards
> jano
>
>
>
>
> Daniel Kulp <dk...@apache.org>
> 06/18/2008 20:05
> Bitte antworten an
> users@cxf.apache.org
>
>
> An
> users@cxf.apache.org
> Kopie
>
> Thema
> Re: Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx'  
> as a
> QName: the prefix 'ns0' is not declared  [Virus checked]
>
>
>
>
>
>
>
> Very strange.   The message is definitely valid.
>
> Could questions:
> 1) Do you have any SAAJ type handlers/interceptors on the chain (jaxws
> SOAPHandler, ws-security things, etc...)?
>
> 2) I noticed you have a xerces jar...  can you try removing that and
> seeing if the JDK built-in parser will work?  Also, check if you have
> a xalan jar installed and remove that as well.
>
> 3) Can you turn off validation.   It looks like it's the validator
> having an issue, not the unmarshaller.   If it unmarshalls OK that
> way, we at least know the parser is giving it the correct data.   If
> that still fails, we'll need to dig in more.
>
> Dan
>
>
>
> On Jun 17, 2008, at 12:33 PM, Urciolo, Kevin wrote:
>
>> I am running in to an issue when a Java 5 client using JWSDP is
>> sending
>> a request to my CXF (2.1.1 SNAPSHOT) service.  I get an exception,
>> Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'ns0:Xxx' as a
>> QName: the prefix 'ns0' is not declared, as shown below.  The type
>> is an
>> extension from a base type.  I am assuming this is why "xsi:type" is
>> generated by the client since it is not used in other places.
>>
>> Is there a reason why CXF is having trouble with this?
>>
>> Type From Schema:
>>
>>                      <xs:complexType name="Xxx">
>>                               <xs:complexContent>
>>                                       <xs:extension base="tns:Base">
>>                                               <xs:sequence>
>>                                                       <xs:element
>> minOccurs="1"
>>
>> name="a"
>> nillable="false" type="xs:boolean" />
>>                                                       <xs:element
>> minOccurs="1"
>>
>> name="b"
>> nillable="false" type="xs:boolean" />
>>                                               </xs:sequence>
>>                                       </xs:extension>
>>                               </xs:complexContent>
>>                     </xs:complexType>
>>
>> ------------------------------------------------------------------------
>> ------------------------------------------------------------------------
>> -----
>>
>> XML Generated:
>>
>> <?xml version="1.0"?>
>> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
>> xmlns:ns0="http://mdc.com">
>> <env:Body>
>>   <ns0:createXxxRequest>
>>     <ns0:xxx xsi:type="ns0:Xxx">
>>       <ns0:name>xxx</ns0:name>
>>     </ns0:xxx>
>>   </ns0:createXxxRequest>
>> </env:Body>
>> </env:Envelope>
>>
>> ------------------------------------------------------------------------
>> ------------------------------------------------------------------------
>> -----
>>
>> Exception In Log:
>>
>> INFO: Interceptor has thrown exception, unwinding now
>> org.apache.cxf.interceptor.Fault: Unmarshalling Error:
>> UndeclaredPrefix:
>> Cannot resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not  
>> declared.
>>       at
>> org
>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>> a:643)
>>       at
>> org
>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>> a:555)
>>       at
>> org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:64)
>>       at
>> org
>> .apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLite
>> ralInInterceptor.java:183)
>>       at
>> org
>> .apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC
>> hain.java:221)
>>       at
>> org
>> .apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiati
>> onObserver.java:78)
>>       at
>> org
>> .apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestin
>> ation.java:92)
>>       at
>> org
>> .apache.cxf.transport.servlet.ServletController.invokeDestination(Ser
>> vletController.java:279)
>>       at
>> org
>> .apache.cxf.transport.servlet.ServletController.invoke(ServletControl
>> ler.java:161)
>>       at
>> org
>> .apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFSe
>> rvlet.java:174)
>>       at
>> org
>> .apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFSe
>> rvlet.java:152)
>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
>>       at
>> org
>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
>> tionFilterChain.java:252)
>>       at
>> org
>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
>> erChain.java:173)
>>       at
>> org
>> .jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilte
>> r.java:96)
>>       at
>> org
>> .apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
>> tionFilterChain.java:202)
>>       at
>> org
>> .apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
>> erChain.java:173)
>>       at
>> org
>> .apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
>> e.java:213)
>>       at
>> org
>> .apache.catalina.core.StandardContextValve.invoke(StandardContextValv
>> e.java:178)
>>       at
>> org
>> .jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAs
>> sociationValve.java:175)
>>       at
>> org
>> .jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.j
>> ava:74)
>>       at
>> org
>> .apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
>> :126)
>>       at
>> org
>> .apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
>> :105)
>>       at
>> org
>> .jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnecti
>> onValve.java:156)
>>       at
>> org
>> .apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
>> java:107)
>>       at
>> org
>> .apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1
>> 48)
>>       at
>> org
>> .apache.coyote.http11.Http11Processor.process(Http11Processor.java:86
>> 9)
>>       at
>> org.apache.coyote.http11.Http11BaseProtocol
>> $Http11ConnectionHandler.proc
>> essConnection(Http11BaseProtocol.java:664)
>>       at
>> org
>> .apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint
>> .java:527)
>>       at
>> org
>> .apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorker
>> Thread.java:112)
>>       at java.lang.Thread.run(Thread.java:619)
>> Caused by: javax.xml.bind.UnmarshalException
>> - with linked exception:
>> [org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot resolve
>> 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.]
>>       at
>> com
>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamEx
>> ception(UnmarshallerImpl.java:396)
>>       at
>> com
>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
>> arshallerImpl.java:335)
>>       at
>> com
>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unma
>> rshallerImpl.java:312)
>>       at
>> org
>> .apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.jav
>> a:628)
>>       ... 31 more
>> Caused by: org.xml.sax.SAXParseException: UndeclaredPrefix: Cannot
>> resolve 'ns0:Xxx' as a QName: the prefix 'ns0' is not declared.
>>       at
>> org
>> .apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unkno
>> wn Source)
>>       at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
>> Source)
>>       at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>> Source)
>>       at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
>> Source)
>>       at
>> org.apache.xerces.impl.xs.XMLSchemaValidator
>> $XSIErrorReporter.reportErro
>> r(Unknown Source)
>>       at
>> org 
>> .apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown
>> Source)
>>       at
>> org
>> .apache.xerces.impl.xs.XMLSchemaValidator.getAndCheckXsiType(Unknown
>> Source)
>>       at
>> org
>> .apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
>> Source)
>>       at
>> org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
>> Source)
>>       at
>> org
>> .apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unkn
>> own Source)
>>       at
>> com
>> .sun.xml.bind.v2.runtime.unmarshaller.ValidatingUnmarshaller.startEle
>> ment(ValidatingUnmarshaller.java:73)
>>       at
>> com
>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStart
>> Element(StAXStreamConnector.java:238)
>>       at
>> com
>> .sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAX
>> StreamConnector.java:172)
>>       at
>> com
>> .sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(Unm
>> arshallerImpl.java:333)
>>       ... 33 more
>
> ---
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>
>
>
>
>
>
>

---
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog