cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: Re: Question about ReaderInterceptor
Date Thu, 08 Aug 2013 19:56:27 GMT
Hi

I guess ReaderInterceptors are really for decorating the input and if 
really needed blocking MBRs, but I don't think they are meant to replace 
MBRs which is where you will deal with the actual reading.

Cheers, Sergey
On 07/08/13 04:41, 芷樱~ wrote:
> Hi,
> Thank you very much for your help.
> I just wondering if I have to use JAXBContext in a ReaderInterceptor?
> Can I use ReaderInterceptor for just I/O operation?
> In the document, jsr339-jaxrs-2.0-final-spec, there is an example about
> ReaderInterceptor (page 40):
> @Provider
> class GzipInterceptor implements ReaderInterceptor{
>
> @Override
> Object aroundReadFrom(ReaderInterceptorContext ctx) ... {
> if (isGzipped(ctx)) {
> InputStream old = ctx.getInputStream();
> ctx.setInputStream(new GZIPInputStream(old));
> try {
> return ctx.proceed();
> } finally {
> ctx.setInputStream(old);
> }
> } else {
> return ctx.proceed();
> }
> }
> ...
> }
> Can I use ReaderInterceptor like this example?
> Could you please give me some advice?
> Thank you very much!
> Sincerely,
> Di Ma
> ------------------ 原始邮件 ------------------
> *发件人:* "Sergey Beryozkin"<sberyozkin@gmail.com>;
> *发送时间:* 2013年8月6日(星期二) 晚上11:30
> *收件人:* "users"<users@cxf.apache.org>;
> *抄送:* "芷樱~"<105634105@qq.com>;
> *主题:* Re: Question about ReaderInterceptor
>
> Hi
>
> Please try the latest 2.7.7-SNAPSHOT, Dan did some related updates to
> WS-A related code which might help resolving your issue
>
> Cheers, Sergey
> On 06/08/13 10:36, Sergey Beryozkin wrote:
>  > Hi
>  >
>  > This is something to do WS-Addressing related JAXBContext
>  > initialization, as per the trace below, which can only happen on the WS
>  > call.
>  > Do you have some WS-to-RS or RS-to-WS bridge ?
>  > org.apache.cxf.ws.addressing.v200408.Relationship needs to be resolved
>  > somehow (I can see it the generated sources).
>  >
>  > Cheers, Sergey
>  >
>  > On 06/08/13 03:27, 芷樱~ wrote:
>  >> Hi,
>  >>
>  >>   I am trying to use ReaderInterceptor, but it seems like it does not
>  >> work at all, because it even does not work for println();
>  >>
>  >>   I use apache-cxf-2.7.5,apache-tomcat-6.0.37, Java 6, and set up the
>  >> ReaderInterceptor as Provider in Spring, Bean.xml.
>  >>
>  >>   This is my code:
>  >>
>  >>    @Override
>  >>   public Object aroundReadFrom(ReaderInterceptorContext arg0)
>  >>     throws IOException, WebApplicationException {
>  >>    System.out.println("This is from ReaderInterceptor.");
>  >>    return arg0.proceed();
>  >>   }
>  >>
>  >>   And there is no message showed.
>  >>
>  >>   Also, if I try to call the arg0.getHeaders(), there will shows error:
>  >>   Throwable occurred: java.lang.IllegalStateException
>  >>          at
>  >>
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1597)
>  >>
>  >>          at
>  >>
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
>  >>
>  >>          at java.lang.Class.getDeclaredMethodsImpl(Native Method)
>  >>          at java.lang.Class.getDeclaredMethods(Class.java:748)
>  >>          at
>  >> com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.getDeclare
>  >> dMethods(ReflectionNavigator.java:262)
>  >>          at
>  >> com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.getDeclare
>  >> dMethods(ReflectionNavigator.java:59)
>  >>          at
>  >>
> com.sun.xml.internal.bind.v2.model.impl.RegistryInfoImpl.<init>(RegistryInfoImpl.java:93)
>  >>
>  >>          at
>  >> com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.addRegistry(Mode
>  >> lBuilder.java:358)
>  >>          at
>  >> com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getTypeInfo(Mode
>  >> lBuilder.java:328)
>  >>          at
>  >> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(J
>  >> AXBContextImpl.java:444)
>  >>          at
>  >>
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:291)
>  >>
>  >>          at
>  >>
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1128)
>  >>
>  >>          at
>  >>
> com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:181)
>  >>
>  >>          at
>  >>
> com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:134)
>  >>
>  >>          at
>  >>
> com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:229)
>  >>
>  >>          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  >>          at
>  >>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
>  >>
>  >>          at
>  >>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>  >>
>  >>          at java.lang.reflect.Method.invoke(Method.java:611)
>  >>          at
>  >> javax.xml.bind.ContextFinder.newInstanceContextFinder.java:139)
>  >>          at javax.xml.bind.ContextFinder.find(ContextFinder.java:301)
>  >>          at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:383)
>  >>          at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:348)
>  >>          at
>  >> org.apache.cxf.ws.addressing.VersionTransformerNames200408.getJAXBCo
>  >> ntext(VersionTransformer.java:543)
>  >>          at
>  >> org.apache.cxf.ws.addressing.VersionTransformer.getExposedJAXBContext
>  >> (VersionTransformer.java:482)
>  >>          at
>  >>
> org.apache.cxf.ws.addressing.soap.MAPCodec.unmarshalMAPs(MAPCodec.java:488)
>  >>
>  >>          at
>  >> org.apache.cxf.ws.addressing.soap.MAPCodec.decode(MAPCodec.java:674)
>  >>          at
>  >> org.apache.cxf.ws.addressing.soap.MAPCodec.mediate(MAPCodec.java:171)
>  >>           at
>  >>
> org.apache.cxf.ws.addressing.soap.MAPCodec.handleMessage(MAPCodec.java:121)
>  >>
>  >>          at
>  >>
> org.apache.cxf.ws.addressing.soap.MAPCodec.handleMessage(MAPCodec.java:78)
>  >>
>  >>          at
>  >>
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
>  >>
>  >>          at
>  >>
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
>  >>
>  >>          at
>  >>
> org.apache.cxf.transport.udp.UDPDestination$MCastListener$2.run(UDPDestination.java:106)
>  >>
>  >>          at
>  >>
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428)
>  >>
>  >>          at
>  >>
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:908)
>  >>
>  >>          at
>  >>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:931)
>  >>
>  >>          at
>  >>
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353)
>  >>
>  >>          at java.lang.Thread.run(Thread.java:773)
>  >> Exception in thread "default-workqueue-9"
>  >> ava.lang.NoClassDefFoundError:
>  >> org.apache.cxf.ws.addressing.v200408.Relationship
>  >>          at java.lang.Class.getDeclaredMethodsImpl(Native Method)
>  >>          at java.lang.Class.getDeclaredMethods(Class.java:748)
>  >>          at
>  >> com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.getDeclare
>  >> dMethods(ReflectionNavigator.java:262)
>  >>          at
>  >> com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.getDeclare
>  >> dMethods(ReflectionNavigator.java:59)
>  >>          at
>  >>
> com.sun.xml.internal.bind.v2.model.impl.RegistryInfoImpl.<init>(RegistryInfoImpl.java:93)
>  >>
>  >>          at
>  >> com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.addRegistry(Mode
>  >> lBuilder.java:358)
>  >>          at
>  >> com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getTypeInfo(Mode
>  >> lBuilder.java:328)
>  >>          at
>  >> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(J
>  >> AXBContextImpl.java:444)
>  >>          at
>  >>
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:291)
>  >>
>  >>          at
>  >>
> com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1128)
>  >>
>  >>          at
>  >>
> com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:181)
>  >>
>  >>          at
>  >>
> com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:134)
>  >>
>  >>          at
>  >>
> com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:229)
>  >>
>  >>          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  >>          at
>  >> sun.reflect.NativeMethodAccessorImpl.invokeNativeMethodAccessorImpl.
>  >> java:60)
>  >>          at
>  >>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>  >>
>  >>          at java.lang.reflect.Method.invoke(Method.java:611)
>  >>          at
>  >> javax.xml.bind.ContextFinder.newInstanceContextFinder.java:139)
>  >>          at javax.xml.bind.ContextFinder.find(ContextFinder.java:301)
>  >>          at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:383)
>  >>          at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:348)
>  >>          at
>  >>
> org.apache.cxf.ws.addressing.VersionTransformer$Names200408.getJAXBContext(VersionTransformer.java:543)
>  >>
>  >>          at
>  >> org.apache.cxf.ws.addressing.VersionTransformer.getExposedJAXBContext
>  >> (VersionTransformer.java:482)
>  >>          at
>  >>
> org.apache.cxf.ws.addressing.soap.MAPCodec.unmarshalMAPs(MAPCodec.java:488)
>  >>
>  >>          at
>  >> org.apache.cxf.ws.addressing.soap.MAPCodec.decode(MAPCodec.java:674)
>  >>          at
>  >> org.apache.cxf.ws.addressing.soap.MAPCodec.mediate(MAPCodec.java:171)
>  >>           at
>  >>
> org.apache.cxf.ws.addressing.soap.MAPCodec.handleMessage(MAPCodec.java:121)
>  >>
>  >>          at
>  >> org.apache.cxf.ws.addressing.soap.MAPCodec.handleMessage(MAPCodec.jav
>  >> a:78)
>  >>          at
>  >> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
>  >> orChain.java:271)
>  >>          at
>  >>
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
>  >>
>  >>          at
>  >>
> org.apache.cxf.transport.udp.UDPDestination$MCastListener$2.run(UDPDestination.java:106)
>  >>
>  >>          at
>  >>
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428)
>  >>
>  >>          at
>  >>
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:908)
>  >>
>  >>          at
>  >>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:931)
>  >>
>  >>          at
>  >>
> org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353)
>  >>
>  >>          at java.lang.Thread.run(Thread.java:773)
>  >> Caused by: java.lang.ClassNotFoundException:
>  >> org.apache.cxf.ws.addressing.v200408.Relationship
>  >>          at
>  >>
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
>  >>
>  >>          at
>  >>
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
>  >>
>  >>          ... 36 more
>  >>
>  >>   I am not sure what the problem is. Could you please give me some
>  >> advice?
>  >>
>  >>   Thank you very much!
>  >>
>  >>   Sincerely,
>  >>
>  >>   Di Ma
>  >>   105634105@qq.com
>  >>
>  >
>  >
>  > -
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Mime
View raw message