You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Grzegorz Grzybek (JIRA)" <ji...@apache.org> on 2013/09/30 11:11:24 UTC

[jira] [Comment Edited] (CXF-5254) Unmarshall exception if a sequence is used in a struct.

    [ https://issues.apache.org/jira/browse/CXF-5254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13781692#comment-13781692 ] 

Grzegorz Grzybek edited comment on CXF-5254 at 9/30/13 9:09 AM:
----------------------------------------------------------------

All the problems are explained with this diff (against {{3.0.0-SNAPSHOT}}):
{noformat}
diff --git a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaStructEventProducer.java b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaStructEventProducer.java
index f4b1304..e07975e 100644
--- a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaStructEventProducer.java
+++ b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaStructEventProducer.java
@@ -52,8 +52,7 @@ public class CorbaStructEventProducer extends AbstractStartEndEventProducer {
                 && (CorbaHandlerUtils.isPrimitiveIDLTypeSequence(obj))
                 && (!((CorbaSequenceHandler)obj).getElements().isEmpty())
                 && (!CorbaHandlerUtils.isOctets(obj.getType()))) {
-                currentEventProducer =
-                    new CorbaPrimitiveSequenceEventProducer(obj, serviceInfo, orb);
+                currentEventProducer = new CorbaSequenceEventProducer(obj, serviceInfo, orb);
             } else if (obj.getSimpleName().equals(obj.getIdlType().getLocalPart() + "_f")) {
                 //some "special cases" we need to make sure are mapped correctly
{noformat}

the problem is that when the {{obj}} becomes {{CorbaSequenceHandler}}, the _special case_ creates {{CorbaPrimitiveSequenceEventProducer}} which skips the "s1" event for the sequence contained in "deep" struct. In consequence JAXB complains about illegal "item" element when it expected one of "deep/id" and "deep/s1" - handler for s1 doesn't produce necessary wrapper element for the sequence.

I've extended the {{repro.idl}}:
{code}
...
	struct Deep2 { 
		Strings s2;
	};
	struct Deeper {
		long id;
		Deep deep; 
		Deep2 deep2; 
	};
{code}
to check what is the _special case_ when struct contains the sequence *only*. In that case "s2" element also should cause the event to be produced.

So I think it's enough to create {{CorbaSequenceEventProducer}} instead of {{CorbaPrimitiveSequenceEventProducer}}. Unless someone (Daniel Kulp) explains what was that "Special case for primitive sequence inside struct" for.

regards
Grzegorz Grzybek


was (Author: gzres):
All the problems are explained with this diff (against {{3.0.0-SNAPSHOT}}):
{noformat}
diff --git a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaStructEventProducer.java b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaStructEventProducer.java
index f4b1304..e07975e 100644
--- a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaStructEventProducer.java
+++ b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/types/CorbaStructEventProducer.java
@@ -52,8 +52,7 @@ public class CorbaStructEventProducer extends AbstractStartEndEventProducer {
                 && (CorbaHandlerUtils.isPrimitiveIDLTypeSequence(obj))
                 && (!((CorbaSequenceHandler)obj).getElements().isEmpty())
                 && (!CorbaHandlerUtils.isOctets(obj.getType()))) {
-                currentEventProducer =
-                    new CorbaPrimitiveSequenceEventProducer(obj, serviceInfo, orb);
+                currentEventProducer = new CorbaSequenceEventProducer(obj, serviceInfo, orb);
             } else if (obj.getSimpleName().equals(obj.getIdlType().getLocalPart() + "_f")) {
                 //some "special cases" we need to make sure are mapped correctly
{noformat}

the problem is that when the {{obj}} becomes {{CorbaSequenceHandler}}, the _special case_ creates {{CorbaPrimitiveSequenceEventProducer}} which skips the "s1" event for the sequence contained in "deep" struct. In consequence JAXB complains about illegal "item" element when it expected one of "deep/id" and "deep/s1" - handler for s1 doesn't produce necessary wrapper element for the sequence.

I've extended the {{repro.idl}}:
{code}
...
	struct Deep2 { 
		Strings s2;
	};
	struct Deeper {
		long id;
		Deep deep; 
		Deep2 deep2; 
	};
{code}
to check what is the _special case_ when struct contains the sequence *only*. In that case "s2" element also should be cause the event to be produced.

So I think it's enough to create {{CorbaSequenceEventProducer}} instead of {{CorbaPrimitiveSequenceEventProducer}}. Unless someone (Daniel Kulp) explains what was that "Special case for primitive sequence inside struct" for.

regards
Grzegorz Grzybek

> Unmarshall exception if a sequence<string> is used in a struct.
> ---------------------------------------------------------------
>
>                 Key: CXF-5254
>                 URL: https://issues.apache.org/jira/browse/CXF-5254
>             Project: CXF
>          Issue Type: Bug
>          Components: CORBA Binding
>    Affects Versions: 2.7.5, 2.7.6
>         Environment: JAVA7 / Windows 7
>            Reporter: Juergen Bockhorn
>            Priority: Blocker
>         Attachments: CorbaBugRepro.zip
>
>
> A server function returns a struct. This struct contains another struct which contains a sequence<string>. Calling this method with a CXF/Corba-Client leads to an unmarshall exception:
> {code}
> Warnung: Interceptor for {http://cxf.apache.org/bindings/corba/idl/repro}repro.ServiceCORBAService#{http://cxf.apache.org/bindings/corba/idl/repro}getFirst has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Unmarshalling Error: unerwartetes Element (URI:"", lokal:"item"). Erwartete Elemente sind <{http://cxf.apache.org/bindings/corba/idl/repro}id>,<{http://cxf.apache.org/bindings/corba/idl/repro}s1> 
> 	at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:808)
> 	at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:629)
> 	at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:157)
> 	at org.apache.cxf.interceptor.BareInInterceptor.handleMessage(BareInInterceptor.java:138)
> ...
> {code}
> (sorry for german).
> Using a pure CORBA-client works.
> I will attach a repro project to this issue if I have figured out how it works :-)



--
This message was sent by Atlassian JIRA
(v6.1#6144)