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

VividApp On Software commented on CXF-2168:
-------------------------------------------

The basicdetails interface:

package com.webauditer.remote.dto;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="basicdetails")
public class Basicdetails implements Record {
        private String planId;
        private String planName;
        private int maxPages;
        private String browserType;
        private boolean javascriptEnabled;
        
        public String getPlanName() {
                return planName;
        }
        public void setPlanName(String name) {
                this.planName = name;
        }
        public int getMaxPages() {
                return maxPages;
        }
        public void setMaxPages(int maxPages) {
                this.maxPages = maxPages;
        }
        public String getBrowserType() {
                return browserType;
        }
        public void setBrowserType(String browserType) {
                this.browserType = browserType;
        }
        public boolean isJavascriptEnabled() {
                return javascriptEnabled;
        }
        public void setJavascriptEnabled(boolean javascriptEnabled) {
                this.javascriptEnabled = javascriptEnabled;
        }
        public String getPlanId() {
                return planId;
        }
        public void setPlanId(String planId) {
                this.planId = planId;
        }
        
}



> IllegalAnnotationException on Collection properties, Getter must return 
> "Collection", Setter must take "List" as parameter
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-2168
>                 URL: https://issues.apache.org/jira/browse/CXF-2168
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>         Environment: jax-rs
>            Reporter: VividApp On Software
>            Priority: Critical
>
> Problem is with jaxb in relation to jax-rs.
> This problem is excruciatingly annoying and has resulted in days of wasted 
> time, almost to the point of giving up!!
> I am marking this as Critical, as I think it will drive people away from 
> using CXF jax-rs if they encounter this problem.
> Getting some very strange behaviour with Collection properties if I do not do 
> the following.
> - The Getter must a type of "Collection"
> - The Setter parameter must be a "List".
> If both Getter and Setter are consistent and both return either a Collection 
> or a List, an IllegalAnnotationException occurs (See Debug output below).
> ie. One must return a Collection, and the other must take a List.
> I get this if I annotate with @XmlElementRefs and also with @XmlAnyElement 
> (coupled with @XmlSeeAlso)
> I don't think this is a problem with the jaxb-api, as I also tried it with 
> jaxb 2.0
> I have included my Maven dependency at the bottom.
> ############################
> My code is as follows:
> @XmlRootElement(name = "data")
> // @XmlSeeAlso({Echo.class, Basicdetails.class, UrlDescriptor.class})
> public class Data {
>       
>       // @XmlAnyElement(lax = true)
>       @XmlElementRefs({
>          @XmlElementRef(name = "basicdetails", type = Basicdetails.class),
>          @XmlElementRef(name = "urldescriptor", type = UrlDescriptor.class),
>          @XmlElementRef(name = "echo", type = Echo.class)
>      })
>       private Collection<Record> records;
>       public Data() {
>       }
>       public Data(final Record record) {
>               addRecord(record);
>       }
>       public Collection<Record> getRecords() {
>               return records;
>       }
>         /**
>         * THIS MUST TAKE A LIST, EXCEPTIONS OTHERWISE, EVEN THOUGH GETTER IS 
> RETURNING "Collection"
>        */
>       public void setRecords(final List<Record> records) {
>               this.records = records;
>       }
>       
>       public void addRecord(final Record record) {
>               if (this.records == null) {
>                       setRecords(new ArrayList<Record>());
>               }
>               getRecords().add(record);
>       }
> }
> ########################################################
> DEBUG OUTPUT:
> Content-Type: text/xml
> Headers: {content-length=[748], accept-encoding=[gzip, deflate], 
> cache-control=[no-cache], connection=[Keep-Alive], 
> referer=[http://localhost:8888/com.webauditor.sanity.app.SanityApplication/SanityApplication.html],
>  host=[localhost:8888], accept-language=[en-gb], user-agent=[Mozilla/4.0 
> (compatible; MSIE 7.0; Windows NT 5.1; GTB5; .NET CLR 1.1.4322; .NET CLR 
> 2.0.50727)], ua-cpu=[x86], content-type=[text/xml], Accept=[*/*]}
> Payload: 
> <request>
>     <data>
>         <basicdetails>
>             <startUrl>http://</startUrl>
>             <maxPages>100</maxPages>
>             <javascriptEnabled>true</javascriptEnabled>
>             <browserType>Internet Explorer</browserType>
>         </basicdetails>
>     </data>
>     <oldValues>
>         <startUrl>http://</startUrl>
>         <maxPages>100</maxPages>
>         <javascriptEnabled>true</javascriptEnabled>
>         <browserType>Firefox</browserType>
>     </oldValues>
>     <dataSource>basicdetails</dataSource>
>     <operationType>update</operationType>
>     <operationId></operationId>
>     <startRow></startRow>
>     <endRow></endRow>
>     <sortBy></sortBy>
>     <textMatchStyle></textMatchStyle>
>     <componentId>basicdetails</componentId>
> </request>
> --------------------------------------
> 1
> Submitting current
> SAVING EDITS
> 1
> Submitting current
> SAVING EDITS
> 1
> Submitting current
> SAVING EDITS
> 10-Apr-2009 18:21:06 org.apache.cxf.jaxrs.provider.AbstractJAXBProvider 
> handleJAXBException
> WARNING: JAXBException occurred : 3 counts of IllegalAnnotationExceptions
> 10-Apr-2009 18:21:06 org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper 
> toResponse
> WARNING: WebApplicationException has been caught : 3 counts of 
> IllegalAnnotationExceptions
> 10-Apr-2009 18:21:06 
> org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
> INFO: Outbound Message
> ---------------------------
> Encoding: 
> Content-Type: text/plain
> Headers: {Content-Type=[text/plain]}
> Payload: JAXBException occurred : 3 counts of IllegalAnnotationExceptions
> --------------------------------------
> 10-Apr-2009 18:21:06 
> org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
> INFO: Outbound Message
> ---------------------------
> Encoding: 
> Content-Type: text/plain
> Headers: {Content-Type=[text/plain]}
> Payload: JAXBException occurred : 3 counts of IllegalAnnotationExceptions
> --------------------------------------
> #############################################################
> MAVEN SETUP
>       <dependencies>
>               <dependency>
>                       <groupId>javax.ws.rs</groupId>
>                       <artifactId>jsr311-api</artifactId>
>                       <version>1.0</version>
>               </dependency>
>               <dependency>
>                       <groupId>org.apache.cxf</groupId>
>                       <artifactId>cxf-bundle-jaxrs</artifactId>
>                       <version>2.2</version>
>                       <exclusions>
>                               <exclusion>
>                                       <groupId>org.springframework</groupId>
>                                       <artifactId>spring-context</artifactId>
>                               </exclusion>
>                               <exclusion>
>                                       <groupId>org.springframework</groupId>
>                                       <artifactId>spring-beans</artifactId>
>                               </exclusion>
>                               <exclusion>
>                                       <groupId>org.springframework</groupId>
>                                       <artifactId>spring-core</artifactId>
>                               </exclusion>
>                               <exclusion>
>                                       <groupId>org.apache.abdera</groupId>
>                                       <artifactId>abdera-i18n</artifactId>
>                               </exclusion>
>                               <exclusion>
>                                       <groupId>org.apache.abdera</groupId>
>                                       <artifactId>abdera-extensions-main
>                                       </artifactId>
>                               </exclusion>
>                               <exclusion>
>                                       <groupId>org.apache.abdera</groupId>
>                                       <artifactId>abdera-extensions-json
>                                       </artifactId>
>                               </exclusion>
>                               <exclusion>
>                                       <groupId>org.apache.abdera</groupId>
>                                       <artifactId>abdera-core
>                                       </artifactId>
>                               </exclusion>
>                               <exclusion>
>                                       <groupId>org.apache.abdera</groupId>
>                                       <artifactId>abdera-parser
>                                       </artifactId>
>                               </exclusion>
>                       </exclusions>
>               </dependency>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to