Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: how to deploy Spring WS with JaxBMarshaller

  1. #1
    Join Date
    Dec 2007
    Posts
    15

    Default 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...
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2007
    Location
    Manila, Philippines
    Posts
    3

    Default

    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.

  3. #3
    Join Date
    Dec 2007
    Posts
    15

    Default

    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 at 10:34 AM.

  4. #4
    Join Date
    Jul 2006
    Posts
    138

    Default

    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.

  5. #5
    Join Date
    Dec 2007
    Posts
    15

    Default

    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

  6. #6
    Join Date
    Jul 2006
    Posts
    138

    Default

    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.

  7. #7
    Join Date
    Dec 2007
    Posts
    15

    Default

    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 virfal@yahoo.com........... 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 at 10:11 AM.

  8. #8
    Join Date
    Dec 2007
    Posts
    15

    Default

    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
    Attached Files Attached Files
    Last edited by virfal; Dec 12th, 2007 at 04:11 PM.

  9. #9
    Join Date
    Jul 2006
    Posts
    138

    Default

    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.

  10. #10
    Join Date
    Dec 2007
    Posts
    15

    Default

    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 at 08:18 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •