You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (JIRA)" <ji...@apache.org> on 2009/10/05 19:02:31 UTC

[jira] Resolved: (CXF-2168) IllegalAnnotationException on Collection properties, Getter must return "Collection", Setter must take "List" as parameter

     [ https://issues.apache.org/jira/browse/CXF-2168?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Beryozkin resolved CXF-2168.
-----------------------------------

    Resolution: Won't Fix

It's a JAXB issue. CXF 2.2.3 will log much more informative JAXB warnings so such issues should be easier to resolve

> 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.