Announcement Announcement Module
Collapse
No announcement yet.
how to deploy Spring WS with JaxBMarshaller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to deploy Spring WS with JaxBMarshaller

    i tried to make all the configurations as given in spring web service documentation in web.xml and spring-ws-servlet.xml for MarshallingEndpoint with JaxBMarshalling/Unmarshalling.

    I have used dynamic wsdl generation bean in spring-ws-servlet.xml

    I have no idea how to deploy it to server so that it exposes it as web service.

    By just deploying it as web application to oc4j server its not configuring it as service


    I have attached the config files....


    Somebody please help me in this issue...

  • #2
    Hi Virfal,

    Checking your configuration files, they look pretty straight forward. What is the exact error you're getting? If it is a 404 (File Not Found), this could mean that your web application was not properly deployed or you are accessing an incorrect port. However, if it is a 500 (Internal Server Error), you would have to check the SystemOut log files of your OC4J Application Server for details. You may want to post the logs and the schema as well. Remember you first need to check if you were able to generate a proper WSDL. Looking at your config files, the URL of the WSDL should be something like: http://<hostname>:<port>/<WebApplica...me>/Hello.wsdl

    Hope that helps.

    Comment


    • #3
      It was a 404(File not Found) .....so it was not getting deployed properly...i added following to web.xml and it started creating all beans in config file .......

      <listener>
      <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
      </listener>


      Still its not generating wsdl and am getting error while creating beans on deployment as following:


      Error creating bean with name 'helloEndpoint' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Cannot resolve reference to bean 'marshaller' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'marshaller' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.xml.bind.JAXBContext.newInstance([Ljava/lang/ClassLjavax/xml/bind/JAXBContext;




      I tried running application in embedded oc4j with index.jsp to get web context....then while loading application it gave same error with following more details................



      Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@1325573: defining beans [helloEndpoint,marshaller,unmarshaller,helloService ,Hello]; root of factory hierarchy
      Dec 11, 2007 10:39:43 AM org.springframework.oxm.jaxb.Jaxb2Marshaller createJaxbContextFromClasses
      INFO: Creating JAXBContext with classes to be bound [class com.beans.HelloRequest,class com.beans.HelloResponse]
      Dec 11, 2007 10:39:43 AM org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry destroySingletons
      INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@1325573: defining beans [helloEndpoint,marshaller,unmarshaller,helloService ,Hello]; root of factory hierarchy
      Dec 11, 2007 10:39:43 AM org.springframework.web.context.ContextLoader initWebApplicationContext
      SEVERE: Context initialization failed
      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'helloEndpoint' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Cannot resolve reference to bean 'marshaller' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'marshaller' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.xml.bind.JAXBContext.newInstance([Ljava/lang/ClassLjavax/xml/bind/JAXBContext;
      Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'marshaller' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.xml.bind.JAXBContext.newInstance([Ljava/lang/ClassLjavax/xml/bind/JAXBContext;
      Caused by: java.lang.NoSuchMethodError: javax.xml.bind.JAXBContext.newInstance([Ljava/lang/ClassLjavax/xml/bind/JAXBContext;
      at org.springframework.oxm.jaxb.Jaxb2Marshaller.creat eJaxbContextFromClasses(Jaxb2Marshaller.java:306)
      at org.springframework.oxm.jaxb.Jaxb2Marshaller.creat eJaxbContext(Jaxb2Marshaller.java:280)
      at org.springframework.oxm.jaxb.AbstractJaxbMarshalle r.afterPropertiesSet(AbstractJaxbMarshaller.java:1 25)
      at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1201)

      .......




      I tried different versions of JAXB libraries but its not helping it out (dont know whether its conflict between JAXB libs and spring libs having marshalling classes).....

      Without adding JAXB libs its giving me error for attachment bean in jaxb... somewhere its getting referenced from spring libs

      error is as follow:
      Cannot resolve reference to bean 'marshaller' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'marshaller' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/attachment/AttachmentUnmarshaller
      Last edited by virfal; Dec 11th, 2007, 11:34 AM.

      Comment


      • #4
        You're getting that error because your "marshaller" bean is failing to be constructed properly, so it doesn't exist to be injected into your endpoint:

        Code:
        Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'marshaller' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:
        I'm not an expert, but this is what my "marshaller" bean looks like:

        Code:
            <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
                <description>
                    The JAXB 2 Marshaller is used by the endpoints.
                </description>
                <property name="contextPath" value="com.mg21.shotgun.ws.bindings.catalog"/>
            </bean>
        Where "com.mg21.shotgun.ws.bindings.catalog" is the package to my XJC generated classes.

        Comment


        • #5
          replacing "classesToBeBound" property with "contextPath" given in ur reply...

          it started giving me different error as follow.....


          Cannot resolve reference to bean 'marshaller' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'marshaller' defined in ServletContext resource [/WEB-INF/spring-ws-servlet.xml]: Invocation of init method failed; nested exception is org.springframework.oxm.jaxb.JaxbSystemException: Unable to locate jaxb.properties for package com.mg21.shotgun.ws.bindings.catalog; nested exception is javax.xml.bind.JAXBException: Unable to locate jaxb.properties for package com.mg21.shotgun.ws.bindings.catalog

          dont know how this approach works

          Comment


          • #6
            Well, you need to change the contextPath to point to the package containing your XJC generated classes. It looks like you just copied and pasted my example without changing anything.

            Comment


            • #7
              I changed it to my package where my beans classes are there which is "com.beans" . There are no other classes generated by XJC. Even with existing annotation @XMLRootElement for each bean is it required to create classes using XJC??? just lemme know steps needs to be executed to get all the dependencies for using JAXB2Marshaller and exposing Endpoint as service.
              when i tried giving path to "com.beans" for beans classes which we need to marshall ...it gave me same error as above "Unable to locate jaxb.properties......."

              No idea where to look into to figure out the solution


              also we are using JAXB2 in other parts of application so any solution for any one out of JAXB1 or JAXB2 marshaller is fine......

              if any body have working solution as proof of concept just send it to me on [email protected]........... i need to deploy it on oc4j server



              or just tell me jaxb libs to be used which is compatible to spring libs....so that i can successfully use "classesTobeBound" property of "org.springframework.oxm.jaxb.Jaxb2Marshaller" mapping..(I found this approach very promising)....





              Thanks in advance...
              Last edited by virfal; Dec 12th, 2007, 11:11 AM.

              Comment


              • #8
                i have created shared lib in oc4j containerto place jaxb libs...and it worked....it has successfully deployed the application with following logs :


                INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@71d335: defining beans [org.springframework.ws.transport.http.WebServiceMe ssageReceiverHandlerAdapter,messageFactory,org.spr ingframework.web.servlet.handler.SimpleUrlHandlerM apping,messageDispatcher,org.springframework.ws.se rver.endpoint.adapter.GenericMarshallingMethodEndp ointAdapter,helloEndpoint,marshaller,unmarshaller, helloService,Hello]; root of factory hierarchy
                Dec 12, 2007 3:26:19 PM org.springframework.ws.soap.saaj.SaajSoapMessageFa ctory afterPropertiesSet
                INFO: Creating SAAJ 1.2 MessageFactory
                Dec 12, 2007 3:26:21 PM org.springframework.oxm.jaxb.Jaxb2Marshaller createJaxbContextFromClasses
                INFO: Creating JAXBContext with classes to be bound [class com.beans.HelloRequest,class com.beans.HelloResponse]
                Dec 12, 2007 3:26:21 PM org.springframework.oxm.jaxb.Jaxb2Marshaller createJaxbContextFromClasses
                INFO: Creating JAXBContext with classes to be bound [class com.beans.HelloRequest,class com.beans.HelloResponse]
                Dec 12, 2007 3:26:21 PM org.springframework.web.context.ContextLoader initWebApplicationContext
                INFO: Root WebApplicationContext: initialization completed in 2422 ms
                Dec 12, 2007 3:26:21 PM org.springframework.web.servlet.FrameworkServlet initServletBean
                INFO: FrameworkServlet 'spring-ws': initialization started
                Dec 12, 2007 3:26:21 PM org.springframework.context.support.AbstractApplic ationContext prepareRefresh
                INFO: Refreshing org.springframework.web.context.support.XmlWebAppl icationContext@1abfc7a: display name [WebApplicationContext for namespace 'spring-ws-servlet']; startup date [Wed Dec 12 15:26:21 EST 2007]; parent: org.springframework.web.context.support.XmlWebAppl icationContext@1ac4ca1
                Dec 12, 2007 3:26:21 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
                INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-ws-servlet.xml]
                Dec 12, 2007 3:26:21 PM org.springframework.context.support.AbstractApplic ationContext obtainFreshBeanFactory
                INFO: Bean factory for application context [org.springframework.web.context.support.XmlWebAppl icationContext@1abfc7a]: org.springframework.beans.factory.support.DefaultL istableBeanFactory@d9e285
                Dec 12, 2007 3:26:21 PM org.springframework.beans.factory.support.DefaultL istableBeanFactory preInstantiateSingletons
                INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@d9e285: defining beans [org.springframework.ws.transport.http.WebServiceMe ssageReceiverHandlerAdapter,messageFactory,org.spr ingframework.web.servlet.handler.SimpleUrlHandlerM apping,messageDispatcher,org.springframework.ws.se rver.endpoint.adapter.GenericMarshallingMethodEndp ointAdapter,helloEndpoint,marshaller,unmarshaller, helloService,Hello]; parent: org.springframework.beans.factory.support.DefaultL istableBeanFactory@71d335
                Dec 12, 2007 3:26:21 PM org.springframework.ws.soap.saaj.SaajSoapMessageFa ctory afterPropertiesSet
                INFO: Creating SAAJ 1.2 MessageFactory
                Dec 12, 2007 3:26:21 PM org.springframework.oxm.jaxb.Jaxb2Marshaller createJaxbContextFromClasses
                INFO: Creating JAXBContext with classes to be bound [class com.beans.HelloRequest,class com.beans.HelloResponse]
                Dec 12, 2007 3:26:21 PM org.springframework.oxm.jaxb.Jaxb2Marshaller createJaxbContextFromClasses
                INFO: Creating JAXBContext with classes to be bound [class com.beans.HelloRequest,class com.beans.HelloResponse]
                Dec 12, 2007 3:26:21 PM org.springframework.ws.transport.http.MessageDispa tcherServlet initWsdlDefinitions
                INFO: Published [Wsdl4jDefinition{http://www.example.org}] as Hello.wsdl
                Dec 12, 2007 3:26:21 PM org.springframework.web.servlet.FrameworkServlet initServletBean





                It shows wsdl on http://localhost:8888/SpringWS/hello...ice/Hello.wsdl as follow




                <?xml version="1.0" encoding="UTF-8" ?>
                - <definitions targetNamespace="http://www.springws.com/helloService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.springws.com/helloService" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
                - <types>
                - <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.springws.com/helloService" elementFormDefault="qualified" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
                - <element name="HelloRequest">
                - <complexType>
                - <sequence>
                <element name="inputString" type="string" />
                </sequence>
                </complexType>
                </element>
                - <element name="HelloResponse">
                - <complexType>
                - <sequence>
                <element name="resultString" type="string" />
                </sequence>
                </complexType>
                </element>
                </schema>
                </types>
                - <message name="HelloRequest">
                <part name="HelloRequest" element="tns:HelloRequest" />
                </message>
                - <message name="HelloResponse">
                <part name="HelloResponse" element="tns:HelloResponse" />
                </message>
                - <portType name="HelloWorld">
                - <operation name="Hello">
                <input name="HelloRequest" message="tns:HelloRequest" />
                <output name="HelloResponse" message="tns:HelloResponse" />
                </operation>
                </portType>
                - <binding name="HelloWorldBinding" type="tns:HelloWorld">
                <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
                - <operation name="Hello">
                <soap:operation soapAction="" />
                - <input name="HelloRequest">
                <soap:body use="literal" />
                </input>
                - <output name="HelloResponse">
                <soap:body use="literal" />
                </output>
                </operation>
                </binding>
                - <service name="HelloWorldService">
                - <port name="HelloWorldPort" binding="tns:HelloWorldBinding">
                <soap:address location="http://localhost:8888/SpringWS/helloWorldService/" />
                </port>
                </service>
                </definitions>



                but when i try to invoke this service using http://localhost:8888/SpringWS/helloWorldService it gives HTTP 404 error

                and with http://localhost:8888/SpringWS/helloWorldService/Hello it gives HTTP 405 method not allowed error.......................................dont know what the issue is



                i have attached the latest config files ....can anyone please check it out whether m missing anything to direct web service request properly or if its exposing service properly
                Last edited by virfal; Dec 12th, 2007, 05:11 PM.

                Comment


                • #9
                  and with http://localhost:8888/SpringWS/helloWorldService/Hello it gives HTTP 405 method not allowed error.......................................dont know what the issue is
                  That's the proper response to a GET request to the service. You have to POST the SOAP request to the service to get it to respond.

                  Comment


                  • #10
                    Hi RShelly,

                    Thanks for assurance that m on right way...

                    but i have no idea like how to post the SOAP request to the service???

                    I need to call spring web services from two types of client:

                    1)--->Java client which uses spring

                    org.springframework.ws.client.core.WebServiceTempl ate

                    setting marshaller,unmarshaller and defaultUri .....for eg. following config gives 404 error while calling using WebServiceTemplate marshallsendandreceive(obj)

                    <bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServi ceTemplate">
                    <property name="marshaller" ref="xmlBeansMarshaller"/>
                    <property name="unmarshaller" ref="xmlBeansMarshaller" />
                    <property name="defaultUri" value="http://localhost:8888/SpringWS/helloWorldService/Hello"/>
                    </bean>

                    Please somebody give resolution for above....


                    2)---> calling Endpoint service through BPEL process/ESB Routing service...



                    by pasting url in browser it was giving 405 method not found error but from spring client it gives 404 error....


                    Help me with creating client so that it successfully calls exposed service....



                    (Got confident as able to view dynamically generated WSDL ....... but strange thing i found in oc4j enterprise manager is .....this deployment is shown as application only ...not as webservice....so i still doubt whether it will work same way as any other web-service like for eg JAX-RPC web service....or need to do something else to make it a web service).....
                    Last edited by virfal; Dec 13th, 2007, 09:18 AM.

                    Comment


                    • #11
                      Personally, I use Netbeans, and it provides an interface for retrieving a wsdl and generating JAXB client classes for communicating with my web service, and marshalling/unmarshalling objects. So I'm not the best resource to answer your questions regarding OC4J or BPEL.

                      Comment


                      • #12
                        but according to log in my previous reply, do u think the web service was deployed perfectly fine...


                        still i need answer from u guys like ...how to call spring web service from WEB template......also if one wants to access it from url in browser to verify.....

                        from web template i am getting HTTP 404 error
                        and from browser url i am getting HTTP 405 method not found error...
                        Last edited by virfal; Dec 13th, 2007, 11:11 AM.

                        Comment


                        • #13
                          If you're getting a 404 when accessing the web service one way, and a 405 when accessing it a different way, then something must be wrong with the URL you're using in the first client. You won't be getting both a 404 and a 405 from the same URL with two different clients. I would make sure your client is using exactly the same URL as what you're putting in the browser to get the 405.

                          I use a capture tunnel to send my requests and responses through that then forwards the messages on to the proper destination, so that I can view the request and response to make sure it's what I expect. You could use something similar.

                          Comment


                          • #14
                            i tried with annotating method as given in airline example and added following part in config file ....

                            <bean class="org.springframework.ws.server.endpoint.mapp ing.PayloadRootAnnotationMethodEndpointMapping">
                            <property name="interceptors">
                            <list>
                            <bean class="org.springframework.ws.server.endpoint.inte rceptor.PayloadLoggingInterceptor"/>
                            <bean class="org.springframework.ws.soap.server.endpoint .interceptor.PayloadValidatingInterceptor">
                            <property name="schema" value="/WEB-INF/xsd/helloWorld.xsd"/>
                            <property name="validateRequest" value="true"/>
                            <property name="validateResponse" value="true"/>
                            </bean>
                            </list>
                            </property>
                            <property name="order" value="1"/>
                            </bean>

                            it has given same 404/405 error but
                            it started giving me warning in logger to indicate there is some problem with endpoint mapping.....

                            warning is as follow

                            Dec 13, 2007 2:31:57 PM org.springframework.ws.server.MessageDispatcher dispatch
                            WARNING: No endpoint mapping found for [SaajSoapMessage helloRequest]

                            Comment


                            • #15
                              Sounds like the request your sending doesn't match an endpoint mapping. I'd make sure the endpoint name, parameters, and parameter types are what they should be as per your xsd (your xsd generates the wsdl which the client uses to send the request, but if your endpoint doesn't match, then it won't work).

                              Comment

                              Working...
                              X