Full maven project can be downloaded from HERE.

This is a follow up article to XFIRE+EJB+POJO.
Here I show how to expose POJO using CXF project instead of XFire. Setting up WebServices with CXF is very easy and consists of two steps:

    • Setting up web.xml with CXFServlet.
    • Defining POJO endpoint.

Setting up web.xml with CXFServlet.

<!-- CXFServlet expect these spring configs already loaded by listeners, endpoint context files will be defined as servlet param.
This will allow us to have different CXFServlets with different endpoints -->








Most of CXF examples have one spring context file that gets loaded through a servlet listener.
The one above shows how to have multiple CXFServlets defined with their own endpoints context file.

Defining POJO endpoint.

<!--?xml version="1.0" encoding="UTF-8"?-->

<!-- ENDPOINTS -->


Like in XFire with EJB article “numberService” bean can be replaced with EJB proxy in order to expose EJB as SOAP WebService.

After deploying to Tomcat hit http://localhost:8080/number-services-webapp/numberservice?wsdl for autogenerated WSDL.

4 comments to CXF+SPRING+POJO

  • Olivier


    These two articles dealing with exposing services as web services are wonderful. Deployments work like a charm !

    I’m still fighting with exposing the EJB from the previous article with CXF. I’m getting a weird NPE when deploying to weblogic.

    The only thing I did in the spring config file is replacing


    Anything you’d advise to do ?

    Thanks again.

    at org.apache.cxf.interceptor.AnnotationInterceptors.getAnnotationObject(AnnotationIntercept

  • Olivier

    Missing the xml snippet. I replace numberService with NumberServiceSessionBeanProxy in the simple:serviceBean definition

  • tsolakp

    Did it work for you? I have only tested this project on Tomcat.

  • tsolakp

    “simple:server” creates adapter similar to “XFireExporter” (as explained in XFIRE+EJB+POJO article) which listens to http request at “base servler path/numberservice” address and converts SOA request to POJO method call and return value to XML according to its autogenerated WSDL.
    The “endpointName=:NumberService”, “serviceName=:NumberService”, “xmlns:e=
    ” and “xmlns:s=” are used in defining WSDL namespaces.
    For more check and

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>