cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adrian Nistor (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CXF-1121) jaxb binding fails for property getters marked @XmlTransient if they return an array with component type that is an interface
Date Fri, 19 Oct 2007 17:39:51 GMT

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

Adrian Nistor commented on CXF-1121:
------------------------------------

Hi Daniel,
Thanks for your quick response!

The initial problem is solved but I realized only now that there are more issues in this area.
Example follows:

@XmlType
public class User  {
    ....    
    public boolean isValid(ValidationContext ctx) {...}
    ....
}

ValidationContext is an interface and thus it will fail. isValid is not a property accessor
and I have to work around this by marking it @XmlTransient, which is not very natural.

JAXBContextInitializer examines all fields and methods (excluding static and @XmlTransient).
Maybe the safest thing is to only take bean property accessors into account for the beans
that are serialized.  And if access method was set to FIELD, then no methods should be analized
at all. Of course, for the service interface itself all methods must still be examined.

I think I can spend a little time tomorrow and come up with a new fix in JAXBContextInitializer.walkReferences()
to make it treat these non-bean-property cases correctly. 

Could you please reopen the issue?

Thanks!


> jaxb binding fails for property getters marked @XmlTransient if they return an array
with component type that is an interface
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-1121
>                 URL: https://issues.apache.org/jira/browse/CXF-1121
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.0.2
>         Environment: WinXP, jdk1.5.0_09
>            Reporter: Adrian Nistor
>            Assignee: Daniel Kulp
>             Fix For: 2.0.3
>
>
> I know interfaces (and arrays of interfaces) are not handled by jaxb but these properties
should at least be ignored if marked @XmlTransient. 
> The problem appears for both field and property access mode.
> I did some investigation and this is not a jaxb issue, it is certainly caused by cxf.

> Found that org.apache.cxf.jaxb.JAXBContextInitializer gathers too many types when it
visits the service model. In my opinion it should not attempt to add to the context ALL the
classes it sees in fields and method signatures (see method JAXBContextInitializer.walkReferences).
It must check if the field or method has the @XmlTransient annotation and skip it if so. 
> I will attach a patch for JAXBContextInitializer.
> Now here is some sample code that triggers the issue. See the exception stacktrace below.
> public class User {
>     ....
>     @XmlTransient
>     public org.acegisecurity.GrantedAuthority[] getAuthorities() { ... }
>     ....
> }
> ------------------------------------------------------------------------------------------------------------------------------------------
> ERROR [main] ContextLoader.initWebApplicationContext(203) | Context initialization failed
> org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'helloWorld': Invocation of init method failed; nested exception is org.apache.cxf.service.factory.ServiceConstructionException
> Caused by:
> org.apache.cxf.service.factory.ServiceConstructionException
>         at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:199)
>         at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:244)
>         at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:272)
>         at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:146)
>         at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:89)
>         at org.apache.cxf.frontend.AbstractEndpointFactory.createEndpoint(AbstractEndpointFactory.java:83)
>         at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:107)
>         at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:147)
>         at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:287)
>         at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:227)
>         at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:179)
>         at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:340)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1240)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1205)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
>         at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
>         at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
>         at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
>         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
>         at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
>         at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
>         at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
>         at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
>         at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
>         at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
>         at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
>         at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
>         at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
>         at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
>         at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
>         at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
>         at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
>         at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
>         at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
>         at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
>         at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
>         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
>         at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
>         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
>         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
>         at org.apache.catalina.core.StandardService.start(StandardService.java:448)
>         at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
>         at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
>         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
> Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
> org.acegisecurity.GrantedAuthority is an interface, and JAXB can't handle interfaces.
>         this problem is related to the following location:
>                 at org.acegisecurity.GrantedAuthority
>                 at org.acegisecurity.GrantedAuthority[]
>         at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:66)
>         at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:389)
>         at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:236)
>         at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
>         at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:585)
>         at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:210)
>         at javax.xml.bind.ContextFinder.find(ContextFinder.java:366)
>         at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
>         at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContext(JAXBDataBinding.java:377)
>         at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:182)
>         ... 52 more

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


Mime
View raw message