7 Replies Latest reply on Jun 14, 2009 9:48 AM by lorinda visnick

    Problem with SWA  (soap + attachments)  and  DataHandler

    Marcel Casado Novice

      Hi,

       

      When I'm trying to deploy an osgi CXF service (wsdl first ) with attachments (swa) deployed on FUSE 4 . I got the exception below:

       

      Caused by: org.apache.cxf.service.factory.ServiceConstructionException

           at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:280)

           at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:340)

           at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:436)

           at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:194)

           at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:164)

           at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:100)

           at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:117)

           at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:168)

           at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:346)

           at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:259)

           ... 26 more

      Caused by: javax.xml.bind.JAXBException: Unable to create context

      - with linked exception:

           at javax.xml.bind.ContextFinder.find(ContextFinder.java:93)

           at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:65)

           at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:437)

           at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:263)

           ... 35 more

      Caused by: java.lang.reflect.InvocationTargetException

           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:597)

           at javax.xml.bind.ContextFinder.find(ContextFinder.java:91)

           ... 38 more

      Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions

      javax.activation.DataHandler does not have a no-arg default constructor.

           this problem is related to the following location:

                at javax.activation.DataHandler

                at public javax.xml.bind.JAXBElement org.apache.cxf.swa.types.ObjectFactory.createHtmlAttach(javax.activation.DataHandler)

                at org.apache.cxf.swa.types.ObjectFactory

       

           at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)

           at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:438)

           at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:286)

           at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:139)

           at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:117)

           ... 43 more

       

       

      The method ObjectFactory method created by wsdl2java (xjc)  :

        /**

            

      • Create an instance of {@link JAXBElement }{@code <}{@link DataHandler }{@code >}}

            

           */

          @XmlElementDecl(namespace = "http://cxf.apache.org/swa/types", name = "HTMLAttach")

          @XmlMimeType("text/html")

          public JAXBElement(_HtmlAttach_QNAME, DataHandler.class, null, value);

          }

       

       

      Thanks,

       

      -Marcel

       

      Edited by: marcelcasado on May 29, 2009 10:16 PM

       

      Edited by: marcelcasado on May 29, 2009 10:18 PM

       

      Edited by: marcelcasado on May 31, 2009 7:33 PM

        • 1. Re: Problem with SWA  (soap + attachments)  and  DataHandler
          lorinda visnick Newbie

          Marcel,

             is this forum thread related to thread id 892 (and 909)?

           

          ThreadID 909 seemingly just has this title (and no body):

          Thread: javax.activation.DataHandler does not have a no-arg default constructor

           

          ThreadID892 has exchanges between you and Ulhas about an example for what you are wishing to implement (possibly you are hitting cxf-1146).

           

          If this thread is meant to be something different from ThreadID892, please clarify.  Did you get past the problems in 892 and now you are hitting this new problem?

           

          Thank you,

          Lorinda

          • 2. Re: Problem with SWA  (soap + attachments)  and  DataHandler
            Marcel Casado Novice

            Hi Lorinda,

             

            Thread 909 is the same that this one. Sorry about that but it looks like your forum app does not work very well with Safari and the upload of attachments. So after I tried to post the message with attachments in Safari it showed like it is now. It can be removed if it's you think so.

             

            Thread 892 is a different thread that I got past after a lot of effort and I believe the test samples has some bugs that I reported on that thread. After I  was able to put together a working wsdl with SWA (soap + attachments not MTOM) attachments and build it with maven as an OSGI CXF service (wsdl first) so the service code is all generated by wsdl2java I tried to deploy it on FUSE 4 where I already have successfully deployed other CXF services (no attachments) but in this case is throwing the exception when initializes the spring context and JAXB context.

             

            Thanks,

             

            -Marcel

             

            Edited by: marcelcasado on Jun 2, 2009 5:49 PM

            • 3. Re: Problem with SWA  (soap + attachments)  and  DataHandler
              lorinda visnick Newbie

              Marcel,

                  

              a question: why are you using soap + attachments instead of MTOM?

               

              a request: can you attach your whole project so I can build it here and try to reproduce the problem you are seeing?

               

              Thank you

              Lorinda

              • 4. Re: Problem with SWA  (soap + attachments)  and  DataHandler
                Marcel Casado Novice

                Lorinda,

                 

                I'm trying to use soap with attachments and I'm not pretty sure about this because our wsdl and schemas from a the third party specification does not contain an element with type="xsd:base64Binary" on the response so I will have to add a part to the response message and wrapped with " <mime:multipartRelated>" on the wsdl bindings.

                The  service request has a parameter to determine if the data has to be send back as an attachment or not. If not then there is an element where you specify the URL for downloading the data but it says that you have to send the data as an attachment in the other case but there is not a type="xsd:base64Binary" element on the response for that to use MTOM so I suppose the only way is swa and use the link for the cid: .

                 

                A little excerpt of the OGC WCS specs are in the previous thread 892. Please let me know if I'm wrong.

                 

                I jared the project up and uploaded a modified version of the project so it builds for you but there is still a little problem :

                 

                In lines 100 and 102 on generated class "SwAServiceInterface_SwAServiceHttpPort_Client"  on package org.apache.cxf.swa it generates code like new java.awt.Image(); that does not compile since is not a valid constructor. I changed it to ImageIO.read(new URL(""));  . So if you do a clean install you will have to fix this every time unless you turn off client code generation. I suppose that can be considered a bug.

                 

                 

                Thanks for looking in to this, I have no idea what is wrong or how to get around it.

                 

                -Marcel

                 

                Edited by: marcelcasado on Jun 2, 2009 10:38 PM

                • 5. Re: Problem with SWA  (soap + attachments)  and  DataHandler
                  lorinda visnick Newbie

                  Marcel,

                     can you pls tell me exactly how you are trying to do the deploy?  Hotdeploy or osgi/install?  if osgi/install, pls paste your install command so I can run it here exactly as you are.

                   

                  Tx

                  Lorinda

                  • 6. Re: Problem with SWA  (soap + attachments)  and  DataHandler
                    Marcel Casado Novice

                    Lorinda,

                     

                    I use  osgi "install -s mvn:com.your.group/swa-cxf". And this time the bundle started  fine for me also with the version of the project I gave you. The difference is in the real project I try to use jaxb extension plugins to improve the generated Jaxb classes to have methods like equals and hashCode, etc. The jaxb ext. plugins run after the wsdl2java plugin  and generate the jaxb binding classes again with the additional stuff. So it looks like for some reason this produces the exception I sent originally. I can not send you the pom with this plugin extensions because I had to install them on maven manually since they are not in any repository and it will not work for you. 

                     

                    I tried to test the soap+attachment operations with soapUI and there are some of them that they not work :

                     

                    "echoAllAttachmentTypes" operation for swa and swa-nomime endpoint does not work

                     

                    For swa-nomime endpoint I got :

                     

                    org.apache.cxf.interceptor.Fault: org.apache.cxf.attachment.DelegatingInputStream cannot be cast to java.lang.String

                         at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:148)

                         at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:83)

                         at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:114)

                         at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:55)

                         at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:68)

                         at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:57)

                         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

                         at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

                         at java.util.concurrent.FutureTask.run(FutureTask.java:138)

                         at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)

                         at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:95)

                         at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)

                         at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:89)

                         at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:302)

                         at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:265)

                         at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70)

                         at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)

                         at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)

                         at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)

                         at org.mortbay.jetty.Server.handle(Server.java:324)

                         at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)

                         at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:879)

                         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:741)

                         at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:213)

                         at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:403)

                         at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)

                         at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:522)

                    Caused by: java.lang.ClassCastException: org.apache.cxf.attachment.DelegatingInputStream cannot be cast to java.lang.String

                         at org.apache.cxf.swa_nomime.SwAServiceInterfaceImpl.echoAllAttachmentTypes(SwAServiceInterfaceImpl.java:57)

                         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:597)

                         at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:166)

                         at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:82)

                         ... 24 more

                     

                     

                    For swa endpoint  : it just logs null and does not return any attachment. No exceptions.

                     

                     

                    "echoData" operation for swa endpoint does not work either  :

                     

                    It just logs null and no attachment is returned.

                     

                    I can avoid using the jaxb plugin extensions but it will be great to know why some of the operations with attachments does not work at all.

                     

                    Thanks,

                     

                    -Marcel

                    • 7. Re: Problem with SWA  (soap + attachments)  and  DataHandler
                      lorinda visnick Newbie

                      Marcel,

                         my apologies - been out of office.  You wrote:

                       

                      I changed it to ImageIO.read(new URL("")); . So if you do a clean install you will have to fix this every time unless you turn off client code generation. I suppose that can be considered a bug.

                       

                      Yes, that is a bug.   I will file one and send the number.

                       

                      You also wrote:

                      I tried to test the soap+attachment operations with soapUI and there are some of them that they not work

                       

                      It is expected that the generated code will have to be modified.  So, where you changed then invalid generated line of code

                       

                      new java.awt.Image();

                       

                      to

                       

                      ImageIO.read(new URL(""));

                       

                      that is not a valid parameter.  If I change the code to provide a real image - and do the same for each parameter and return code, then the code runs.

                       

                      Can you please try to do the same?

                      Tx

                      Lorinda